Network Administration

This tutorial explains basic network configuration commands in Linux with examples.

In Linux several networking tools are available to manage the network. RHCE exam include several networking related questions. During the exam you need to configure the network. For RHCE exam you must know the following commands and their uses.

  • ifconfig
  • ifup
  • ifdown
  • ping
  • arp
  • netsat -r
  • route -n
  • dhclient
  • system-config-network
  • service network [start][restart]
  • chkconfig --list network
  • chkconfig network on

ifconfig

Every computer in network requires an IP address. With ifconifg command you can easily check the current configuration of active network adapters.

#ifconfig

ifconfig

Default ifconfig command would display the current state of all active network adapters. To display the current configuration of a specific adapter use its number with ifconfig command. For example to display the current configuration of first adaptor only run following command

#ifconfig eth0

ifconfig eth0

During the exam if you think ifconfig command is missing any network adaptor, use -a option to list the configuration of all network adaptors, whether or not they are currently active.

#ifconfig -a

Other use of ifconfig command

How to assign IP address from ifconfig command

ifconfig command can also be used to assign the IP address. For example to assign IP address and subnet mask to eth0 adapter run following command

#ifconfig eth0 192.168.1.34 netmask 255.255.255.0

ifconfig netmask

How to activate or deactivate network adapter from ifconfig command

With ifconfig command you can also activate or deactivate the network adaptor. To deactivate network adaptor run following command

#ifconfig [network adaptor] down

ifconfig eth down

To activate the network adaptor run following command

#ifconfig [network adaptor] up

ifconfig eth up

During the exam use ifconfig command to list the current configuration of network adaptors only. There are better tools available for above tasks. To assign IP address use system-config-network. To activate or deactivate network adapter use ifup and ifdown commands.

ifdown

ifdown command is used to deactivate the network adaptor. syntax of ifdown is following

#ifdown [network adaptor]

ifdown

ifup

ifup command is used to activate the network adaptor. syntax of ifup is following

#ifup [network adaptor]

ifup

ping

ping command is used to test the connectivity. ping command on linux works continuously. We need to press CTRL+C to stop it. If you are connected with internet, you can also check the connectivity with website. For example to test connectivity with our site run following command

#ping www.computernetworkingnotes.com

ping

During the exam you will not have internet access. ping command works on local network as well. Whenever you have trouble in connecting with network, use ping command in following order.

  • ping with localhost
  • ping with self IP address
  • ping with default gateway IP address
  • ping with remote computer IP

ping order

arp

Address resolution protocol (ARP) bind MAC address with IP address. APR protocol works only in local network as MAC address are not routable. ARP table keep entries of local network systems. It is helpful to detect duplicate address on the network.

arp

  • The Address column lists detected IP addresses on the network.
  • The HWtype column shows the hardware type of the adapter.
  • The HWaddress column shows the hardware address of the adapter.

netsat -r and route -n

netstat command with -r option is equivalent to the route command with -n option. Both will display the routing table.

netstat

Routing table can be very helpful during the exam to detect misconfigured gateway.

dhclient

dhclient command fetch IP configuration for calling network card. For example following command will fetch IP configuration for eth0 network card from DHCP server.

dhclient

#dhclient eth0

How to assign IP address in Linux

ifconfig command can be used to assign the IP address but as I said above during the exam we should use best available command. Use system-config-network command to assign IP address.

#system-config-network

system config network

How to restart network service

Whenever you made change in IP configuration, you have to restart the network service so change can be applied. To restart network service run following command

#service network restart

How to start network service

During the exam you may get a system with network service disabled. To check network service run following command.

chkconfig list

if network service is off, run following command to on it.

chkconfig on