WindowsMacSoftwareSettingsSecurityProductivityLinuxAndroidPerformanceConfigurationApple All

How to Configure Static IP Address on Ubuntu Desktop

Edited 3 weeks ago by ExtremeHow Editorial Team

Static IPUbuntuDesktopNetworkingLinuxConfigurationOperating SystemsIP AddressSystemAdministration

How to Configure Static IP Address on Ubuntu Desktop

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.

Understanding IP addresses

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.

Network Manager: Graphical method

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.

Step-by-step instructions

  1. Open the Network Manager:
    • Find the network icon in the top right corner of your Ubuntu desktop screen and click on it.
    • A dropdown menu will appear. Click "Settings" or "Network Settings."
  2. Access the network settings:
    • Once you are in the Network Settings window, find the network connection for which you want to set a static IP. This can be a wired (Ethernet) or wireless (Wi-Fi) connection.
    • Edit its settings by clicking the gear icon next to the network connection name.
  3. Configure IPv4 settings:
    • In the network settings window, you will see several tabs. Switch to the "IPv4" tab.
    • Change the method from "Automatic (DHCP)" to "Manual."
    • A new input box will appear in which you will be able to enter the details of your static IP address.
    • Enter the desired IP address under "Address", the netmask under "Netmask/Prefix", and the gateway address under "Gateway".
  4. Set up DNS:
    • In the same window, look for the "DNS" section.
    • Enter the IP addresses of the DNS servers you want to use, separating them with commas.
  5. Save and apply the changes:
    • After entering the required information, click the "Apply" button to save the changes.
    • Turn your network connection off and then on again, or restart your computer to apply the changes.

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.

Using the command line: Netplan configuration

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.

How to set up a static IP address using Netplan

  1. Open the terminal:
    • Use the keyboard shortcut Ctrl + Alt + T to open the terminal.
  2. Edit the netplan configuration file:
    • Go to the /etc/netplan/ directory, which contains the network configuration files.
    • Execute the command: cd /etc/netplan
    • Identify the existing YAML file. It is usually named something like 01-netcfg.yaml or 50-cloud-init.yaml.
    • Edit the YAML file with a text editor such as nano. Run sudo nano 01-netcfg.yaml
  3. Modify the network configuration:
    • In the selected YAML file, find the section starting with “ethernets” or “wifis” depending on your connection type.
    • Inside this section, look for the block that begins with "dhcp4". Change it from true to false to disable DHCP.
  4. Enter the static IP information:
    • To specify a static IP configuration, add a new block of properties under the Ethernet or Wi-Fi identifier. Here is an example of what the configuration might look like:
    •         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]
            
    • Make sure to replace 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.
    • Save the file and press Ctrl + X to close the editor, then press Y to confirm the changes, and press Enter to exit.
  5. apply changes:
    • Execute the command: sudo netplan apply
    • This will apply your changes. Verify your settings by using 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.

Testing the configuration

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:

Common problems and troubleshooting

Sometimes, the configuration may not work as expected. Here are some common problems and possible solutions:

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


Comments