CS469 - Linux and Unix Administration and Networking

Internet Protocol (IP) (man 7 ip)

Provides a route-able protocol for delivering data-gram packets across networks based on IP address. There are two version, version 4 (IPv4) which uses 32 bit addresses (< 4 billion addresses) and a less widely used version 6 (IPv6) which uses 128 bit addresses (< ~340 undecillion addresses). For now IPv4 still remains the primary Internet protocol:

  • An IPv4 Header contains among other information:

    • Source IP address
    • Destination IP address
    • Total length of the IP packet
    • Protocol - i.e. TCP / UDP - The protocol encapsulated within the IP packet
    • Time to live (TTL) - A number decremented at every hop along the packets journey, upon reaching zero, the packet is discarded. This prevents a packet caught in a loop from being passed around forever.
    • Other fields for IP fragmentation and options.
  • Packets are routed based on destination. It isn't necessarily the case that a packet will be returned along the same path that one was sent. It is also the case that the source address can be completely bogus.



  • List of protocols (man 5 protocols) (mostly useful to programmers)


> ifconfig

  • Configure a network interface (being deprecated)


ifconfig eth0 netmask broadcast
or maybe: ifconfig eth0

  • Configures eth0 for:
IP address
Broadcast address

> ip

  • show/manipulate routing, devices, policy routing and tunnels. Too many options to list. Typically not used by humans, but in scripts.

IPv4 Addresses:

  • Consist of 32 bits, typically listed in 4 8-bit "octet" dot-decimal notation.

  • Distributed by the Internet Assigned Numbers Association (IANA) a department of ICANN (Internet Corporation of Assigned Names and Numbers):

    • Delegates allocations to Regional Internet Registries (RIRs) which each address different areas of the world.

    • Administers the data in the root domain name servers

    • ICANN also:

      • Administers protocol parameters of IETF (Internet Engineering Task Force (who publish the RFCs))
      • Maintain a time zone database.
  • IPv4 Private addresses:

    • These are addresses that are not routed on the internet (but might be routed on the local network.)
    • They consist of three reserved blocks:
CIDR Starting address Ending address Number of IPs (~16M) (~1M) (~65K)
  • The block is the loopback or localhost address range and is a virtual network range that exists only with a machine itself via the virtual loopback device lo or lo0, typically assigned the address

  • IP addresses are usually assigned in two ways:

    • Static assignment, where the IP address is configured manually on the host and does not change.

    • Dynamic assignment, where a protocol, such as DHCP (Dynamic Host Configuration Protocol) or BOOTP is used to request an IP address.

  • The Broadcast address for a host is the host part of the IP address where all bits are 1's.
    (| ->
    Packets with the destination set to the broadcast address are typically recieved by all machines on the local network.

  • Multicast IP addresses: (

Network commands:

> route

  • print and set routes

> routel

  • List routes

> traceroute [-n] hostname

  • Show routes taken from host to destination.

# echo "1" > /proc/sys/net/ipv4/ip_forward

  • Enables packet forwarding between interfaces. Lets Linux be a gateway.

> ping hostname

  • Send ICMP echo's to a machine.


  • Classful network design:

    • Originally divided networks into 3 sizes, Class A (24 bits), Class B (16 bits) (ISU's network was originally a Class B network ( and Class C (8 bits).
  • Classless Inter-Domain Routing (CIDR)

    • Prior to CIDR IPv4 networks were represented using dot-decimal notation for both IP address and netmask: (classful) == (CIDR)
  • CIDR divides an IP network into smaller logical sub-networks. Given:

[ Network prefix ][ Host number ]
                      /       \
[ Network prefix ][Subnet #][Host #]

  • The host part is determined by (IP address & ~ Netmask)
  • All zeros in the host part is reserved for the network ID.
  • All ones in the host part is reserved for the broadcast address.


  • (2 bits for host part)

    11111111.11111111.11111111.111111 00 Netmask:
    11000000.10101000.00000001.000000 00 Network address:
    11000000.10101000.00000001.000000 01 1st IP:
    11000000.10101000.00000001.000000 10 2nd IP:
    11000000.10101000.00000001.000000 11 Broadcast address:
  • (2 bits for host part, second network)

    11111111.11111111.11111111.111111 00 Netmask:
    11000000.10101000.00000001.000001 00 Network address:
    11000000.10101000.00000001.000001 01 1st IP:
    11000000.10101000.00000001.000001 10 2nd IP:
    11000000.10101000.00000001.000001 11 Broadcast address:
  • (16 bits for host part)

    11111111.11111111. 00000000.00000000 Netmask:
    11000000.10101000. 00000000.00000000 Network address:
    11000000.10101000. 00000000.00000001 1st IP:
    11000000.10101000. 11111111.11111110 last IP:
    11000000.10101000. 11111111.11111111 Broadcast address:
  • (8 bits for host part):

    11111111.11111111.11111111. 00000000 Netmask:
    10001011.01100110.00001110. 00000000 Network address:
    10001011.01100110.00001110. 00000001 1st IP:
    10001011.01100110.00001110. 11111110 last IP:
    10001011.01100110.00001110. 11111111 Broadcast address: