Rhel/centos 6 does not configure network interfaces on default installation. Also, it's configured to use NetworkManager. To enable networking interface and disable NetworkManager please follow instructions below.
The/etc/sysconfig/network-scripts/ifcfg-eth0 content looks as follows on default installation.
Device= "Eth0″
HWADDR=SPECIFC MAC Address
Nm_controlled= "Yes"
Onboot= "No
For DHCP, configure the interface as follows.
Device= "Eth0″
HWADDR=SPECIFC MAC Address
Nm_controlled= "No"
onboot= "Yes"
Bootproto= "DHCP"
Restart the network after configuration.
/etc/init.d/network restart
Or
Service Network restart
For Static IP, configure it as follows
Device= "Eth0″
HWADDR=SPECIFC MAC Address
Nm_controlled= "No"
onboot= "Yes"
bootproto= "Static"
Ipaddr=ip address here.
Netmask=netmask here.
Change The/etc/sysconfig/network to the GATEWAY.
Networking=yes
Hostname=www.linuxbyanish.com
Gateway=gateway address here.
Restart the network after configuration.
/etc/init.d/network restart
To see current IP address information for eth0:-
# IP Addr Show eth0
To see routing information:
# IP Route Show
Ifconfig Command Example
Simply Type the ifconfig command as follows to display eth0 IP information:
# ifconfig Eth0
Eth0 Link encap:ethernet HWaddr b8:ac:6f:65:31:e5
inet addr:192.168.1.100 bcast:192.168.1.255 mask:255.255.255.0
Inet6 ADDR:FE80::BAAC:6FFF:FE65:31E5/64 Scope:link
Up broadcast RUNNING multicast mtu:1500 metric:1
RX packets:308560 errors:0 dropped:0 overruns:0 frame:0
TX packets:217836 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:431112624 (431.1 MB) TX bytes:20994801 (20.9 MB)
Interrupt:17
Type the following command to display a IP and its netmask:
# ifconfig Eth0 | grep ' inet addr: '
Sample outputs:
inet addr:192.168.1.100 bcast:192.168.1.255 mask:255.255.255.0
Rhel/centos 6 (command line) Networking