Skip to main content

How to setup network in centos 6

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

Just modify the lines like this

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

Just modify the lines like this

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

  • Pingback: How to install squid proxy on centos 6()

  • Pingback: Installing and configuring samba on centos 6()

  • Pingback: Installing Apache2 , Mysql server and PHP on Centos 6 (LAMP)()

  • Алексей Вахтин

    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

    • krizna

      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 )

    • phanith

      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 )

    • phanith

      Yes;
      You can following by me
      vim /etc/sysconfig/network-scripts/ifcfg-eth0
      dns1=ip primary
      domain=name domain
      it’s ok

      • Алексей Вахтин

        Thank you )

  • Pingback: How to install dns server in centos 6()

  • Kenny

    Thank you for providing this very useful information!

  • Kenny

    Thank you for providing this very useful information!

  • Pingback: Installing CentOS or RHEL 6.4 on VirtualBox : Linux Movies()

  • Geopelia

    Thanks very helpfull!!

  • Geopelia

    Thanks very helpfull!!

  • Lou Picardo

    Thanks for the tip mtrfkr! much appreciated

  • Lou Picardo

    Thanks for the tip mtrfkr! much appreciated

  • Pingback: Install and Configure Squid Proxy Server on CentOS 6 | CHAULV8X | HIGH QUALITY WEB DESIGN SERVICES()

  • Pingback: HOW TO – clonare macchina Centos e risolvere i problemi di rete | blog infocube | sviluppo applicazioni web()

  • Pingback: How to install squid proxy on centos 6 | স্বাধীনতা()

  • wiliam

    i don’t understand why linux doesn’t come with network already configured like windows

    • Windows r Amatuers

      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

  • wiliam

    i don’t understand why linux doesn’t come with network already configured like windows

    • Windows r Amatuers

      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

  • La gran José macho

    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!