Thursday, September 3, 2015

How to assign IP address in Linux

Every computer requires IP configuration in network.
Four configuration parameters are required.
  • IP Address
  • Netmask
  • Default Gateway or Router
  • DNS Server(s)
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.


source : http://computernetworkingnotes.com/network-administration/how-to-assign-ip-address-in-linux.html

No comments:

Post a Comment