Edited 3 weeks ago by ExtremeHow Editorial Team
Static IPUbuntuDesktopNetworkingLinuxConfigurationOperating SystemsIP AddressSystemAdministration
This content is available in 7 different language
Configuring a static IP address on Ubuntu desktop can be useful for a number of reasons. Generally, having a fixed IP address can help ensure a consistent network connection and this is especially necessary in certain scenarios such as running a gaming server, file server or any other type of server on a home network. In this comprehensive guide, we will review how to set up a static IP address on Ubuntu desktop systems. We will explore using the graphical user interface as well as the command line interface, which will provide flexibility and depth of knowledge. This process should be applicable for most versions of the Ubuntu operating system, although the steps may vary slightly depending on the version you have.
An Internet Protocol (IP) address is a unique identifier assigned to each device on a network. It consists of a series of numbers separated by dots. For example, in IPv4, an IP address looks like 192.168.1.2. There are two types of IP addresses: dynamic and static. A dynamic IP is usually assigned automatically by a DHCP server. This is convenient because you don't have to configure anything manually, but the assigned IP can change. On the other hand, a static IP is configured manually and remains constant, which is useful for maintaining consistent access to a machine.
The Ubuntu desktop comes with a software utility called Network Manager that provides a convenient graphical user interface for configuring network settings, including IP addresses.
This method is user-friendly and does not require in-depth technical knowledge. However, there are times when using the command line can provide more control and offer more customizability, especially for advanced users. In the next sections, we will explore how to configure a static IP address via the command line.
For more technical users or those running a server without a graphical interface, manually configuring IP addresses through a command-line tool like Netplan is a great option. Netplan is a utility used by Ubuntu to configure networking; it is straightforward and uses YAML configuration files.
/etc/netplan/
directory, which contains the network configuration files.cd /etc/netplan
01-netcfg.yaml
or 50-cloud-init.yaml
.nano
. Run sudo nano 01-netcfg.yaml
true
to false
to disable DHCP.
ethernets: enp3s0: dhcp4: no addresses: - 192.168.1.100/24 gateway4: 192.168.1.1 nameservers: addresses: [8.8.8.8, 8.8.4.4]
192.168.1.100
with your chosen IP address, 192.168.1.1
with your network's gateway, and use the appropriate DNS server addresses.sudo netplan apply
ip addr
to check the IP assignment.The simplicity of using YAML files makes Netplan an effective tool for those familiar with the command line. However, always be careful with the syntax as YAML is dependent on spaces.
Once you have configured a static IP address, it is important to test the network to make sure everything is working correctly. Here are some general tips and checks you can perform:
Use ping [destination]
command to check connectivity to another device or the Internet. For example, ping 8.8.8.8
to check connectivity to Google's public DNS.
Check if domain names are being resolved correctly by using nslookup [domain]
. For example, nslookup ubuntu.com
.
Confidently verify the IP settings by typing ip addr show
in the terminal to display the IP addresses of all network interfaces.
Sometimes, the configuration may not work as expected. Here are some common problems and possible solutions:
Make sure you save and apply the configuration correctly. It's easy to overlook not saving the YAML file or executing netplan apply
.
Check if the static IP you set is already in use on the network. You can use a tool or check your router's interface to avoid conflicts.
Since YAML relies on spaces, ensure correct formatting. Use spaces for indentation and avoid tabs. Format checker tools can be helpful.
By following these steps, anyone should be able to efficiently set up a static IP on Ubuntu desktop, optimizing network performance according to their needs. Whether using the GUI or the command line, Ubuntu offers flexibility in managing network settings to suit different user comfort levels and expertise.
If you find anything wrong with the article content, you can