LINUX

This tutorial explains how to configure IP address in Linux step by step with examples.

This tutorial is prepared for Centos / RHEL 6 or lower version. A lot of things have been changed in RHEL 7. Some features explained in this tutorial will not work in RHEL 7.0 or higher. If you have RHEL 7 or higher version of RHEL /Centos, please use this tutorial.

How to assign IP address in Redhat Linux 7

The most essential part of networking is assigning IP address, default gateway and DNS server IP address. An IP address is the unique identity of a computer in network. Without it computer will not be able to communicate with other computers in network. Before we learn how to assign an IP address, let’s learn how to view the current IP configuration.

In RHEL you can assign these parameters in two ways.

  • Static configuration
  • Dynamic configuration

Static configuration

In static configuration you have to assign all these parameters manually. Static configuration does not change automatically. Static configuration generally used with servers or network resources like printer, router etc. Static configuration uses set parameters for the configuration, which is known by the system and the network.

Dynamic configuration

Dynamic configurations are handled by DHCP server. In dynamic configuration DHCP service on the network provides all these parameters to a system when it joins the network.

Dynamic configuration generally used with workstations. Dynamic configuration configures network parameters on the boot.

Red Hat provides two tools to configure the network device.

  • Network configuration tool
  • Network manager

Network configuration tool

This is a command line network configuration tool. Use this tool to configure IP address on console. This tool can be invoked by running system-config-network command.

#system-config-network

system-config-network

Key control

  • TAB Key :- To switch between options
  • Enter /Space :- Select the highlighted options

Select Device Configuration if other option is selected press TAB key until device configuration is selected and press ENTER

device-configuration

On Select A Device screen select first network card (eth0) and press ENTER

select-a-device

Now we are on Network configuration screen. As we mentions above IP configuration can be set in two ways static or dynamic.

To set IP configuration dynamically Select DHCP

network-configration-dhcp

To use static IP configuration press TAB key to highlight DHCP option and press SPACEBAR to deselect it. Fill necessary parameters and select Ok by pressing TAB key. Once OK is highlighted press ENTER

network-configration-static

Select Save by pressing TAB key and press ENTER

select-a-device-back

Select Save & Quit by pressing TAB key and press ENTER

device-configuration-back

To put the configuration customized with this tool into effect we need to reactivate the associated device. Until we reactivate associated device it would run with old configuration. You can check it with ifconfig command

dynamic-ip

Use ifdown command to deactivate and ifup to activate.

ifup-ifdown

Check again with ifconfig command. The configuration of the network card should reflect the new configuration.

static-ip

Network manager tool

This is a GUI tool to configure IP address. It is also default network management tool for RHEL6. Use this tool to configure IP address on GUI. To invoke this tool click System | Preferences | Network Connections.

system-preferences-network-connections

You can also invoke this tool form terminal. Run following command

#nm-connection-editor

nm-connection-editor

This command may return with following error

nm-connection-editor-error

This error triggered when NetwrokManager service is disabled.

nm-connection-service-stoped

Start NetworkManager service

nm-connection-service-start

Now try to invoke network manager again. From open window select eth0 and click on edit

nm-editor-running

Click on IPv4 tab. For dynamic configuration select DHCP from method drop down

nm-editor-iv4-tab

For static configuration select Manual from drop down and click on Add button, fill IP configuration and click on apply button

nm-editor-manual-ip

We are back on Network Connection window click on close

nm-editor-running

Reactivate network adaptor so new configuration can take effect.

ifup-ifdown-gui

You can also invoke Network Manager directly from panel .Right click on Network icon and click on edit connection

nm-connection-connect

To deactivate do left click on network icon and click on Disconnect

network-connection-disconnect

To activate do left click on network icon and click on network adaptor

nm-connection-connect

Both tools are available during the exam. Do practice with both.