Ch4 Linux Networking
Ch4 Linux Networking
Service Data
IP IP T/U Data
UTP/PSTN
TCP/IP Packet Encapsulation
Connecting to a Network
Hostname and IP Address
assignment
Configuration of hardware
Default route (gateway)
assignment
Name Service Configuration
Addressing mechanism
Like letters or email messages,
network packets must be properly
addressed in order to reach their
destinations.
Several addressing schemes are used in
combination:
MAC (media access control) addresses for
use by hardware
IPv4 and IPv6 network addresses for use by
software
Hostnames for use by people
Address types
The IP layer defines several broad types of
address, some of which have direct
counterparts at the link layer:
Hostnames
Uniquely identifies each system
hostname.site.domain[.country]
Country: 2 letter identifier for country
(et, uk)
Domain: Type of site (edu, com, org,
gov)
Site: Unique name of organization
(bdu, dmu)
Hostname: Unique name of system
(www, mail)
Interface Configuration
Hardware to connect to network
Common interfaces
Ethernet
Modem
Your server will typically check this file before
referencing DNS. If the name is found with a
corresponding IP address then DNS won't be
queried at all.
15
Configuring /etc/network/interfaces
The file /etc/network/interfaces file stores
permanent IP address assignment to
interfaces
auto eth0
iface eth0 inet dhcp/static
address ip4
gateway defaultgatewayIP
netmask subnetmask
broadcast broadcastaddress of subnet
Configuring /etc/network/interfaces
Example configuration
auto eth0
Iface eth0 inet static
address 10.133.120.20
network 10.133.120.0
netmask 255.255.255.0
gateway 10.133.120.1
broadcast 10.133.120.255
Save file and restart network
# /etc/init.d/networking restart
Name Services
/etc/hosts
Local configuration
Localhost – 127.0.0.1
/etc/resolv.conf
Domain Name Service (DNS)
lookup
search: domains to search if not
FQDN
nameserver : Nameservers
Name Services
IP lease selection
– client machine selects the first IP address offer
it receives.
– The client replies by broadcasting an
acceptance message, requesting to lease IP
information.
– Just as in stage one, this message will be
broadcast as a DHCP request, but this time, it
will additionally include the IP address of the
DHCP server whose offer was accepted.
– All other DHCP servers will then revoke their
offers
DHCP operation
IP lease acknowledgment
• The accepted DHCP server proceeds to assign an
IP address to the client, then sends:
– DHCPACK – positive acknowledgment
– DHCPNACK - negative acknowledgment
• If the client is attempting to lease its old IP address,
which has since been reassigned elsewhere.
• The requesting client has an inaccurate IP address,
resulting from physically changing locations to an
alternate subnet
• Negative acceptance messages can also mean
that the requesting client has an inaccurate IP
address, resulting from physically changing
locations to an alternate subnet.
• The client machine integrates the new IP
information into its TCP/IP configuration.
DHCP operation
Lease renewal:
• The leasing client will send
– DHCPREQUEST - to the DHCP server when its lease
period has elapsed by 50%.
• If the DHCP server is available, and there are no
reasons for rejecting the request, a DHCP
acknowledge message is sent to the client,
updating the configuration and resetting the
lease time.
• If the server is unavailable, the client will receive
an ‘eviction’ notice stating that it had not been
renewed.
– Client would still have a remaining 50% lease time to use
the IP
– React by sending out an additional lease renewal
attempt when 87.5%
– if DHCPACK is received, renew the lease.
DHCP operation
Lease release
• If the client elects to cancel the
lease, or is unable to contact the
DHCP server before the lease
elapses, the lease is automatically
released.
• Note that DHCP leases are not
automatically released at system
shutdown.
• A system that has lost its lease will
attempt to re-lease the same address
DHCP operation
Summary of DHCP protocol
How does DHCP work?
1. Server discovery
Client DHCPDISCOVER packet asking “Who can give me DHCP
information?” Hello
3. Client requests
The client selects one of the responses, and broadcasts a
DHCPREQUEST packet saying “I choose server XYZ. Server XYZ, here’s
my MAC address, what’s my IP address?” Give Me An
Summary of DHCP protocol
4. Server responds Here It is and for
How long
The server responds with a DHCPACK packet saying
“Here is your IP address. It’s good for 24 hours.”
The response can contain additional information, if the
client asked for it.
The server records that the IP address is in use.
host web-server {
hardware ethernet 00:17:a4:c2:44:22;
fixed-address 10.133.120.200;
}