Lesson 5

Dates: 6/12/2017
Linux networking
Linux System Administration


Configuring Linux on a network


  • HOWTO configure the network interface and routing by
    using commands /sbin/ifconfig and /sbin/route

    Command to check the interface configuration:
    /sbin/ifconfig -a
    
    or
    ip addr list
    
    Command to check the routing configuration:
    /sbin/route -n
    
    or
    netstat -nr
    

    Command to stop the interface:
    /sbin/ifconfig eth0 down
    
    or
    /sbin/ifdown eth0
    

    Command to configure the interface:
    /sbin/ifconfig eth0 192.168.5.18 netmask 255.255.255.0 up
    
    Command to configure the routing to the gateway:
    /sbin/route add default gw 192.168.5.240 eth0
    

  • HOWTO Configure the network interface and routing by using the startup scripts.

    Static IP address configuration on 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 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