Lesson 5

Dates: 6/5/2019
Linux networking
Linux System Administration


Classical network configuration


Command to check the interface configuration (RedHat):
/sbin/ifconfig -a
or, on the recent Linux systems (Ubuntu 18.04)
ip addr show 
or
ip a

Command to check the routing configuration (RedHat):
/sbin/route -n
or
netstat -nr
Command to chommand to check the routing configuration (Ubuntu 18.04):
ip route show

Command to stop the interface (RedHat):
/sbin/ifconfig eth0 down
or
/sbin/ifdown eth0
Command to stop the interface (Ubuntu 18.04):
ip link set eth0 down`

Command to configure the interface (RedHat):
/sbin/ifconfig eth0 192.168.5.18 netmask 255.255.255.0 up
Command to configure the interface (Ubuntu 18.04):
       
ip address add 192.168.5.18 dev eth0
ip link set eth0 up

Command to configure the routing to the gateway (RedHat):
/sbin/route add default gw 192.168.5.240 eth0
Command to configure the routing to the gateway (Ubuntu 18.04):
ip route add 192.168.5.0/24 via 192.168.5.240 



Static IP address configuration on older Ubuntu in /etc/network/interfaces
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 192.168.5.18
netmask 255.255.255.0
gateway 192.168.5.240

Dynamic (DHCP) configuration on older Ubuntu:
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp


Static IP address configuration on RedHat:
Specific settings for the network cards go into the config files in directory /etc/sysconfig/network-scripts. For example, /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=none
IPADDR=192.168.5.18
NETMASK=255.255.255.0
NETWORK=192.168.5.0
BROADCAST=192.168.5.255

Dynamic (DHCP) configuration on RedHat:
The interface configuration file for eth0, /etc/sysconfig/network-scripts/ifcfg-eth0:
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=dhcp

For the name resolution, configure /etc/hosts, /etc/resolv.conf, /etc/nsswitch.conf


Take me to the Course Website