Network Configuration
This article covers network configuration on Linux, with specific reference to the information needed for the RHCSA EX200 and RHCE EX300 certification exams.
Remember, the exams are hands-on, so it doesn’t matter which method you use to achieve the result, so long as the end product is correct.
Related articles.
- NIC Channel Bonding in RHEL 5 & 6 (CentOS & Oracle Linux)
- Routing IP Traffic on Linux
- Use iptables to Implement Packet Filtering and Configure Network Address Translation (NAT)
Networking Files
The “/etc/sysconfig/network” file holds top-level networking configuration, including the hostname and gateway settings.
# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=rhce1.localdomain
GATEWAY=192.168.122.1
#
The “/etc/sysconfig/network-scripts/ifcfg-eth0” file holds the network configuration for the “eth0” adapter. If you have multiple network adapters, you would expect additional configuration files (eth1, eth2 etc.). The following example contains the configuration for a DHCP adapter.
# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT=yes
TYPE=Ethernet
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth0"
UUID=5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03
HWADDR=52:54:00:91:6A:B3
PEERDNS=yes
PEERROUTES=yes
#
The following example is for a static IP address.
# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
NM_CONTROLLED=yes
ONBOOT=yes
TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth0"
UUID=5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03
HWADDR=52:54:00:91:6a:b3
PEERROUTES=yes
IPADDR=192.168.122.89
NETMASK=255.255.255.0
GATEWAY=192.168.122.1
DNS1=192.168.122.1
USERCTL=no
#
The “/etc/hosts” file contains information for local name resolution.
# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
192.168.122.89 rhce1.localdomain rhce1
#
The “/etc/resolv.conf” file is used to configure the location of the DNS servers to be used for name resolution. There can be multiple “nameserver” lines, one for each nameserver.
# cat /etc/resolv.conf
# Generated by NetworkManager
search localdomain
nameserver 192.168.122.1
#
The “/etc/sysconfig/network-scripts” directory contains a number of network related scripts and commands. The ifdown
and ifup
commands are used to stop and start the specified network adapters.
# ifdown eth0
Device state: 3 (disconnected)
# ifup eth0
Active connection state: activated
Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/5
#
The current network settings are displayed using the ifconfig
command.
# ifconfig -a
eth0 Link encap:Ethernet HWaddr 52:54:00:91:6A:B3
inet addr:192.168.122.89 Bcast:192.168.122.255 Mask:255.255.255.0
inet6 addr: fe80::5054:ff:fe91:6ab3/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:13548 errors:0 dropped:0 overruns:0 frame:0
TX packets:6144 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2871500 (2.7 MiB) TX bytes:824754 (805.4 KiB)
Interrupt:11 Base address:0xe000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:48 errors:0 dropped:0 overruns:0 frame:0
TX packets:48 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:3230 (3.1 KiB) TX bytes:3230 (3.1 KiB)
#
system-config-network-tui
The system-config-network-tui
and system-config-network
commands start a text-based network configuration tool.
Navigate using the “tab”, “arrow” and “return” keys. The “Device configuration” option gives a list of network devices.
Selecting the device allows you to edit the adapter’s network configuration, which is saved to the “/etc/sysconfig/network-scripts/ifcfg-eth0” file.
The “DNS configuration” option on the first screen allows you to modify the configuration in the “/etc/sysconfig/network” and “/etc/resolv.conf” files.
The network configuration can also be initiated using the setup
command.
Network Connections
The “Network Connections” dialog is available from the menu (System > Preferences > Network Connections) at the console.
Highlighting the device and clicking the “Edit” button allows you to view or alter the configuration of a device.
For more information see:
Leave a comment