0% found this document useful (0 votes)
28 views54 pages

Ch4 Linux Networking

Uploaded by

animut0934
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views54 pages

Ch4 Linux Networking

Uploaded by

animut0934
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 54

BAHIR DAR UNIVERSITY

Bahir Dar Institute of Technology


Faculty of Computing

System and Network Administration


Chapter 4: Linux
Networking
4.1 Introduction to
Linux network
4.2 SSH
4.3 DHCP protocol
4.4 DHCP client
4.5 DHCP Server
TCP/IP Protocol Stack

Application (FTP, HTTP, DNS)

Transport Layer (TCP,UDP)

Network Layer (IP)

Link Layer (Device Drivers)

Physical Layer (media)


TCP/IP Protocol Stack
TCP/IP Packet Encapsulation

Service Data

TCP/UDP T/U Data

IP IP T/U Data

Ethernet/PPP E IP T/U Data E

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:

Unicast – addresses that refer to a single


network interface
Multicast – addresses that simultaneously
target a group of hosts
Broadcast – addresses that include all hosts on
the local subnet
Ethernet Addressing
Assigned by manufacturer (hardware)
Must be absolutely unique
Address format
6 octets in hex (#:#:#:#:#:#)
First 3 octets: Manufacturer Identifier
Last 3 octets: Card serial number


Hostnames
Uniquely identifies each system

Fully Qualified Domain Name

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

ifconfig – View/Configure interface (Linux)


ipconfig –view interface configure in
windo
Interface Configuration
Any device use symbol to
determine
eth0: Ethernet device number 0
eth1: Ethernet device number 1
lo : local loopback device
Wlan0 : Wireless LAN device
Ifconfig
Ifconfig
• eth0 add 10.133.120.153
• broadcast 10.133.120.255
• netmask 255.255.255.0
Netmask forces TCP/IP to go only to the
router interface for any address except
those in 10.133.120.
Broadcast limits broadcasts to the
10.133.120. subnet
Configuring /etc/hosts File

The /etc/hosts file is just a list of IP addresses and
their corresponding server names.


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

#nano #nano /etc/network/interfaces


/etc/resolv.conf auto eth0
search bdu.edu.et iface eth0 inet static
address 10.133.120.253
nameserver
10.133.5.15 gateway 10.133.120.1
broadcast 10.133.120.255
nameserver
10.132.5.15 netmask 255.255.255.0
dns-nameservers
nameserver 4.2.2.2
10.133.5.15 10.132.5.15
dns-search bdu.edu.et
Network Testing
Localhost reachability
Hostname reachability
Local network reachability
Internet network reachability
Network tools
ping – Reachability test
traceroute – Routing performance
netstat – Network performance stats
tcpdump – Packet sniffing
nslookup/dig
Chapter 4: Linux
Networking
4.1 Introduction to
Linux network
4.2 SSH
4.3 DHCP protocol
4.4 DHCP client
4.5 DHCP Server
SSH – security shell
As a system administrator, you spend most
of your time at the datacenter
If you have the necessary tools, you don’t
need to be at the datacenter physically
You can log into any of the servers remotely
from your personal computer
 One of the tools for remote login is telnet
SSH
Secured SHell
Connecting to internet increases
vulnerability
Firewalls are not enough
telnet send username and password as
simple text
ssh is a secured telnet which encrypts
commands, usernames and passwords
in a remote login
OpenSSH is commonly used tool
Others: putty, freeSSH, secureCRT
SSH
To install SSH-client
apt-get install ssh
To install SSH-server
apt-get install openssh-server
To login into a remote machine
(IP:10.133.120.30) with username Abebe
onto
ssh [email protected]
SSH
Reading assignments:
Secured copy to a remote machine
Secured FTP
Chapter 4: Linux
Networking
4.1 Introduction to
Linux network
4.2 SSH
4.3 DHCP protocol
4.4 DHCP client
4.5 DHCP Server
Dynamic Host Configuration
Protocol
• DHCP - centrally control IP-related information
and eliminate the need to manually keep track of
where individual IP addresses are allocated
• Two basic functions:
– Provide a mechanism for assigning addresses to hosts
– A method by which clients can request addresses and
other configuration data from server
• In a DHCP-enabled host, a special message is sent
out requesting an IP address and a subnet mask
from a DHCP server
• DHCP server responds with information the client
requests such as IP address, default gateways,
NetBios
• DHCP provides static and dynamic address
allocation that can be manual or automatic.
DHCP operation
IP lease request
• First step in obtaining an IP address under
DHCP
• It is initiated by a host with TCP/IP,
configured to obtain an IP address
automatically
• Since the requesting client is not aware of
its own IP address, or that belonging to the
DHCP server,
– it will use 0.0.0.0 for client and 255.255.255.255
for DHCP server with UDP ports 67 (client) and
68 (server)
– Message includes MAC address of client for the
reply
 known as a DHCP discover
DHCP operation
IP lease offer
• DHCP offer consist of an IP address, subnet
mask, lease period (in seconds), and the IP
address of the proposing DHCP server
• Offer sent to requesting MAC address
• The pending IP address offer is reserved
temporarily to prevent it from being taken
simultaneously by other machines
DHCP operation

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

2. Servers make an offer


 All servers on the subnet unicast a DHCPOFFER packet saying “I can
supply you with DHCP information, if you like.” What Do You
need

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.

5. Client releases You Can Have it Back


 The client finishes it’s work, and send a DHCPRELEASE
packet saying “I’m done with the IP address.”
 The server records that the IP address is not in use.
Chapter 4: Linux
Networking
4.1 Introduction to
Linux network
4.2 SSH
4.3 DHCP protocol
4.4 DHCP client
4.5 DHCP Server
DHCP Client
dhclient - DHCP client daemon, included with
many popular Linux distributions,
is the software component used to talk to a
DHCP server
If invoked, it will attempt to obtain an address
from an available DHCP server and then
configure its networking configuration
accordingly.
Configuration of /etc/network/interfaces:
auto eth0
Iface eth0 inet dhcp
DHCP Client
Configuring the DHCP Client
The client is typically run from the startup files,
but it can also be run by hand.
It’s typically started prior to other network-
based services, since other network services are
of no use unless the system itself can get on the
network.
On the other hand, the client can be invoked at
the command line any time after startup.
The command to invoke the client is: dhclient
DHCP Client
DHCP Client
Optionally, the client daemon can be started
with additional flags that slightly modify the
behavior of the software.
For example, you can optionally specify the
interface (such as eth0) for which an address
lease should be requested.
dhclient eth0
For the full syntax of the command is use read
the manual page: man dhclient
DHCP Client
In order to keep track of leases across system
reboots and server restarts, dhclient keeps a
list of leases it has been assigned in the
dhclient.leases(5) file.
On startup, after reading the dhclient.conf file,
dhclient reads the dhclient.leases file to
refresh its memory about what leases it has
been assigned.
DHCP Client
It is also possible to specify interfaces by
name in the dhclient.conf file.
If interfaces are specified in this way, then the
client will only configure interfaces that are
either specified in the configuration file or on
the command line, and will ignore all other
interfaces.
On startup, dhclient reads the dhclient.conf
for configuration instructions. It then gets a
list of all the network interfaces that are
configured in the current system.
Chapter 4: Linux
Networking
4.1 Introduction to
Linux network
4.2 SSH
4.3 DHCP protocol
4.4 DHCP client
4.5 DHCP Server
DHCP Server

The DHCP server, is responsible for serving IP


addresses and other relevant information
upon client request.
Since the DHCP protocol is broadcast-based, a
server will have to be present on each subnet
for which DHCP service is to be provided.
Installation on ubuntu:
apt-get install dhcp3-server
apt-get install isc-dhcp-server
DHCP Server

The main configuration file on Ubuntu is


/etc/dhcp3/dhcpd.conf
The configuration file consists of a set of
global directives followed by one or more
subnet definitions.
Comments are prefixed with hash marks (#).
DHCP Server

Like most configuration files in UNIX, the file is


ASCII text and can be modified using your
favorite text editor.
The general structure of the configuration file
is as follows:
DHCP Server

Global Settings of sample dhcpd.conf


configuration
DHCP Server
dns-update-style - specifies that our DHCP server
will not do DNS updates for addresses that it hands
out
default-lease-time: directive specifies how long a
DHCP lease will be active if a connecting client does
not specify a time.
max-lease-time: specifies the maximum lease
time allowed if the client does specify a time
Both settings specify a time in seconds.
log-facility: specifies how the system logger
should handle log entries generated by the DHCP
server
DHCP Server

option domain-name “bdu.edu.et";


This global setting specifies the domain name
of the organization that name-servers are
authoritive
option domain-name-servers 10.133.5.15,
10.132.15
This specifies list of DNS servers
All those global settings are common to all
clients acquiring IP from this server
DHCP Server

To each subnet within the network, the


default gateway and IP address range
should be specified.
subnet 10.133.120.0 netmask 255.255.255.0
{
option range 10.133.120.5 10.133.120.250;
option router 10.133.120.1
}
Add DNS

subnet 10.133.120.0 netmask 255.255.255.0


{
option range 10.133.120.5 10.133.120.250;
option domain-name-servers 10.1.25.15,
8.8.8.8;
option router 10.133.120.1
}
Host specific address
subnet 10.133.120.0 netmask 255.255.255.0
{
option range 10.133.120.5 10.133.120.250;
option domain-name-servers 10.1.25.15, 8.8.8.8;
option router 10.133.120.1
}

host web-server {
hardware ethernet 00:17:a4:c2:44:22;
fixed-address 10.133.120.200;
}

You might also like