Ubuntu IP address management

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:

Open the Terminal

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:

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.

Add IP address to network adapter

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

Show IP address

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.

ip addr show

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

Show IP address

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.

Change static IP address

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

Backup resolv.conf file

Step 2: Enter command:

sudo rm /etc/resolv.conf

To remove the resolv.conf file.

Delete old resolv.conf file

Step 3: Now enter command:

sudo bash

to gain the root privileges.

Get root priveliges

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.

Set new nameserver address

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

Nameserver ahs been set

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.

Set gateway IP address

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

IP Address Management on Ubuntu