Skip to main content

Tutorial: Set a Static IP Address on an Ubuntu System


Follow these steps to set up a static IP address on an Ubuntu system. This is important to run Access Server.


This guide provides instructions for setting a static IP address on an Ubuntu server in your local or private network.


  • This guide is for Access Servers deployed in a local or private network.

  • For cloud environments, reference the provider's documentation for static IP address assignment.

  • If you use NetworkManager, you should use that instead of this guide.

  • Ensure that the static IP for Access Server is available for assignment, not part of a DHCP range, and not already in use.

  • These instructions apply to Ubuntu 20 and newer.

  • We recommend using a fully qualified domain name (FQDN) as the address to which VPN clients connect, even if you use a static IP address.

You need the following to get started:

  1. Console or SSH access to your server with root privileges.

  2. The static IP address for your server — in our example, we use

  3. The network subnet for your server — in our example, we use

  4. The internet gateway and DNS server IP address — in our example, we use

Ensure your IP address and values match your network. These steps use IPv4 addresses. We use example IPv4 addresses reserved for documentation.


When you change the network interface settings, you could lose network access to the system if you make a mistake. We recommend backing up your Access Server configuration, creating a snapshot of your VM, or ensuring access to the (virtual) console to have a way to fix errors.

If Access Server receives an IP address from a DHCP server, use the DHCP reservation or static lease option there (if available) to always assign the same DHCP IP address to the server. This way, you don't have to configure a static IP in the operating system.

Not all DHCP servers have this option. In such a case, you can follow these steps to set the static IP address in the Linux server operating system. If you set the static IP address directly on the server, ensure you configure it to one outside of the DHCP range. Otherwise, the DHCP server may consider the IP address you assign to your server suitable for assignment to a DHCP client, which may lead to an IP address conflict.

Some networks don't have a DHCP server; you must assign a static IP address. In that case, pick any available IP address in your network.

To assign a static IP address, edit the text file containing your network interfaces' configuration.


The file storing the netplan configuration may have a different name than 01-netcfg.yaml, such as 50-cloud-init.yaml. You may also have multiple files in the directory. If you have multiple files, pick the one with the highest number. If you don't have the /etc/netplan directory, you may be on an older Ubuntu system, and we recommend upgrading.

  1. Connect to your console with root privileges.

  2. Open the file /etc/netplan/01-netcfg.yaml with the nano text editor:

    nano /etc/netplan/01-netcfg.yaml
  3. Locate the dhcp4 item for your network interface and set it to false.

  4. Use the following example to add the static IP address information:

         dhcp4:4 false
         addresses:5 []
         - to: default
           addresses: []


    This is the configuration file's root element and signifies the network configuration's start.


    This section specifies the start of the ethernet interfaces configuration.


    This identifies the specific ethernet interface being configured. You can use the command ip link to list your interface names.


    This indicates whether the interface obtains an IP address automatically from a DHCP server.


    Here, you specify the static IP address and subnet mask.


    This section defines static routes where to: default specifies a default route through the gateway,, with via: .


    This key specifies the DNS servers to be used by the system.


    Ensure you use correct spacing to avoid errors. The correct spacing is found in /usr/share/doc/netplan/examples/static.yaml.

  5. Press ctrl+x, y, and enter to save and exit the file.

  6. Apply the setting with this command:

    netplan apply

In the example network configuration file above, adjust for your network based on our example settings:

  • IP address:

  • Network:

  • Internet gateway and DNS server:


In our example above, we only have one network interface, eth0. If it is called something else in your system, make allowances for this and adjust things as necessary.

If you've lost network access to your instance, use the (virtual) console to restore the altered file back to DHCP mode, undo the changes, or correct any errors reported.

If you have network access but can't ping an address like, your gateway (routes to default via:) may be incorrect. Try correcting this and applying the changes to ensure traffic goes through the correct gateway.

If you can ping but can't ping a domain name like, then make corrections to the nameserver setting; it may have an incorrect DNS server specified there. Try correcting this and applying the changes to ensure DNS resolution goes through the correct DNS server.

If your network is working correctly, but now the Access Server web services don't respond, you may need to restart the Access Server service with service openvpnas restart. If the web services still don't work on the new IP address configuration, you may have configured Access Server to listen only to a specific IP that doesn’t exist anymore. You can reset the web services and daemon ports to their default settings to make it work with the new IP address configuration.