Protocols and data

How to set a static IP address on Ubuntu Desktop

Use a second NetworkManager profile on Ubuntu Desktop for fixed IPv4, ZGW-20 management access and Edge; then restore the normal network.

You have a laptop, a Gateway and a direct Ethernet cable, and the laptop gets no address. To reach the Gateway over that cable, the laptop needs a static address on the same /24. On Ubuntu Desktop, the cleanest way is a second NetworkManager profile for the Gateway link. Your normal wired profile stays as it was, and one command switches back.

This guide applies to Ubuntu Desktop interfaces managed by NetworkManager, on Ubuntu 22.04 LTS and later. Ubuntu Server uses Netplan YAML and has its own procedure, as do bridges, bonds and VLANs. Work at the laptop. Do not change an interface that carries a remote session you need. Do not disable firewalls, VPNs or global NetworkManager state to make the example work.

EpiSensor direct-management settings

A ZGW-20 with factory network settings answers at 172.31.255.1/24 on its management port. The management port is the Gigabit Ethernet port. The 2.5 Gigabit port is the uplink to the site network.

Laptop fieldValue
IPv4 address172.31.255.123 (any free address from .2 to .254 works)
Prefix / netmask/24 / 255.255.255.0
GatewayLeave empty
DNSLeave empty
Gateway management address172.31.255.1

The management port does not run a DHCP server, so you set the laptop address by hand. The port is itself a DHCP client. On a network with a DHCP server it takes a second address and keeps 172.31.255.1. It never supplies a default route.

A Gateway upgraded from an older image, or with network settings changed on site, can use other addresses. If you can already reach Edge on the site network, Settings > Networking in Edge lists the management profile and its addresses. The older EpiSensor Linux PDF shows the same laptop address with an older 255.255.0.0 (/16) mask. This guide replaces it: use the /24 values above.

This procedure changes the laptop, not the Gateway.

Before changing the laptop

Connect the laptop to the Gateway's Gigabit port and power the Gateway. Then list the interfaces and profiles:

Bash
nmcli --version
nmcli device status
nmcli -f NAME,UUID,TYPE,DEVICE connection show

A built-in wired interface usually has a name such as enp3s0 or enp0s31f6. A USB or USB-C Ethernet adapter usually gets a name made from its MAC address, such as enx00e04c680123. If you are not sure which interface is which, unplug the cable and plug it in again. The device whose state changes is the one to use.

The STATE column tells you about the link:

  • unavailable means no carrier. Check the cable, the port and the Gateway's power.
  • connecting (getting IP configuration) means the ordinary profile is waiting for a DHCP offer. The Gateway will not send one, so this is expected.
  • unmanaged means NetworkManager does not control the interface. Stop: this guide does not apply.

Set two variables from that output and save a copy of the current profile:

Bash
LAN_IFACE='enp3s0'
ORIGINAL_UUID='paste-original-profile-uuid'
nmcli connection show uuid "$ORIGINAL_UUID" > ~/nm-original-profile.txt

Choose one of the next two methods. Ubuntu Settings edits the ordinary wired profile, and you change it back afterwards. The nmcli method adds a second profile and does not touch the ordinary one. Do not use both.

Set the address in Ubuntu Settings

  1. Open Settings, then Network.
  2. Select the gear beside the wired connection.
  3. Open the IPv4 tab and set IPv4 Method to Manual.
  4. Enter 172.31.255.123 as the address and 255.255.255.0 as the netmask.
  5. Leave Gateway empty.
  6. Turn off automatic DNS and leave the server field empty.
  7. Under Routes, select Use this connection only for resources on its network.
  8. Select Apply. Turn the wired connection off and on again.

Step 7 sets ipv4.never-default on the profile, so the wired link cannot take the default route from Wi-Fi. These labels are from GNOME Settings on Ubuntu 24.04. Other releases can place them slightly differently.

Create a separate profile with nmcli

Choose a name for the new profile and check that it is free. nmcli accepts two profiles with the same name, and the UUID lookup below then returns two lines. No output from grep means the name is free.

Bash
LAN_PROFILE='EpiSensor temporary management'
nmcli -g NAME connection show | grep -Fx "$LAN_PROFILE"

Create the profile:

Bash
sudo nmcli connection add \
  type ethernet \
  ifname "$LAN_IFACE" \
  con-name "$LAN_PROFILE" \
  connection.autoconnect no \
  ipv4.method manual \
  ipv4.addresses '172.31.255.123/24' \
  ipv4.never-default yes \
  ipv6.method disabled

LAN_PROFILE_UUID=$(nmcli -g connection.uuid connection show id "$LAN_PROFILE")
echo "$LAN_PROFILE_UUID"

connection.autoconnect no stops NetworkManager from choosing this profile by itself when you plug into the office network. ipv4.never-default yes stops the profile from installing a default route, even if someone adds a gateway to it later. Wi-Fi keeps carrying internet traffic while the cable is connected. ipv6.method disabled applies to this profile only.

Activate the profile:

Bash
sudo nmcli connection up uuid "$LAN_PROFILE_UUID" ifname "$LAN_IFACE"

An interface has one active profile at a time. This command replaces the ordinary profile on that interface and does not change Wi-Fi.

