In this tutorial we will learn step by step how to configure IP address in linux . There are different ways in linux to configure IP address. We will show how to configure IP address in linux in different ways. We will use GUI tool nmtui text bases user interface network manager tool
What is IP address?
- An IP address is a set of 4 numbers assigned to each device/system on a computer network.
- Every computer requires IP address to communicate with others over the LAN or WAN.
- In computer network the IP address is a numerical representation of a host address.
For example, the domain google.co.uk would go to the IP address 184.108.40.206 There are four configuration parameters required for Static IP.
- IP Address
- Subnet mask
- Default Gateway or Router
- DNS Server(s)
There are two ways to configure an IP on a host.
- Static Configuration
- Dynamic Configuration
Static IP ConfigurationYou have to assign all these parameters manually.
The IP address will not change automatically. We assign static IP addresses to servers or network resources like printer, router etc. Dynamic IP Configuration Dynamic configurations are handled by DHCP server which assigns IP address automatically. DHCP service on the network provides all these parameters to a system when it joins the network.
DHCP uses DORA process for IP.
DORA Stand for;
How to Configure IP in Linux
CentOS/Red Hat provides two tools to configure the network device/interface.
- Network Configuration Tool
- Network Manager Tool
Network Configuration Tool This is a command line network configuration tool. This tool is used to configure IP address on terminal. Type below command in terminal and hit enter to invoke tool nmtui —network manager text user interface (you can run this command as root user) see below image;
You will see the network configuration dialog box if you want to use DHCP then leave value Automatic highlighted in below screenshot; For static IP you have to select the option Manual and enter the IP manually By the help of navigation keys goto option ok to save the edit connection settings. Network Manager Tool This is a GUI tool to configure IP address. It is also default network management tool for RHEL. This tool is used to configure IP address on GUI. To invoke this tool click Goto the options – Applications>System Tools> Settings. Click on IPV4 option by default it is Automatic for static you need to select Manual option. After selecting manual option you need to set IP address, Netmask and Gateway. DNS IP as per your requirement. Click Apply button to save the settings. Another Method: Last but not least if you are using Pure CLI mode then there is another way to configure IP through configuration file. The path to the access configuration file is /etc/sysconfig/network-scripts/ifcfg-enp0s3. For configuration you need to edit the configuration file Vim tool (vi) is use for editing vi /etc/sysconfig/network-scripts/ifcfg-enp0s3. You need to change and add some parameters for Static IP configuration, by default as I said that DHCP use by interface; Some Changes are; BOOTPROTO=”static” NM_CONTROLLED=”no” ONBOOT=”yes” Add Parameters are; IPADDR=192.168.1.100 NETMASK=255.255.255.0 After editing press first Esc key to switch to command mode and type :wq to save changes and exit. If you are not familiar with vi editor please visit our tutorial working with vi editor part1 and working with vi editor part2 Now start/restart the service of network by using systemctl restart network. Check your interface get the IP by using ifconfig command. Yes interface get the IP which is 192.168.1.100
Congratulations we have learn how to configure IP in linux bravo
In this tutorial we have learnt step by step how to configure IP address in linux using GUI tool nmtui text based user interface network manager tool
I hope you enjoyed tutorial. See you again in next tutorial. Please let us know if there are any mistakes in tutorial suggestions are always welcome… Thanks