Knowledgebase

Configure CentOS 6 Network Settings

Overview

This tutorial will walk you through configuring your network configurations on CentOS 6.X. There are three different methods to choose from, depending on what installation type and packages you have installed.

Manual configuration is done by directly modifying the configuration files. You will need to be comfortable with the command-line for this one. However, this will give you the most flexibility and is worth learning.

System Config Network is a command-line tool that presents a very basic graphical interface. This a great tool for those who just want to quickly configure the network and do not require advanced features, like interface bonding (teaming).

And lastly, from a Gnome desktop. This for those trying Linux out and have yet to venture into command-line territory, or have no interest in it at all.

Manual Configuration

This configuration is done by modifying the network configuration directly, using a text editor. This method is typical for servers, and is a more advanced way of doing it.

Set the Hostname

  1. Open the following file into a text editor, like VI or Nano.
    vi /etc/sysconfig/network
  2. Change the hostname value to the fully qualified name of your computer.
    HOSTNAME=slcentos6-01.serverlab.intra
  3. Save your changes and exit the text editor. The new name will be applied after your next reboot.

Set a DHCP Address

  1. Open the configuration file for the first network interface, eth0, into a text editor.
    vi /etc/sysconfig/network-scripts/ifcfg-eth0
  2. Modify the file to look similar to the example below.
    DEVICE=eth0
     TYPE=Ethernet
     ONBOOT=yes
     BOOTPROTO=dhcp
     IPV4_FAILURE_FATAL=yes
     NAME="System eth0"
  3. Save your changes and exit the text editor.
  4. Restart the network service.
    service network restart

Set a Static IP Address

  1. Open the configuration file for the first network interface, eth0, into a text editor.
    vi /etc/sysconfig/network-scripts/ifcfg-eth0
  2. Modfy the configuration file to look similar to the one below. Remember to change the highlighted values to match your environment’s.
    DEVICE=eth0
     TYPE=Ethernet
     ONBOOT=yes
     BOOTPROTO=none
     IPADDR=172.30.0.53
     PREFIX=24
     GATEWAY=172.30.0.1
     IPV4_FAILURE_FATAL=yes
     NAME="System eth0"
  3. Save your changes and exit the text editor.
  4. Restart the network service.
    service network restart

Using the System Config Network Tool

The System Config Network tool is a terminal application that presents a very basic GUI. It can do basic network configurations, such as configuring static or dhcp addresses, setting the DNS server IP addresess, and setting the default gateway.

Install System Config Network

The base CentOS 6 installation includes the tool by default. To install it on a minimal installation, follow these instructions.

  1. Install it from the yum repository.
    yum intall system-config-network
  2. If you have no Internet access, install it from the CentOS DVD. Create a directory in /media called cdrom.
    mkdir -p /media/cdrom
  3. Mount the CentOS DVD to the directory.
    mount /dev/cdrom /media/cdrom
  4. Run yum and target the repository that uses the DVD.
    yum --repodisable=/* --repoenable=c6-media install system-config-network

Configure the Network Settings

  1. Launch the System-Config-Network tool from the terminal.
    system-config-network-tui
  2. Ensure Device Configuration is highlighted, and then press Enter.
  3. Select the network interface you want to configure, and then press Enter.
  4. For Dynamic IP address allocation, ensure the Use DHCP box is checked. Otherwise, for static IP address allocation, enter the static IP address, netmask, default gateway, and DNS server infomation.
  5. Tab to highlight Ok, and then press Enter.
  6. Press tab until Save is highlighted, and then press Enter to save your changes.
  7. Press tab until Save&Exit is highlighted, and then press Enter to save your changes.
  8. To apply your changes, restart your network services.
    service network restart

From a Gnome Desktop

Gnome is the default environment for CentOS 6 Desktop installations. There are plenty of alternative environments that can be installed, but being the default, this one is more widely used.

  1. Click to expand the Sytem menu, expand Preferences, and then click Network Connections.
    CentOS 6 Gnome Desktop
  2. From the list of connections in Network Connections application, select the interface you want to configure.
  3. Click Edit.
    CentOS 6 Network Connections
  4. Click the IPv4 Settings tab.

Set a DHCP Address

  1. From the Method drop-down list, select Automatic (DHCP).
    Editing System eth0
  2. If required by your DHCP server, set a Client ID in the DHCP Client ID input box.
  3. Click Apply to save your changes.

Set a Static IP Address

  1. From the Method drop-down list, select Manual.
  2. Click the Add button, located beside the Addresses table.
  3. Enter an IP address into the Address field.
  4. Enter a subnet mask in the Netmask field.
  5. Enter the gateway address in the Gateway field.
  6. Enter the IP addresses of your DNS servers in the DNS servers input box, separating each entry with a comma.
  7. Enter your search domain suffexes in the Search Domains input box, separating each entry with a comma.
    CentOS Static IP
  8. Click Apply to save your changes.

Conclusion

Following one of the three examples above, you should now have a configured network connection. There are more advanced configurations that can be done, like bonding connections together to increase throughput or add fault tolerance, but those subjects are too advanced for this tutorial.

Was this answer helpful?

 Print this Article

Also Read

cPanel/WHM Locations of Logs

CPANEL LOGS     cPanel Access Log     cPanel Apache Log     cPanel Backup Log...