IP Address Management on Ubuntu shell ubuntu

Nowadays, everything takes place on the Internet. It is not wrong to say that “the Internet has become the basic requirement for our lives”. And the Internet is a network of networks that are interconnected. To surf the Internet, you should know the basics of a network and how to connect your local network to the Internet. The first and most important thing when connecting to the Internet is the IP address. The IP address is your identity on the Internet, just like your phone number, social security number, etc. To browse the Internet, you need an IP address. If the network is down or not working, the user should be able to find the cause of the problem. To identify the problem, one should be familiar with the basics of networking. The Linux Network Stack provides great flexibility in managing a network through the graphical user interface and the command line. In this tutorial, we will see how to manage, debug, and fix a network problem using the Linux GUI interface and the command-line interface.

How to statically assign an IP address

When you connect to the network, the first thing your computer receives is the IP address from the network router. There are two ways to assign an IP address. One is static and the other is dynamic. In this section, we will show you how to assign the IP address statically through the graphical user interface and through the command line.

Step 1: First, open the terminal. Once the terminal is open, you will see a screen like this:

<img alt="Open the Terminal" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/04/echo/word-image-3.png624eb43503ac7.jpg" data-ez ezimgfmt="rs rscb10 src ng ngcb10 srcset" height="468" loading="lazy" src="data:image/svg xml,” width=”725″>

Step 2: Enter “ip addr show” command to see the available network adapter whom you want to change the IP address and press execute.

ip addr show

In this tutorial, we are focusing on “eth0”. The output will be like this:

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/04/echo/word-image-4.png624eb43515547.jpg" data-ez ezimgfmt="rs rscb10 src ng ngcb10 srcset" height="221" loading="lazy" src="data:image/svg xml,” width=”738″>
Get network adapter

Step 3: Use “ip addr add X.X.X.X/24 dev eth0” command to change the IP address. In our example X.X.X.X address is 10.0.2.16.

<img alt="Add IP address to network adapter" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/04/echo/word-image-5.png624eb43541366.jpg" data-ez ezimgfmt="rs rscb10 src ng ngcb10 srcset" height="25" loading="lazy" src="data:image/svg xml,” width=”472″>

Step 4: Execute the above command and IP address has been changed successfully. You can verify by using “ip addr show” command.

<img alt="Show IP address" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/04/echo/word-image-6.png624eb4357362f.jpg" data-ez ezimgfmt="rs rscb10 src ng ngcb10 srcset" height="41" loading="lazy" src="data:image/svg xml,” width=”487″>

How to change a static IP address

To change the static IP address assigned to our machine, perform the following steps:

Step 1: First of all, open Terminal. Enter “ip addr show” command to see the available network adapter whom you want to change the IP address and press execute.Advertisement

ip addr show

In this tutorial, we are focusing on “eth0”. The output will be like this:

<img alt="Show IP address" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/04/echo/word-image-11.png624eb435a2584.jpg" data-ez ezimgfmt="rs rscb10 src ng ngcb10 srcset" height="221" loading="lazy" src="data:image/svg xml,” width=”738″>

Step 2: Use “sudo ifconfig eth0 X.X.X.X netmask 255.255.255.0” command to change the IP address. In our example X.X.X.X address is 10.0.2.17.

<img alt="Change static IP address" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/04/echo/word-image-12.png624eb435c917c.jpg" data-ez ezimgfmt="rs rscb10 src ng ngcb10 srcset" height="27" loading="lazy" src="data:image/svg xml,” width=”585″>

Step 3: Execute the above command and the IP address has been changed successfully. You can verify by using “ip addr show” command.

How to set which DNS Server shall be used to resolve domain names

The DNS server is one of the most important components of a network. The task of the DNS server is to translate the domain name or URL into the IP address used by the network to communicate with the server. If the DNS server is not configured properly or stops working, the user will not be able to browse the Internet. To change the IP address of the DNS, follow the steps below:

Step 1: First of all, open Terminal. Back up the existing network configuration file before changing the DNS server. To do this run this command:

sudo cp /etc/resolv.conf /etc/resolv.orig

<img alt="Backup resolv.conf file" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/04/echo/word-image-17.png624eb4360c74d.jpg" data-ez ezimgfmt="rs rscb10 src ng ngcb10 srcset" height="24" loading="lazy" src="data:image/svg xml,” width=”506″>

Step 2: Enter command:

sudo rm /etc/resolv.conf

To remove the resolv.conf file.

<img alt="Delete old resolv.conf file" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/04/echo/word-image-18.png624eb436336d9.jpg" data-ez ezimgfmt="rs rscb10 src ng ngcb10 srcset" height="18" loading="lazy" src="data:image/svg xml,” width=”336″>

Step 3: Now enter command:

sudo bash

to gain the root privileges.

<img alt="Get root priveliges" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/04/echo/word-image-19.png624eb4365d5e0.jpg" data-ez ezimgfmt="rs rscb10 src ng ngcb10 srcset" height="19" loading="lazy" src="data:image/svg xml,” width=”231″>

Step 4: Finally, enter command:

sudo echo "nameserver 8.8.8.8" > /etc/resolv.conf

In this example 8.8.8.8 is the address of DNS server.

<img alt="Set new nameserver address" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/04/echo/word-image-20.png624eb4367f883.jpg" data-ez ezimgfmt="rs rscb10 src ng ngcb10 srcset" height="25" loading="lazy" src="data:image/svg xml,” width=”563″>

After the execution of above commands, the address of DNS server has been updated successfully. To check run this command “cat /etc/resolv.conf”.

<img alt="Nameserver ahs been set" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/04/echo/word-image-21.png624eb436a5ad0.jpg" data-ez ezimgfmt="rs rscb10 src ng ngcb10 srcset" height="38" loading="lazy" src="data:image/svg xml,” width=”312″>

How to set the Gateway IP

The gateway, also known as the default gateway, is a very important component in a network. It is usually a border router and is used when the computer wants to send information over the Internet to another network. To change the IP address of the gateway, follow these steps:

Step 1: Open Terminal. Enter the command:

sudo route add default gw X.X.X.X eth0

In this example 10.0.1.1 is the address of the gateway.

<img alt="Set gateway IP address" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/04/echo/word-image-26.png" data-ez ezimgfmt="rs rscb10 src ng ngcb10 srcset" height="23" loading="lazy" src="data:image/svg xml,” width=”607″>

After the execution of the above commands, the address of the gateway has been updated successfully.