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
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
On Select A Device screen select first network card (eth0) and press ENTER
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
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
Select Save by pressing TAB key and press ENTER
Select Save & Quit by pressing TAB key and press ENTER
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
Use ifdown command to deactivate and ifup to activate.
Check again with ifconfig command. The configuration of the network card should reflect the new configuration.
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.
You can also invoke this tool form terminal. Run following command
#nm-connection-editor
This command may return with following error
This error triggered when NetwrokManager service is disabled.
Start NetworkManager service
Now try to invoke network manager again. From open window select eth0 and click on edit
Click on IPv4 tab. For dynamic configuration select DHCP from method drop down
For static configuration select Manual from drop down and click on Add button, fill IP configuration and click on apply button
We are back on Network Connection window click on close
Reactivate network adaptor so new configuration can take effect.
You can also invoke Network Manager directly from panel .Right click on Network icon and click on edit connection
To deactivate do left click on network icon and click on Disconnect
To activate do left click on network icon and click on network adaptor
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