Configuring network in Red Hat Linux can be hectic and confusing if you don't know the parameter details which are used. Also from Red Hat 6 the configuration parameter has been changed for network-config. Let me show you out the steps to do the same along with some possible explanation.
The configuration files used for complete network configuration in Red Hat 6 are
/etc/sysconfig/network-scripts/ifcfg-eth0 (can vary as per the NIC present)
/etc/nsswitch.conf
/etc/resolv.conf
Command Line configuration
Here below is a sample file configuration for ifcfg-eth0
# less /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
HWADDR=73:25:N4:2E:8C:46
TYPE=Ethernet
UUID=ca73df13-5553-4631-bfb4-9244f5e29190
ONBOOT=yes
NM_CONTROLLED=no
IPADDR=10.10.20.55
DNS1=8.8.8.8
GATEWAY=10.10.20.100
NETMASK=255.255.255.0
BOOTPROTO=none
USERCTL=no
PEERDNS=yes
- yes — This device should be activated at boot-time.
- no — This device should not be activated at boot-time.
where answer is one of the following:
- yes — NetworkManager is permitted to configure this device.This is the default behavior and can be omitted.
- no — NetworkManager is not permitted to configure this device.
- none — No boot-time protocol should be used.
- bootp — The BOOTP protocol should be used.
- dhcp — The DHCP protocol should be used.
where answer is one of the following:
- yes — Non-root users are allowed to control this device.
- no — Non-root users are not allowed to control this device.
where answer is one of the following:
- yes — Modify /etc/resolv.conf if the DNS directive is set. If using DHCP, then yes is the default.
- no — Do not modify /etc/resolv.conf.
Configure /etc/resolv.conf
In case you have used directive no for the parameter PEERDNS then you will have to manually update your resolv.conf file.
# vi /etc/resolv.conf
nameserver 8.8.8.8
Step 3:
Configure /etc/nsswitch.conf
#hosts: db files nisplus nis dns
hosts: files dns
# service network restart
or
# /etc/init.d/network restart
To check the ip details of your machine
# ifconfig
eth0 Link encap:Ethernet HWaddr 73:25:N4:2E:8C:46
inet addr:10.10.20.55 Bcast:10.10.20.255 Mask:255.255.255.0
inet6 addr: fe20::7a35:c4gf:fe2e:8c46/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:642049 errors:0 dropped:0 overruns:0 frame:0
TX packets:28185 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:74176258 (70.7 MiB) TX bytes:6418581 (6.1 MiB)
GUI configuration
GUI configuration can be done either on command line as well as on the GNOME or KDE desktop.
Make sure the following package is installed
# rpm -qa | grep system-config-network
system-config-network-tui-1.6.0.el6.2-1.el6.noarch
# system-config-network
Follow the screenshots (Click on the image for clear view)
Hit Enter on "Device Configuration"
Select the device and hit Enter
Fill up the required details as shown below and click on OK
Once you click on OK you will reach on the first page of action. Select DNS Configuration and hit enter
Fill up the required details as shown below and hit Enter
Once you have filled up all detail move the cursor to Save and Quit and Hit Enter
Restart your network to make the change affect
# service network restart
or
# /etc/init.d/network restart