Domain Name System.
- http://tools.ietf.org/html/rfc1034
- http://tools.ietf.org/html/rfc1035
- http://tools.ietf.org/html/rfc4343 clarifies that domains are case insensitive. <www.ExAmPlE.COM>
Part of the application layer.
Standard IANA port: 53/UDP
Protocol that convert strings into IPs, for example:
http://www.google.com -> 173.194.34.34
Before before using an address such as www.google.com
, any program such as a browser must first resolve the hostname www.google.com
into an IP by asking that from a server.
Linux systems usually offer man resolver
C library interface, which any program can use to resolve DNS names. The resolver library may cache results across applications that have already been resolved.
On the Internet, hostnames are resolved to IPs by DNS servers.
You must pay to reserve hostnames so they can be resolved to the IP of your choice.
TODO how to DNS servers find out all the hostnames in the world?
DNS can also be done for local networks:
computer2 -> 192.168.0.3
In which case the DNS server normally resides on the router.
Client computers on the network are informed that it is a DNS server via DHCP.
On your LAN, people can use the host name to communicate between computers
For example, John is running an Apache server on the usual port 80. He has hostname john
.
Mary is on the same network. Therefore, she can refer to john
simply as john
. For example:
ping john
firefox john
TODO if many people set up the same hostname, then what?
It is possible to redirect all subdomains that don't match any other rule to a single IP by using a wildcard DNS record:
- http://en.wikipedia.org/wiki/Wildcard_DNS_record
- http://stackoverflow.com/questions/9627613/heroku-wildcard-domains-with-godaddy
This can be used to implement functionality like GitHub pages on a website, allowing users to have their own subdomains for potentially non safe HTML content, while avoiding CSRF attacks.
Does DNS and rDNS
DNS:
host www.google.com
Sample output:
www.google.com has address 74.125.206.147
www.google.com has address 74.125.206.106
www.google.com has address 74.125.206.104
www.google.com has address 74.125.206.105
www.google.com has address 74.125.206.103
www.google.com has address 74.125.206.99
www.google.com has IPv6 address 2a00:1450:400c:c0a::93
rDNS:
host 173.194.40.194
Sample output:
194.40.194.173.in-addr.arpa domain name pointer par10s12-in-f2.1e100.net
TODO understand that output. Why is google.com
nowhere to be seen?
TODO: why does host 74.125.206.147
(one of the IPs for www.google.com
) give:
Host 147.206.125.74.in-addr.arpa. not found: 3(NXDOMAIN)
cat /etc/resolv.conf
Lists DNS servers.
This file may be automatically generated by utilities.
On Ubuntu 12.04, you should never edit that file manually. By default it contains:
nameserver 127.0.1.1
which is localhost
, and is used indirectly by the NetworkManger system, which you should use instead.
TODO does it specify the config file location? resolv.conf
POSIX function to resolve hostnames:
http://pubs.opengroup.org/onlinepubs/009695399/functions/freeaddrinfo.html
Print currently desired hostname:
echo $HOSTNAME
hostname
In the default bash PS1
line for Ubuntu and many systems you see: ciro@ciro-Thinkpad-T430
, then the hostname is ciro-Thinkpad-T430
.
Change hostname for cur session:
h=
sudo hostname "$h"
prompt PS1
is not changed immediately.
h=
echo "$h" | sudo tee /etc/hostname
Host is referred to as "computer name". Good name choice, that is exactly what host is.
wmic computersystem where name="%COMPUTERNAME%" call rename name="NEW-NAME"
When you register for a domain of your own, you will start thinking about this: it is the main setting on your registrar interface.
http://en.wikipedia.org/wiki/Zone_file
@
in the zone file means the domain you own without any subdomain.
E.g., if you own cirosantilli.com
, @
means cirosantilli.com
itself, while www
means www.cirosantilli.com
.
Apex domains are more restrictive than subdomains, and certain hosting services advise against it, such as GitHub Pages.
The main problem is that in services such as GitHub pages you don't get an actual IP, so you can't point the Apex to an IP (which is simple), and the CNAME
"workaround" is not good enough in that case.
The apex domain is sometimes called naked domain, since it has no subdomain.
TODO File that tells DNS to redirect to another domain name, creating an alias.
http://en.wikipedia.org/wiki/CNAME_record
Points a domain to an IP. The final part of the resolution.
http://en.wikipedia.org/wiki/Reverse_DNS_lookup
Protocol that transforms an IP into a hostname.
Not always supported on all DNS servers.
Dynamic DNS.
A way to update DNS as IPs change.
Useful for example if you want to give a hostname for your home network, in which the IP is dynamic for most ISPs. A DDNS service like http://www.noip.com can give you a persistent hostname anyways.
TODO what is it exactly? How does it work? A protocol? Part of DNS?
- dig