How to configure static IP on Ubuntu?
Overview
This is a step-by-step tutorial on how to configure a static IP address on an Ubuntu server using netplan and a desktop computer with NetworkManager. For servers, a static IP address is advised since it is more reliable than a dynamic IP address assigned by a DHCP server.
Some service providers may provide two separate customers the same IP address due to a lack of IP addresses or to cut costs. In this case, the customer might face some connection issues. While static IP numbers are user-specific, they do not result in the same issues, but you should still be cautious because your IP address might be used inappropriately in a number of ways.
All recent Ubuntu releases, including the most current are compatible with this guide. Both the GUI and command line methods for setting a static IP address that Ubuntu provides are discussed here.
Prerequisites
There are certain prerequisites that need to be met before you begin:
An ubuntu system or server
Root privilege or access via sudo command
Get Started
Step-1: Accessing the .yaml file
Type the following command to check the name of your system network interface:
Type the following command to go to the netplan directory:
Type the following command to list the files in the netplan directory:
Step-2: Changing the network configuration in .yaml file
Type the following command to open the configuration file, replace the file name with your .yaml file:
Change the following configurations in the file.
After making the modifications shown above, press ctrl+x then Y and press enter to save the changes done.
Apply the changes using the following command:
Type the following command to verify the changes and network configuration.
Conclusion
Now you can access your Ubuntu server using the static IP you have set in this process. You can also set up multiple IPs using this process.
Last updated