Skip to content

Tutorial: How to set up NAT gateway for private Cloud Networks -- network connection lost at DHCP renewal #1307

@jrmyfranck

Description

@jrmyfranck

Problem

By following the tutorial How to set up NAT gateway for private Cloud Networks, the client servers end up with a configuration that works at reboot, but can fail after DHCP renewal, depending on the content of the netplan configuration files (i.e. if you've removed all public IPs from the client server).

This means that the client servers can lose network access after a while.

The reason for this is, on modern Ubuntu (24.04) netplan will take over after DHCP renewal and will create new network configuration files, invalidating the changes made manually through the /etc/systemd/network/10-enp7s0.network file.

Suggested Fix

Rely on netplan to create the appropriate configuration files, instead of a manually-created configuration file.

On the client server, remove the /etc/systemd/network/10-enp7s0.network file, and modify the /etc/netplan/50-cloud-init.yaml file instead to include the desired route.

Here is an example:

Run the following command:

sudo vim /etc/netplan/50-cloud-init.yaml

And edit the content so that it ressembles this:

network:
    version: 2
    ethernets:
        enp7s0:
            dhcp4: true
            routes:
                - to: default
                  via: 10.0.0.1

Save and exit the editor.

Now, apply the configuration with

sudo netplan apply

You can verify the ip route with this command:

ip route show

You should see your desired route (i.e. default via 10.0.0.1 ) in the ouput.

Disclaimer: I am not a network expert, and used an LLM (informed by outputs from the client servers and the contents of the tutorial), to come up with this solution. It seems to be working for me, and I thought I'd contribute by sharing it, but it may not be flawless — a more seasoned system admin would probably need to weight in on the implications to make it foolproof.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions