Linux Services Organization

Our goal, introduce Linux services to the enterprise world.
Contact us in contact@linuxsv.org

Linux Services Organization : Linux Network Linux Server

On Red Hat Linux the network communications between nodes is done through the software network interfaces (real or virtual) related with the physical network interfaces (real). The following are the keys files in order to integrate a system on the network :

/etc/hosts

The main propose of this file is provide local DNS resolving. It can be used to resolve hostnames in small networks without DNS server.

$ cat /etc/hosts

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.10.6 server


On this system server hostname is resolved to 192.168.10.6

/etc/resolv.conf

In this file is where the connection with a DNS server is configured.

$ cat /etc/resolv.conf

search lso.net
nameserver 192.168.10.6


This system will forward all lso.net (an other domains) DNS queries to 192.168.10.6 DNS server.

/etc/sysconfig/network

In this file is where the network activation is configured. It also set-up the system hostname.

$ cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=rhel6-srv


With the parameter 'NETWORKING=no' the system will not have network connections.

/etc/sysconfig/network-scripts/ifcfg-*

These are the configuration scripts (real or virtual) associated with the physical interfaces (real). For example the configuration script for eth0 network interface is /etc/sysconfig/network-scripts/ifcfg-eth0

$ cat /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE="eth0"
HWADDR="00:0C:29:21:F7:7F"
NM_CONTROLLED="yes"
ONBOOT="yes"
BOOTPROTO="none"
IPADDR=192.168.10.6
NETMASK=255.255.255.0
GATEWAY=192.168.10.1


* These interfaces can activated/deactivated individually with the commands ifup/ifdown :

$ ifup eth0
Activates network interface eth0 as specified on /etc/sysconfig/network-scripts/ifcfg-eth0

$ ifdown eth0
Deactivates interface eth0

* If the interface eth0 is configured with the parameter "ONBOOT=yes" it will be activated as specified on ifcfg-eth0 with the command :

$ /etc/init.d/network start

And deactivated with

$ /etc/init.d/network stop

All interfaces configured with "ONBOOT=yes" will be activated/deactivated at the same time with the command '/etc/init.d/network start/stop'

* The following are some useful options to be considered on /etc/sysconfig/network-scripts/ifcfg-* file :

BOOTPROTO="dhcp"
The interface will get the ip with dhcp protocol

PEERDNS="yes"
When is BOOTPROTO="dhcp" the dhcp server provides an ip to the interface and the DNS server on /etc/resolv.conf.

USERCTL="yes"
Non-root users can activate/deactivate the network interface.

Useful Network commands

route

This command displays/change the routing table information.

$ route -n
Displays system routing information

$ route add default gw 192.168.10.1
Sets the system default gateway to 192.168.10.1

ifconfig

With this command the network interfaces can be configured overwriting the values on ifcfg-* files.

$ ifconfig
Shows the network configuration of all configured network interfaces.

$ ifconfig eth0 192.168.10.6
It assigns the ip 192.168.10.6 to the network interface eth0

$ ifconfig eth0:1 192.168.10.61
It creates a virtual network interface eth0:1 from eth0 with the ip 192.168.10.61.

$ ifconfig eth0 up/down
Activates/deactivates eth0 network interface

dhclient

This command is a dhcp-client that queries dhcp network configuration for the network interface to any active dhcp server.

$ dhclient eth0
Configures eth0 with the dhcp configuration retrieved.

system-config-network

This command launches a graphical application that configures the network interfaces, including wireless interfaces.

arp

The arp command manages the relation between IP address and MAC address.

$ arp -a
? (192.168.10.223) at 00:0c:29:4b:ce:ed [ether] on eth0
? (192.168.10.6) at 00:0c:29:21:f7:7f [ether] on eth0

Shows all arp entries cached by the system

$ arp -d hostname
Removes hostname arp entry

$ arp -s hostname MAC
Adds hostname arp entry with mac MAC

ethtool

Display/changes the network card settings.

$ ethtool eth0
Settings for eth0:
Current message level: 0x00000007 (7)
Link detected: yes

This commands verifies that there is a network wire plugged on eth0 network card.

Questions

1.- By default when a hostname resolution is done first the file /etc/hosts is checked and then the DNS server specified on /etc/resolv.conf (true/false)

2.- Only one DNS server can be configured on /etc/resolv.conf (true/false)

3.- Only root can manage network interfaces via ifcfg-* scripts (true/false)

4.- Which parameter must be specified on ifcfg-eth1 network script in order to start eth1 at boot ?

5.- Which parameter must be specified on ifcfg-eth0 network script in order to get eth0 network configuration via dhcp server ?

6.- Which command must be used in order to display the system arp table ?

7.- The command 'route -n 192.168.10.1' sets the system default gateway to 192.168.10.1 (true/false)

8.- Which command must be used in order to verify if there is a network wire plugged on eth1 network interface ?

9.- Which of the following commands can be used in order activate eth0 network interface ?
A - ifup eth0
B - ifconfig eth0 up
C - Both of them
D - None of them

10.- Which of the following commands can be used in order configure 192.168.10.1 as default gateway ?
A - route add default gw 192.168.10.1
B - ifconfig eth0 default gw 192.168.10.1
C - Both of them
D - None of them

Labs

1.- Configure the network interface eth0 to start as a client dhcp at boot.

2.- Create the virtual network interface eth0:1 with the ip 192.168.10.20. Make sure eth0:1 start at boot.

3.- Configure the system default gateway to 192.168.10.30 .

-- This page is part of Linux Server online tutorial --