Setup network in centos 6 :
By default Centos 6 new installation will not have network access , which means you need to configure ip address to the network interfaces by yourself.
In this article we can see how to setup network in centos 6 , i.e. assigning ipaddress in static and in DHCP mode .
» DHCP mode :
Assigning ip address in DHCP mode
Step 1 » Check the network interface name by typing below command
[root@leela ~]# ip a
1: lo: mtu 16436 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: p4p1: mtu 1500 qdisc mq state UP qlen 1000
link/ether 00:22:19:09:4d:3c brd ff:ff:ff:ff:ff:ff
Here “lo” is the loopback interface and “p4p1” is the network interface that you need to configure .
Step 2 » you can see the file named ifcfg-p4p1 ( Interface name ) in the location “/etc/sysconfig/network-scripts/” , open the file and you can see the lines as below
DEVICE="p4p1" HWADDR="00:22:19:09:4D:3C" NM_CONTROLLED="yes" ONBOOT="no"
Just modify the lines like this
DEVICE="p4p1" HWADDR="00:22:19:09:4D:3C" NM_CONTROLLED="yes" ONBOOT="yes" # Interface enabled BOOTPROTO="dhcp" #Assigning IP from DHCP
Step 3 » Start the network service and you can see the status as below .
[root@leela ~]# service network start
Bringing up loopback interface: [ OK ]
Bringing up interface p4p1:
Determining IP information for p4p1... done. [ OK ]
Step 4 » Now you can see the ip address “192.168.1.12” assigned to the interface p4p1 using dhcp .
[root@leela ~]# ip a
1: lo: mtu 16436 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: p4p1: mtu 1500 qdisc mq state UP qlen 1000
link/ether 00:22:19:09:4d:3c brd ff:ff:ff:ff:ff:ff
inet 192.168.1.12/26 brd 172.27.6.63 scope global p4p1
inet6 fe80::222:19ff:fe09:4b3c/64 scope link
valid_lft forever preferred_lft forever
» Static mode :
Assigning ip address in Static mode
Step 1 » Check the network interface name by typing below command
[root@leela ~]# ip a
1: lo: mtu 16436 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: p4p1: mtu 1500 qdisc mq state UP qlen 1000
link/ether 00:22:19:09:4d:3c brd ff:ff:ff:ff:ff:ff
Here “lo” is the loopback interface and “p4p1” is the network interface that you need to configure .
Step 2 » you can see the file named ifcfg-p4p1 ( Interface name ) in the location “/etc/sysconfig/network-scripts/” , open the file and you can see the lines as below
DEVICE="p4p1" HWADDR="00:22:19:09:4D:3C" NM_CONTROLLED="yes" ONBOOT="no"
Just modify the lines like this
DEVICE="p4p1" HWADDR="00:22:19:09:4D:3C" NM_CONTROLLED="yes" ONBOOT="yes" # Interface enabled BOOTPROTO="static" #Assigning in static mode IPADDR=192.168.1.11 #IP address NETMASK=255.255.255.0 # Subnet Mask GATEWAY=192.168.1.1 # Default Gateway DNS1=8.8.8.8 #Primary DNS DNS2=4.2.2.2 #Secondary DNS
Step 3 » Start the network service and you can see the status as below .
[root@leela ~]# service network start
Bringing up loopback interface: [ OK ]
Bringing up interface p4p1: [ OK ]
Step 4 » Now you see the ip address “192.168.1.12” assigned to the interface p4p1 .
[root@leela ~]# ip a
1: lo: mtu 16436 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: p4p1: mtu 1500 qdisc mq state UP qlen 1000
link/ether 00:22:19:09:4d:3c brd ff:ff:ff:ff:ff:ff
inet 192.168.1.12/26 brd 172.27.6.63 scope global p4p1
inet6 fe80::222:19ff:fe09:4b3c/64 scope link
valid_lft forever preferred_lft forever
Also see
I can’t edit “/etc/resolve.conf“ because when I restart computer my changes losted. This file has comment: “Generated by NetworkManager”. Where’s NetworkManager? I has CentOS 6.3
if it is static ip .. Add the below line in this file /etc/sysconfig/network-scripts/ifcfg-*
DNS1=192.168.1.1 (primary dns )
DNS2=192.168.1.2 ( sec dns )
Yes;
You can following by me
vim /etc/sysconfig/network-scripts/ifcfg-eth0
dns1=ip primary
domain=name domain
it’s ok
Thank you )
I can’t edit “/etc/resolve.conf“ because when I restart computer my changes losted. This file has comment: “Generated by NetworkManager”. Where’s NetworkManager? I has CentOS 6.3
if it is static ip .. Add the below line in this file /etc/sysconfig/network-scripts/ifcfg-*
DNS1=192.168.1.1 (primary dns )
DNS2=192.168.1.2 ( sec dns )
Yes;
You can following by me
vim /etc/sysconfig/network-scripts/ifcfg-eth0
dns1=ip primary
domain=name domain
it’s ok
Thank you )
# service NetworkManager stop
# service manager off
vi /etc/sysconfig/network-scripts/ifcfg-ethx(?)
then either :
1: comment out: # “NM_CONTROLLED”=yes
2: delete the line
3: Change the value to no …. # “NM_CONTROLLED=no”
Thank you for providing this very useful information!
Thank you for providing this very useful information!
Thanks very helpfull!!
Thanks very helpfull!!
Thanks for the tip mtrfkr! much appreciated
Thanks for the tip mtrfkr! much appreciated
i don’t understand why linux doesn’t come with network already configured like windows
Windows doesn’t come with the network already configured. That is impossible.
Most linux distros configure it automatically on install but sometimes, like moving a VM image, requires a little
Furthermore, a server has no need for GUI crap so you have to config on the command line.
smh
i don’t understand why linux doesn’t come with network already configured like windows
Windows doesn’t come with the network already configured. That is impossible.
Most linux distros configure it automatically on install but sometimes, like moving a VM image, requires a little
Furthermore, a server has no need for GUI crap so you have to config on the command line.
smh
Thanks. I had a clean install with no network/internet.
I edited /etc/sysconfig/network-scripts/ctfg-eth0
I set ONBOOT=yes
BOOTPROTO=dhcp
service network restart. AND BOOM! I have internet!