Learning Python Network Programming

(Sean Pound) #1
Chapter 1

Documented as RFC 1035, the Domain Name System (DNS) is a globally distributed
database of mappings between hostnames and IP addresses. It is an open and
hierarchical system with many organizations choosing to run their own DNS servers.
DNS is also a protocol, which devices use to query DNS servers for resolving
hostnames to IP addresses (and vice-versa).


The nslookup tool comes with most Linux and Windows systems and it lets us
query DNS on the command line, as follows:


$ nslookup python.org


Server: 192.168.0.4


Address: 192.168.0.4#53


Non-authoritative answer:


Name: python.org


Address: 104.130.43.121


Here, we determined that the python.org host has the IP address 104.130.42.121.
DNS distributes the work of looking up hostnames by using an hierarchical system
of caching servers. When connecting to a network, your network device will be given
a local DNS server through either DHCP or manually, and it will query this local
server when doing DNS lookups. If that server doesn't know the IP address, then it
will query its own configured higher tier server, and so on until an answer can be
found. ISPs run their own DNS caching servers, and broadband routers often act as
caching servers as well. In this example, my device's local server is 192.168.0.4.


A device's operating system usually handles DNS, and it provides a programming
interface, which applications use to ask it to resolve hostnames and IP addresses.
Python provides an interface for this, which we'll discuss in Chapter 6, IP and DNS.


The protocol stack or why the Internet is like a cake


The Internet Protocol is a member of the set of protocols that make up the Internet
protocol suite. Each protocol in the suite has been designed to solve specific
problems in networking. We just saw how IP solves the problems of addressing
and routing.

Free download pdf