Activate with a checkpoint

A checkpoint makes the change reversible without your input. Run nmcli device help. If it lists checkpoint, use this instead of the plain connection up above. If checkpoint support is unavailable, use the plain command from the laptop's own console, with the original profile details already recorded:

Bash
sudo nmcli device checkpoint --timeout 120 "$LAN_IFACE" -- \
  nmcli connection up uuid "$LAN_PROFILE_UUID" ifname "$LAN_IFACE"

When the activation finishes, nmcli shows Type "Yes" to commit the changes:. Check the route from a second terminal, then type Yes. If you do not type it within 120 s, NetworkManager puts the interface back as it was before the checkpoint. Always set --timeout long enough to check the route.

Verify the address and route

Shell variables do not carry into a new terminal, so set LAN_IFACE again:

Bash
LAN_IFACE='enp3s0'
ip -4 address show dev "$LAN_IFACE"
ip -4 route get 172.31.255.1
ip -4 route show default
ping -c 4 -W 2 172.31.255.1

A correct route looks like this:

Output
172.31.255.1 dev enp3s0 src 172.31.255.123 uid 1000
    cache

dev must be the Ethernet interface and src must be 172.31.255.123. The default route must be the same as before, usually through the Wi-Fi interface (wlp...). Ubuntu shows the wired link as having no internet access. That is expected.

A ping reply shows that 172.31.255.1 answers on the link. It does not show that Edge is running. Test the Edge port:

Bash
nc -zv 172.31.255.1 8082

succeeded! means Edge is listening. Open http://172.31.255.1:8082 in a browser and sign in. Edge uses TCP port 8082 unless its ui-port setting was changed. If the site has turned on HTTPS, use https://. Open Settings > About and check that the Gateway identity and Edge version match the Gateway you meant to reach.

Troubleshooting

SymptomCause and action
nmcli device status shows unavailableNo link. Check the cable, the port and the Gateway's power. For a USB adapter, check that ip link lists it.
ip route get shows dev tun0, dev wg0 or another VPN interfaceA VPN routes 172.31.255.0/24. Disconnect the VPN for this session. Some corporate VPN clients also block local-subnet traffic while connected, even when the route is correct.
Route is correct, but ping times out and ip neigh show 172.31.255.1 shows FAILED or INCOMPLETENothing answers ARP for .1 on the cable. The cable is in the 2.5 Gigabit uplink, or the Gateway's management address was changed.
Ping replies, but nc reports Connection refused or times outEdge is not running, or it uses a different port. Check the site's commissioning record.
The link stops working after you unplug and replug the cableNetworkManager activated the ordinary profile again, because the Gateway profile has autoconnect off. Run the connection up command again.
The laptop loses internet access while cabledThe wired profile has a gateway and took the default route. Remove the gateway, or set ipv4.never-default yes.

Do not widen the laptop's mask to /16 until something answers. A wider mask hides the real problem and can overlap other networks.

Restore the ordinary network

If you used Ubuntu Settings, open Settings, Network and the same wired connection. On the IPv4 tab, set IPv4 Method back to the value in ~/nm-original-profile.txt, usually Automatic (DHCP). Turn automatic DNS on again and clear Use this connection only for resources on its network. Select Apply and reconnect.

If you used the separate nmcli profile, bring the original profile back up:

Bash
LAN_IFACE='enp3s0'
ORIGINAL_UUID='paste-original-profile-uuid'
sudo nmcli connection up uuid "$ORIGINAL_UUID" ifname "$LAN_IFACE"
ip -4 route show default

If the interface had no profile before, skip this step.

Then delete the temporary profile, or keep it for the next visit:

Bash
LAN_PROFILE_UUID=$(nmcli -g connection.uuid connection show id 'EpiSensor temporary management')
sudo nmcli connection delete uuid "$LAN_PROFILE_UUID"

Delete by UUID, not by name, so you cannot remove a different profile with a similar name.

Permanent addresses on a site network

For a permanent address on a site network, ask the network owner for the address, prefix, gateway and DNS, or use a DHCP reservation. With a reservation, the DHCP server keeps control of the gateway and DNS, and the address is recorded in one place. Do not use 172.31.255.0/24 on a site network unless the network owner has assigned it for this purpose.

Common questions

What static IP should Ubuntu Desktop use for a ZGW-20 management connection?

Use 172.31.255.123/24 (netmask 255.255.255.0) on the Ethernet interface cabled to the Gateway's Gigabit port. Leave the gateway and DNS empty. The Gateway answers at 172.31.255.1. Any free address from 172.31.255.2 to 172.31.255.254 also works.

Can the laptop keep its Wi-Fi internet connection while it is cabled to the Gateway?

Yes. The Gateway profile has no gateway and sets ipv4.never-default, so it never installs a default route. The default route stays on Wi-Fi, and only 172.31.255.0/24 traffic uses the cable. Run ip -4 route show default to confirm it.

Why does Ubuntu stay on "connecting" when the cable goes to the Gateway?

The laptop's ordinary wired profile asks for a DHCP address. The ZGW-20 management port is a DHCP client, not a DHCP server, so no offer arrives. nmcli device status shows connecting (getting IP configuration) until NetworkManager gives up. Activate the static profile in this guide instead.