Configure network in CentOS 6

After the installation of the CentOS 6 settings Internet connection is established automatically, so you can immediately go to work in the browser or downloading the packages from the”Terminal”. However, sometimes it appears before the user task is to change the values of the current connection, create a new or switch to another existing network. In this case, you will need to manually set the appropriate parameters in one of the available methods. Just about them and will be discussed further.

Configured network in CentOS 6

All network parameters, like most of the other settings stored in specific configuration files and are read by the standard services and applications. Just from the content of such files and depends on the work Internet connection. To adjust the necessary values in two different methods — by using additional utilities or independent of content changes in the configuration documents. Below we analyze in detail these two methods and you will only choose the best.

Quick network connection

Before the full analysis methods I would like to mention built-in the ability to quickly connect to a network using the standard utilities ifconfig. This option is useful for those users who want to specify the IP address and subnet mask. All actions are performed literally in a few steps:

  • Run the standard console, for example, through the apps menu or by the key combination Ctrl + Alt + T. In it, mount it and activate ifconfig, and then review existing interfaces to understand what you want to configure.
  • Type the command ifconfig eth0 netmask all values, including the interface name, replace as needed.
  • If you need to disable the connection, use sudo ifconfig eth0 down.
  • This step is done as root, so you must enter the password to grant root access.
  • In case of need receive automatic connection settings, you need to replace the above commands in dhclient eth0.
  • Of course, this option allows just a couple of minutes to establish a new connection, but it is not always possible for such settings to satisfy the needs of users, therefore we suggest to familiarize with the two methods.

    Method 1: NetworkManager TUI

    Application TUI NetworkManager has the likeness of the graphical interface implemented via the”Terminal”. This tool allows you to quickly manage existing networks and create new ones. However, to start this utility must be installed in the system, and then you can proceed to edit the settings.

  • Download the latest version of the program via the official repository by typing sudo yum install NetworkManager-tui.
  • Confirm the superuser account and wait for it to complete downloading.
  • Run TUI NetworkManager by running the command nmtui.
  • The main menu offers a choice of three actions — “Change connection”, “Connect” and “Change host name”. Let’s begin with the first point.
  • In the list look for any connection type and proceed to edit it.
  • At the top there are two fields where you enter the profile name and the MAC address of the device used for networking.
  • Further disclosed details of”Ethernet” and a separate configuration protocols. The filling of each field is held solely by the consideration of the user. Here you can clone the MAC addresses, independent search domains and DNS servers. In addition, you configure additional routing settings.
  • When you create a new connection, first select the type that you need to generate the initial configuration.
  • Then how to manually create a network is no different from tuning an existing one, except that the additionally installed automatic connection and access level.
  • In the list of networks active always marked with a tick and to change it, you need to use the arrows to move to desired item and press Enter.
  • Upon completion of the configuration, restart the network service to update the settings service network restart.
  • The method is more suitable for novice users who have not experienced job in the configuration files. But it has its drawbacks, such as limited functionality. No tool will give a complete list of settings that you can change in the config.

    Method 2: Edit the configuration file

    All the configuration files on operating systems based on Linux kernel are modified using various text editors. Such decisions a lot, so normally the user will choose the best variant itself. However, the choice of software to open config is not as important as the process of settings.

  • Open console and navigate to storage network configurations, by entering cd /etc/sysconfig/network-scripts/.
  • We advise to run the document through the editor nanoby typing sudo nano ifcfg-enp0s3where enp0s3 is the name of the interface to change. If you don’t already have the editor, first install it using sudo yum install nano.
  • In the file you will see the parameters and their values, details on each point we will discuss below. Now is the time to change all the necessary.
  • At the end apply the changes by clicking on Ctrl + O and exit the editor Ctrl + X.
  • Restart the network service service network restartto update the configuration.
  • Now let’s deal with the present parameters and consider two types of configuration — static connection and receive dynamic settings using DHCP. In the file for the first type of centres should have the following values:

    DEVICE=eth0 #the interface Number assigned by the system
    HWADDR=08:00:27:6c:e1:fc #the MAC address of the network device. Does not change unnecessarily
    TYPE=Ethernet #connection Type
    UUID=e2f7b74a-ec49-4672-81cf-ff9c30d8ebdd #connection ID
    ONBOOT=yes #Automatically start the network after loading the operating system
    NM_CONTROLLED=no #Enable or disable control NetworkManager
    BOOTPROTO=none #do Not use DHCP
    IPADDR= #IP address
    NETMASK= #subnet Mask
    GATEWAY= #Gateway
    DNS1= #DNS server
    IPV6INIT=no #Disable IPv6
    USERCTL=no #prevent the user without privileges to manage network interface

    Describe each line we put behind the sign #to the config file means a comment. So you can feel free to copy this material, by changing the desired values and review of the description strings, in the future, not to forget, responsible for each. This content is a standard static connection, and as the dynamic through DHCP, the view is slightly different:

    DEVICE=eth0 #the interface Number assigned by the system
    HWADDR=08:00:27:6c:e1:fc #MAC-address
    TYPE=Ethernet #interface Type
    UUID=e2f7b74a-ec49-4672-81cf-ff9c30d8ebdd #ID interface
    ONBOOT=yes #Enable the interface at boot
    NM_CONTROLLED=no #whether the interface is Controlled by NetworkManager daemon
    BOOTPROTO=dhcp #Use DHCP
    IPV6INIT=no #Disable IPv6
    USERCTL=no #Ban users to control the interface

    As you can see, in the second case, the IP address and subnet mask are obtained automatically, since it involves technology DHCP, the main thing to specify in a configuration file so that all actions were performed successfully. After all the changes in the document don’t forget to save and restart the service network, so all the updates went into effect.

    The Firewall in CentOS

    Another important component of any network connection is the firewall it is the firewall. Thanks to him, there is a filtration of the traffic and ensures security of data transmission. The effect of this firewall depend on the established rules, which are activated by default or configured by each user individually. By default, CentOS Firewall involved is a standard tool for managing the firewall, with a detailed setup guide which you can read in our other article on the following link.

    Read more: the Firewall in CentOS

    Sometimes, users prefer another tool, iptables. In fact, this utility is almost analogous to the Daemon, but with some peculiarities. Therefore, the user has to choose which solution for management of firewall to choose. We recommend you to explore the theme of editing iptables, and then choose the tool that is most appropriate.

    Read more: setting up iptables in CentOS

    Now you are familiar with all phases of network settings in CentOS 6. It remains only to choose one of the two methods, and follow the instructions. It should be noted that the edit of the configuration file should always be done very carefully to prevent mistakes when typing the parameters and values. Even one mistake can lead to refusal of the Internet.


    (Visited 5 times, 1 visits today)