Set a static IP address on an Ubuntu system


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

Notes about this guide:

  • This guide is for Access Servers deployed in a local or private network.
  • For cloud environments, reference the cloud 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 or already in use otherwise.
  • 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. 

Before you begin

You need the following to get started:

  • Console or SSH access to your server with root privileges.
  • The static IP address for your server — in our example, we use
  • The network subnet for your server — in our example, we use
  • The internet gateway and DNS server IP address — in our example, we use

Adjust our examples to match your network and your desired static IP. These steps use IPv4 addresses.

Important: 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 settings, making a snapshot of your VM, or ensuring access to the (virtual) console to have a way to fix errors.

DHCP server tips

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 the static IP 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.

Edit network configuration file

To assign a static IP address, the first step is editing the text file containing your network interfaces' configuration.

Note: The filename in which netplan configuration is stored may have a different name than 01-netcfg.yaml file. 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: false
    - to: default
           addresses: []
  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:

Note: 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 and undo the changes or correct whatever errors are reported.

If you have network access but can't ping an address like then 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 nameservers 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.