Setting a Static IP in Ubuntu – Linux IP Address Tutorial
In most network configurations, the router DHCP server assigns the IP address dynamically by default. If you want to ensure that your system IP stays the same every time, you can force it to use a static IP.
That's what we will learn in this article. We will explore two ways to set a static IP in Ubuntu.
Static IP addresses find their use in the following situations:
- Configuring port forwarding.
- Configuring your system as a server such as an FTP server, web server, or a media server.
To follow this tutorial you will need the following:
- Ubuntu installation, preferably with a GUI.
- sudo rights as we will be modifying system configuration files.
How to Set a Static IP Using the Command Line
In this section, we will explore all the steps in detail needed to configure a static IP.
Step 1: Launch the terminal
You can launch the terminal using the shortcut Ctrl+ Shift+t .
Step 2: Note information about the current network
We will need our current network details such as the current assigned IP, subnet mask, and the network adapter name so that we can apply the necessary changes in the configurations.
Use the command below to find details of the available adapters and the respective IP information.
The output will look something like this:
For my network, the current adapter is eth0 . It could be different for your system
- Note the current network adapter name
As my current adapter is eth0 , the below details are relevant.
It is worth noting that the current IP 172.23.199.129 is dynamically assigned. It has 20 bits reserved for the netmask. The broadcast address is 172.23.207.255 .
- Note the subnet
We can find the subnet mask details using the command below:
Select the output against your adapter and read it carefully.
Based on the class and subnet mask, the usable host IP range for my network is: 172.23.192.1 - 172.23.207.254 .
Subnetting is a vast topic. For more info on subnetting and your usable IP ranges, check out this article .
Step 3: Make configuration changes
Netplan is the default network management tool for the latest Ubuntu versions. Configuration files for Netplan are written using YAML and end with the extension .yaml .
Note: Be careful about spaces in the configuration file as they are part of the syntax. Without proper indentation, the file won't be read properly.
- Go to the netplan directory located at /etc/netplan .
ls into the /etc/netplan directory.
If you do not see any files, you can create one. The name could be anything, but by convention, it should start with a number like 01- and end with .yaml . The number sets the priority if you have more than one configuration file.
I'll create a file named 01-network-manager-all.yaml .
Let's add these lines to the file. We'll build the file step by step.
The top-level node in a Netplan configuration file is a network: mapping that contains version: 2 (means that it is using network definition version 2).
Next, we'll add a renderer, that controls the overall network. The renderer is systemd-networkd by default, but we'll set it to NetworkManager .
Now, our file looks like this:
Next, we'll add ethernets and refer to the network adapter name we looked for earlier in step#2. Other device types supported are modems: , wifis: , or bridges: .
As we are setting a static IP and we do not want to dynamically assign an IP to this network adapter, we'll set dhcp4 to no .
Now we'll specify the specific static IP we noted in step #2 depending on our subnet and the usable IP range. It was 172.23.207.254 .
Next, we'll specify the gateway, which is the router or network device that assigns the IP addresses. Mine is on 192.168.1.1 .
Next, we'll define nameservers . This is where you define a DNS server or a second DNS server. Here the first value is 22.214.171.124 which is Google's primary DNS server and the second value is 126.96.36.199 which is Google's secondary DNS server. These values can vary depending on your requirements.
Step 4: Apply and test the changes
We can test the changes first before permanently applying them using this command:
If there are no errors, it will ask if you want to apply these settings.
Now, finally, test the changes with the command ip a and you'll see that the static IP has been applied.
How to Set a Static IP Using the GUI
It is very easy to set a static IP through the Ubuntu GUI/ Desktop. Here are the steps:
- Search for settings .
- Click on either Network or Wi-Fi tab, depending on the interface you would like to modify.
- To open the interface settings, click on the gear icon next to the interface name.
- Select “Manual” in the IPV4 tab and enter your static IP address, Netmask and Gateway.
- Click on the Apply button.
- Verify by using the command ip a
In this article, we covered two methods to set the static IP in Ubuntu. I hope you found the article useful.
What’s your favorite thing you learned from this tutorial? Let me know on Twitter !
You can read my other posts here .
I am a DevOps Consultant and writer at FreeCodeCamp. I aim to provide easy and to-the-point content for Techies!
If you read this far, thank the author to show them you care. Say Thanks
Learn to code for free. freeCodeCamp's open source curriculum has helped more than 40,000 people get jobs as developers. Get started
How to Configure Static IP Address on Ubuntu 22.04 LTS and 22.10
Switching from dynamic IP allocation to static IP addresses is easy on Ubuntu 22.04 "Jammy Jellyfish" and 22.10.
The IP addresses of most devices today are generated by Dynamic Host Configuration Protocol (DHCP) servers. A DHCP server assigns a dynamic IP address to your device when it's connected to a network. Thus, you have the chance to change this IP address from time to time.
On the other hand, a static IP refers to a fixed, immutable address, different from dynamic IPs. You can set static IP settings for Ubuntu 22.04 LTS and 22.10 in three different ways. Here's how to get started.
Understanding IP Configuration in Ubuntu
Ubuntu's progression in network management has made configuring settings like the static IP more user-friendly. The feature to set a static IP in Ubuntu 22.04, in particular, has advantages in terms of network efficiency and stability.
Unlike dynamic IPs, which might vary over sessions, a static IP in Ubuntu remains consistent. This is especially advantageous for servers where consistent address recognition is paramount. For these servers, static IP configurations can become a necessity.
While the graphical interface offers a more intuitive way to handle IP configurations, using the static IP command line can offer more precision. For users who want granular control over their network configurations, command-line methods are a preferred choice. By mastering this method, users can ensure optimal Ubuntu IP configuration for their needs.
However, the benefits of a static IP in Ubuntu, especially in the 22.04 version, come with responsibilities. Ensuring that these IPs are correctly set up is crucial, as misconfigurations can lead to network vulnerabilities.
So follow the steps below to configure a static IP address on your Ubuntu machine correctly.
Set a Static IP on Ubuntu With the nmcli Command
It's pretty easy to configure Ubuntu 22.04 static IP settings using the nmcli command . nmcli is a text-based utility used to check the status of the wired connections you are using on your device.
With this command, you can access additional networking information such as your connection status, the name of your host device, and general permissions in your network configuration. If you're aiming to set a static IP on an Ubuntu server, this command proves invaluable.
You can get information about your connection with:
The output of this command will be as follows:
Create a static link with the command given below. Then, manually configure the enp0s3 and ipv4 settings with the appropriate parameters in the nmcli command:
If you use the nmcli connection show command again, you can see that the static link has been added.
After this process, add the static connection you created to the DNS IP:
Now use the command below to activate the connection:
If the output displays "connection successfully activated," you've successfully set up a static IP address on your machine.
You can consider using static IP addresses to avoid connection problems caused by dynamic IP addresses. A static IP address allows you to have a fixed identity and location when connected to the internet.
You can verify the static IP you want to assign to your device by running:
Using netplan for Static IP Settings on Ubuntu
Just like nmcli, another command you can use for setting a static IP on Ubuntu is netplan. You can easily make Ubuntu static IP settings using the netplan command in 22.04 LTS and 22.10 versions. To do this, follow the steps below.
First, find out the name of your network interface using:
What you see here is your network interface name. This name may be different on each device.
Now, create a file named 01-netcfg.yaml in the /etc/netplan folder. Edit it with your favorite text editor.
Add the following lines to the file:
As you can see, you have disabled the DHCP IP setting with the dhcp4: no statement. You've then added the IP address and DNS settings assigned by Google.
After saving this file, run the following to apply the changes:
Configure Static IP Settings on Ubuntu Graphically
The graphical network interface in Ubuntu 22.04 is quite useful if you don't want to use the command line. So much so that you can easily set the Ubuntu static IP address using this interface.
To do this, click on the Network icon in the upper right corner of your desktop. Then, select Wired Settings from the drop-down menu. Click on the Gear icon to open the settings window.
Then, switch to the IPv4 tab in the window that opens.
As you can see, DHCP is enabled by default. Change the IPv4 Method to Manual as you want to use a static IP instead of a dynamic one. Next, change your address, netmask, and gateway settings. Finally, modify your DNS setting and click the Apply button.
You must restart this wired connection for all these actions to take effect. To do this, simply toggle the switch next to the network name on and then off.
Why Should You Use Static IP Addresses on Ubuntu?
You've now understood how to configure a static IP in Ubuntu, especially in the "Jammy Jellyfish" 22.04 LTS version and 22.10, using both graphical and command-line methods with nmcli and netplan.
Due to insufficient IP addresses, some service providers may assign the same address to two different users. In this case, connection problems can occur. Using static IP addresses instead does not cause such problems as it is user-specific, but beware as someone can misuse your IP address in several ways.
How to set a static ip address in ubuntu.
When static is the way forward.
What is a static ip address, setting a static ip in ubuntu, set a static ip in ubuntu with the gui, connection convenience, key takeaways.
After gathering your connection name, subnet mask, and default gateway, you can set a static IP address in the terminal using the nmcli command. Or, in the GNOME desktop, open your connection settings and click the + icon, then enter the info for your static IP address there.
Your home network relies on IP addresses to route data between devices, and sometimes on reconnecting to the network a device's address can change. Here's how to give an Ubuntu Linux computer a permanent IP address that survives reboots.
Everything on your network home network, whether it's using a wired connection or Wi-Fi, has an IP address . IP stands for Internet Protocol. An IP address is a sequence of four numbers separated by three dots. Each IP address that is unique within that network.
IP addresses act as numeric labels. Your router uses these labels to send data between the correct devices. Usually, your router assigns IP addresses. It knows which IP addresses are in use and which are free. When a new device connects to the network, it requests an IP address and the router allocates one of the unused IP addresses. This is called DHCP, or dynamic host configuration protocol .
When a device is restarted or powered off and on, it may receive its old IP address once more, or it might be allocated a new IP address. This is normal for DHCP and it doesn't affect the normal running of your network. But if you have a server or some other computer that you need to be able to reach by its IP address, you'll run into problems if its IP address doesn't survive power downs or reboots.
Pinning a specific IP address to a computer is called allocating a static IP address . A static IP address, as its name suggests, isn't dynamic and it doesn't change even if the computer is power-cycled .
Nmcli is the command-line network manager tool , and can be used to change your IP address, configure network devices, and --- relevant to our purposes --- set up a static IP in Ubuntu.
We're demonstrating this technique on Ubuntu 22.04 LTS, but it ought to work on any Linux distribution, including Ubuntu 23.04. The nmcli tool was released in 2004, so it should be present on just about any standard distribution.
Let's take a look at the network connections that already exist on the computer. We're using the connection command with the show argument.
nmcli connection show
This displays some information about each connection. We only have a single connection configured.
The output is wider than the terminal window. This is the information that we're shown.
- Name : Our network connection is called "netplan-enp0s3."
- UUID : The universally unique identifier Linux uses to reference this connection internally.
- Type : This is an ethernet connection.
- Device : This connection is using the "enp0s3" network interface. It's the only network card in this computer.
We can use the ip command to discover the IP address this computer is using.
In the output we can see the "enp0s3" entry, and its current IP address, 192.168.86.117. The "/24" is a shorthand way of saying that this network uses a 255.255.255.0 subnet mask . Take a note of this number, we'll need to use it later.
We need to choose the IP address we're going to set as our static IP address. Obviously, you can't use an IP address that is already in use by another device. One safe way to proceed is to use the current IP address assigned to the Ubuntu system. We know for certain that nothing else is using that IP address.
If we want to use a different IP address, try pinging it. We're going to test whether IP address 192.168.86.128 is in use. If everything else on your network uses DHCP and you get no response to the ping command, it should be safe to use.
Even if another device had previously used that IP address, it'll be given a new IP address when it next boots up. Nothing responds to the ping requests, so we're clear to go ahead and configure 192.168.86.128 as our new static IP.
We also need to know the IP address of your default gateway , which will usually be your broadband router. We can find this using the ip command and the route option, which we can abbreviate to "r."
The entry that starts with "default" is the route to the default gateway. Its IP address is 192.168.86.1. Now we can start to issue commands to set up our static IP address.
The first command is a long one.
sudo nmcli con add con-name "static-ip" ifname enp0s3 type ethernet ip4 192.168.86.128/24 gw4 192.168.86.1
Taken in small chunks, it's not as bad as it looks. We're using sudo . The nmcli arguments are:
- con : Short for "connection."
- add : We're going to add a connection.
- con-name "static-ip" : The name of our new connection will be "static-ip."
- ifname enp0s3 : The connection will use network interface "enp0s3."
- type ethernet : We're creating an ethernet connection.
- ip4 192.168.86.128/24 : The IP address and subnet mask in classless inter-domain routing notation . This is where you need to use the number you took note of earlier.
- gw4 192.168.86.1 : The IP address of the gateway we want this connection to use.
To make our connection a functioning connection, we need to provide a few more details. Our connection exists now, so we're not adding anything, we're modifying settings, so we use the mod argument. The setting we're changing is the IPv4 DNS settings. 188.8.131.52 is the IP address of Google's primary public DNS server , and 184.108.40.206 is Google's fallback DNS server.
Note that there is a "v" in "ipv4." In the previous command the syntax was "ip4" without a "v." The "v" needs to be used when you're modifying settings, but not when adding connections.
nmcli con mod "static-ip" ipv4.dns "220.127.116.11,18.104.22.168"
To make our IP address static, we need to change the method which the IP address obtains its value. The default is "auto" which is the setting for DHCP. We need to set it to "manual."
nmcli con mod "static-ip" ipv4.method manual
And now we can start or "bring up" our new connection.
nmcli con up "static-ip" ifname enp0s3
We didn't get any error messages which is great. Lets use nmcli to look at our connections once more.
nmcli con show
Here's the output:
Our static-ip connection is active and using device "enp0s3." The existing connection "netplan-enp0s3" is no longer associated with a physical network interface because we've pinched "enp0s3" from it.
Click the icons at the far-right end of the system bar to show the system menu, then click on the "Wired Connected" menu option. If you're using a wireless connection, instead click the name of your Wi-Fi network.
The available connections are displayed. A dot indicates which is in use. Click the "Wired Settings" or "Wi-Fi Settings" menu option. The details of the active connection are displayed.
If you followed our previous instructions the new connection will be the active connection. We can see our new "static-ip" connection has the IP address, default gateway, and DNS servers that we set for it.
To create a new connection using the "Settings" application, click the " + " icon on the "Networks" page, above the list of wired connections.
A dialog appears. We need to provide a name for our new static IP connection.
We're calling our new connection "static-2." Click the "IPv4" tab.
Select the "Manual" radio button, and complete the "Address", "Netmask", and "Gateway" fields. Also complete the DNS field, and then click the green "Apply" button. Note the comma between the DNS entries.
Our new connection is listed in the "Wired" connections pane.
You can swap between the available connections by clicking directly on their names.
If you want to modify a connection after you create it, click the cog icon. In this case, we'll enter the settings for the "static-ip" connection.
A dialog box opens. Click on the "IPv4" tab.
Because we set our new IP address to be static, the "Manual" radio button is selected. You could change this back to DHCP by selecting the "Automatic (DHCP)" radio button, and clicking the green "Apply" button.
Using the nmcli command or the GNOME desktop and apps, you can hop between network connections very easily and very quickly.
It's more convenient to have a selection of connection profiles and move between them as you need to, rather than to have one that you keep editing. If something goes horribly wrong with the connection you're editing or adding, you can always fall back on one of the existing connections.
How to Configure Static IP Address on Ubuntu 20.04
Mostly when a user connects to a network through WIFI or eternal cable, the DHCP server automatically picks and assigns IP addresses to the system. Here the downside is that once the lease time of DHCP expires, another IP address is assigned to the system.
Such changes might cause disconnection of the system and due to this it’s recommended to set static IP addresses to the system so that the ip addresses do not change even when the lease time has expired. In this guide, we’ll tell you about how to configure a static IP address on Ubuntu 20.04.
Static IP Configuration on Ubuntu Server
The Ubuntu system uses predictable network interfaces names to identify the interfaces of the network. Firstly, to set up a static IP address we need to identify the name of the interface that we want to configure. For this we will use “ ip_link ”.
This will print out all the available network interfaces such as “ enp0s3 ” that we’ll configure.
Netplan is used as a default network management tool by Ubuntu and its files are written using YAML syntax with extension of “ .yaml ”. In order to configure the interface with Netplan a yaml description is needed to be created and the required configuration files for that particular render tool will be generated by Netplan.
Configuration file of Netplan is stored in “ /etc/netplan ”. Here there might be some YAML files with the names “ 01-netcfg.yaml ”, “ NN_interfaceName.yaml ” or “ 50-cloud-init.yaml ”, but they differ in each system.
Now, we need to disable cloud instances just in case your Ubuntu is provisioned with cloud-init.
This will open the file, in it write the following.
Now, we need to assign an IP address and for this open the configuration file of the YAML file.
This will open the configuration file in which you need to add the following:
Here you need to understand some key points:
- Each YAML file of Netplan is supposed to start with “ network ”.
- Networks contain a minimum two elements.
- Here, the first element is the network configuration format’s version.
- Second element is device type which can be ethernets, VLANS or bridges.
- Renders: Incase ubuntu was installed in server mode, render use networkd as back end.
In this under ethernets you can define various interfaces. We defined “enp0s3” that obtains an IP address from dhcp4. Now, in order to assign “enp0s3” an IP address which is static we will edit the file:
- Set no to dhcp4 which is a DHCP server.
- Give a static IP address using addresses: and provide one or more IPv4 or IPv6.
- Specify gateway
- Set the IP address of nameserver under nameservers .
After this save the file and run the below command in order for the changes to apply.
Now after everything is completed, verify the changes using the command provided below.
That’s all, you’ve successfully provided a static IP address to your Ubuntu server.
The easiest way to assign a static IP address is through Ubuntu Desktop as you do not need any technical knowledge as well as no worry about syntax. All you’ve to do is select Settings and go to the Network or WiFi tab. Select the cog icon next to the interface and go to IPv4 tab and there select manual and provide IP address.
After this select Apply and in order to verify run the command below.
In this you can directly assign a static IP address through Ubuntu Desktop as well as through the command line.
Assigning static IP addresses is beneficial as the IP address won’t change even when the lease has expired. This can be done through various ways. In this guide we showed you how to assign static IP addresses through Ubuntu server as well as through Desktop.
Personally the easiest way is through Desktop as it doesn’t require a lot of technical knowledge and involves just a few steps. Now following this guide you can assign a static IP address to your system.
TUTORIALS ON LINUX, PROGRAMMING & TECHNOLOGY
How to Configure Static IP Address on Ubuntu 22.04
After installing Ubuntu 22.04 the default network interface assigns an IP address using the DHCP server. Also, the wireless network will be active and enable networking over the wifi network.
You can also configure the network interface with static IPv4 addresses. Ubuntu 22.04 uses the Netplan as a network manager.
This tutorial helps you to configure network interfaces on Ubuntu 22.04 Desktop and Ubuntu 22.04 Server editions. The desktop users can use any one of the below methods but the server users that have CLI only access use the second method to edit network interface configuration files.
Method 1: Configuring Static IPv4 Address on Ubuntu 22.04 Desktop
The Ubuntu Desktop editions have a graphical interface for configuring the network interfaces. Follow the below steps to configure a static IP address on Ubuntu 22.04 Desktop system.
- Click the network icon in the upper-right corner.
- Then expand the Wired Connected dropdown.
- Now, click on Wired Setting as shown below image.
- A network settings dialog box will appear.
- Now, click “Network” in left sidebar.
- Under the Wired section, click the Gear icon as showing in below image
- A new Wired dialog box will appear.
- Now, click on “IPv4” tab.
- Set IPv4 Method to Manual
- Input a valid IP address, Netmark and Gateway address
- Set the DNS server (optional)
- Click Apply button to save changes
- All done. Ubuntu Desktop system IP address is now changed.
Method 2: Configuring Static IPv4 Address on Ubuntu 22.04 Server with CLI
Server editions are installed without any graphical interface. In that case, you need to configure the IP address using the command line.
Ubuntu uses the Netplan as a network manager that is responsible for configuring the network interfaces. Follow the below steps:
Add the network configuration in YAML format as below:
In the above configuration:
- eth0 – is the network interface name
- addresses – is used to configure IPv4 address on an interface. Make sure to define CIDR. You can add multiple addresses here
- nameservers – Set the name servers here. 22.214.171.124 and 126.96.36.199 are Google’s name servers
- routes – This is used to set gateway on your system.
In this tutorial, you have learned 2 methods of configuring network interface on Ubuntu 22.04 systems. The first method uses the GUI interface to set up a static IP address. The second method provides you with the instructions to configure the network interface via the command line using Netplan.
You can also configure multiple IP addresses on a single network interface.
Apt configuration file options /etc/apt/apt.conf.
A Step-by-Step Guide to Installing OpenDKIM with Postfix on Ubuntu – Unleash the Power of DKIM!
How to Install and Use Composer on Ubuntu 22.04
**networkctl list** IDX LINK TYPE OPERATIONAL SETUP 1 Io loopback carrier unmanaged 2 eth0 ether routable configured
**route** Destination Gateway Genmask ….. iface default 192.168.178.1 0.0.0.0 …… eth0 192.168.178.0 0.0.0.0 255.255.255.0 …… eth0
**/etc/netplan/000-installer-config.yaml** network: version: 2 renderer: networkd ethernets: eth0: addresses: – 192.168.178.43/24 nameservers: addresses: [188.8.131.52] routes: – to: default via: 192.168.178.1
After this `ip-a` confirms i have ip address 192.168.178.43, but `ping -4 192.168.178.1` says: Destination Host Unreachable
Any ideas on how to change? I only have CLI, no GUI running
Oh man bring back /etc/network/interfaces
If you use the GUI, you need to disable and then enable the connection. Just clicking on ‘Apply’ doesn’t change anything.
I am getting an error: Error in network definition expected mapping (check indentation) network:
Any help would be great!
When I set – to: default via: 192.168.1.1 I get an error : could not find expected ‘-‘ before via and when I add this ‘-‘ before via, then I get : error in network definition: global unicst route must include both ‘to’ and ‘via’ IP.
That’s a nightmarre to configure a simple eth0 using CLI.
I have again verified the configuration file and it works fine for me. Make sure that JSON is properly formatted and any extra or less space may cause syntax issues.
It is warning that gateway4 is depracated and default routes should be used instead.
Thanks, Ken, article is updated accordingly.
gateway4: is no longer allowed as an option in Ubuntu 22.04
routes: – to: default via: 192.168.1.1
Thanks, Passerby, gateway4 works but as its deprecated, I have updated the article to routes.
Leave A Reply Cancel Reply
Save my name, email, and website in this browser for the next time I comment.
Type above and press Enter to search. Press Esc to cancel.
How to Configure Static IP Address on Ubuntu Linux
The post provides instructions on how to configure a static IP address on Ubuntu Linux using Netplan, the default network configuration tool as of Ubuntu 17.10. It details how to disable dynamic IP assignment and set up a static IP address via terminal commands and by manipulating .yaml configuration files. Additionally, it offers a guide on assigning static IP addresses for Ubuntu desktops through the GNOME Network configuration settings.
This post shows students and new users how to configure a static or fixed IP address on Ubuntu Linux. Generally, IP addresses are assigned dynamically, and you probably would not need to assign fixed IP addresses for your computers.
However, in certain situations, you may need to set up static IP addresses on some machines that you don’t want to have random IP addresses. In many environments, static IP addresses are assigned by a router or DHCP servers using reservations. An IP reservation is a process where the same IP addresses are reserved and assigned only to computers with corresponding MAC addresses.
The computer with its MAC address reserved for a particular address will always receive that IP address.
If you’re not using a dedicated system for IP management, configuring an individual system with a unique IP address may be your next option.
Since the release of Ubuntu 17.10, Netplan is now the default network configuration tool to manage network settings replacing the configuration file /etc/network/interfaces used in previous versions.
Netplan currently supports two renderers, NetworkManager and Systemd-network. NetworkManager is mostly used on Desktop machines, while Systemd-network is used on servers without a GUI.
The new interfaces configuration file now lives in the /etc/netplan directory. There are two renderers: NetworkManager and Network .
When you use NetworkManager as the renderer, you will use the NetworkManager GUI to manage the interfaces. Ubuntu uses ‘Predictable Network Interface Names’ that, by default, start with en[letter][number] .
Netplan configuration files are stored in the /etc/netplan directory and have the extension .yaml . You’ll probably find one or two YAML files in this directory.
The network configuration file will differ from setup to setup. Some may be named 01-netcfg.yaml , 50-cloud-init.yaml , etc.
Below is a sample file for a network interface using the network as a renderer using DHCP. The network uses the command line to configure the network interfaces.
You should see a similar DHCP server for servers like the one below:
On Desktops, you may see something like the one below:
How to configure IP address with networkd
To configure a static IP address using the new Netplan tool on the Ubuntu server, you must edit the *.yaml file in the /etc/netplan/ directory.
If your Ubuntu cloud instance is provisioned with cloud-init, you’ll need to disable it before setting a static IP address.
To do so, create the following file by running the commands below:
With the file open, paste the line below and save.
After editing the file above, run the commands below to open the network configuration file for the network interfaces. The device type can be ethernets , bonds , bridges , or VLANs .
Then change the dhcp4 value to no , and configure the static IP address details, including DNS and Gateway addresses, as shown below.
When you’re done editing the file, save it and exit.
You will want to ensure the file meets YAML code indent standards. If not probably indented, you’ll get an error.
Run the commands below to apply your changes.
To validate that your changes are applied, run the commands below to view the IP address configuration details.
It should display similar lines like the one below:
How to setup static IPs on Ubuntu desktop
To set up static IP addresses on Ubuntu desktops, click the network icon in the top menu, then select Wired Connected –> Wired Settings .
This will open the GNOME Network configuration settings. Click on the cog icon.
Then choose Manual for IPv4 Method, and set up the IP, Network, Gateway, and DNS addresses. Click Apply to save your changes.
This show how to configure static IP addresses on Ubuntu systems.
For more about Netplan, visit this site.
This post showed you how to set up static IP addresses on Ubuntu Linux. Please use the comment form below if you find any errors above or have something to add.
I love computers; maybe way too much. What I learned I try to share at geekrewind.com.
You may also like
How to Install AWS CLI on Ubuntu
The ls command in Ubuntu Linux with examples
How to Install netstat on Ubuntu Linux
The cat command in Ubuntu Linux with examples
Does this work on a ubuntu on Virtualbox as well or is it just for actual machines?
Leave a Reply Cancel reply
Your email address will not be published. Required fields are marked *
Notify me of follow-up comments by email.
Notify me of new posts by email.
This site uses Akismet to reduce spam. Learn how your comment data is processed .