How To Change IP Address on Ubuntu – Step By Step – May 2022

Changing the IP address on your Ubuntu system may be important for a variety of reasons, including port forwarding and running a media server on your network. In the majority of circumstances, your router’s DHCP server allocates IP addresses to your network interface dynamically. 

However, you may simply alter your system’s given IP address with “netplan” or the Ubuntu GUI Network settings. The utility used to manage and configure network settings in Ubuntu is called “netplan”.

The netplan communicates with the kernel via the systemd-networkd and Network Manager daemons, together referred to as renderers. You must choose between the two.

Netplan reads network configurations from “/etc/netplan/*.yaml” files, preserving all network interface configuration settings. If you use the netplan command in the Ubuntu terminal, restarting and changing network settings becomes simple.

Now, we’ll demonstrate how to change IP address on Ubuntu using the terminal and the graphical user interface. Therefore, let us begin!


How to use netplan to modify the IP address on an Ubuntu terminal

To begin, use the “ip” command to list all active network interfaces. The “ip” command is used in the Ubuntu terminal to assign and remove routes, as well as to enable and disable interfaces. By including “link” in the “ip” command, you may view information about the link-layer, the name, and status of an interface, among other things. To learn more about your network interfaces, run the following “ip link” command:

Ubuntu 1

The following steps will open the file “/etc/netplan/*.yaml” in your editor:

ubuntu 2
The “/etc/netplan/*.yaml” file that is opened will include the following information:

ubuntu 3

Now, in the “/etc/netplan/*.yaml” file, add the following code to modify your system’s IP address:

ubuntu 5

  • dhcp4 and dhcp6 are DHCP characteristics for IPv4 and IPv6 respectively.
  • enp0s3 is the network interface name for which the IP address will be changed.
  • addresses contain the network interface’s address sequence.
  • gateway4 holds the IPv4 address of the default gateway.
  • nameservers are a collection of IP addresses assigned to nameservers.

ubuntu 6

To save the modifications we made to the file, use “CTRL+O”:

ubuntu 7

Utilize the following netplan command in your terminal to apply the amended settings:

ubuntu 8

Now, verify whether or not the IP address of the “enpos3” network interface has been changed: As you can see, the Ubuntu system’s IP address has been successfully changed:

ubuntu 9


How to change the IP address on Ubuntu through the Graphical User Interface (GUI)

Yes, you read that correctly! Additionally, Ubuntu’s Graphical User Adapter allows you to alter the IP address of your network interface (GUI). To do so, access the “Settings” programme on your machine by manually searching for it in the Application’s search bar:

ubuntu 10

Select “Network” from the left-side vertical menu. Following that, click the “tool” icon to modify the selected network’s IP address:

ubuntu 11

A popup displaying settings for your wired network connection will appear. Now, pick the “IPv4” tab from the menu, and you’ll notice that your system is configured to use the “Automatic (DHCP)” IPv4 method by default:

ubuntu 12

Select the “Manual” option; then, in the provided boxes, enter the new IP address, Netmask, Gateway, and DNS-related information. Finally, click the “Apply” button as follows:

ubuntu 13

Completed! You may verify that the information is up to date by selecting the “details” tab in your network interface:

ubuntu 14


Frequently Asked Questions

How to assign a static IP address in Ubuntu through the command line :

  • Obtain the network interface’s name and default gateway.
  • Identify the location of the Netplan configuration.
  • Edit the Netplan setup to add a static IP address.

 


  • To configure a static IP address on an Ubuntu server, you must locate and alter a network configuration file named netplan.
  • To assign the static IP address 192.168.1.1 to your network interface enp0s3.
  • Once ready, run the following commands to implement the updated Netplan configuration changes: $ sudo apply netplan

 



Conclusion

You can change your IP address on Ubuntu for port forwarding or for running a media server. The Ubuntu system’s network management tool is called “netplan”. It has the ability to set up and manage networks.

The “netplan” programme was used in this article to explain how to modify the IP address on Ubuntu. The Ubuntu GUI is used to change the IP address, as well, according to the guide.