IP Address Management on Ubuntu (2024)

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 IP address is the first and most important thing when connecting to the Internet. 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. One should be familiar with the basics of networking to identify the problem. 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 and command-line interfaces.

How to statically assign an IP address

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

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

IP Address Management on Ubuntu (1)

Step 2: Enter “ip addr show” command to see the available network adapter which 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:

IP Address Management on Ubuntu (2)

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.

IP Address Management on Ubuntu (3)

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

IP Address Management on Ubuntu (4)

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:

IP Address Management on Ubuntu (5)

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.

IP Address Management on Ubuntu (6)

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 cannot 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

IP Address Management on Ubuntu (7)

Step 2: Enter command:

sudo rm /etc/resolv.conf

To remove the resolv.conf file.

IP Address Management on Ubuntu (8)

Step 3: Now enter command:

sudo bash

to gain the root privileges.

IP Address Management on Ubuntu (9)

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.

IP Address Management on Ubuntu (10)

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

IP Address Management on Ubuntu (11)

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.

IP Address Management on Ubuntu (12)

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

IP Address Management on Ubuntu (2024)
Top Articles
Latest Posts
Article information

Author: Laurine Ryan

Last Updated:

Views: 6122

Rating: 4.7 / 5 (77 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Laurine Ryan

Birthday: 1994-12-23

Address: Suite 751 871 Lissette Throughway, West Kittie, NH 41603

Phone: +2366831109631

Job: Sales Producer

Hobby: Creative writing, Motor sports, Do it yourself, Skateboarding, Coffee roasting, Calligraphy, Stand-up comedy

Introduction: My name is Laurine Ryan, I am a adorable, fair, graceful, spotless, gorgeous, homely, cooperative person who loves writing and wants to share my knowledge and understanding with you.