Ubuntu 22.04: Switching network configuration from DHCP to static

@Jamie, that is somewhat expected, right if primary IP address is assigned (i.e. dhcp4: true) automatically?

Perhaps, we should convert currently active IP address assigned with DHCP to a static IP in case additional IPs are added to the interface?

@Ilia,

This does appear to be the proper behavior as his IP address is changing, so yeah the nag screen is telling him to apply an update so that things continue to work as expected.

He should set the “Default IP” to the “Dedicated IP” rather than the “Dynamic IP”.

the problem is it’s not changing at all, tell me how you get that the IP is changing. All I did was add a virtual interface with the extra IP as my vpn supplier has the default IPas one starting 185 & the 109 one was added afterwards … I think more the problem here is VM didn’t write the netplan config file correctly reading the above posts shows how I fixed it and how it was after the new virtual interface was added via virtualmin

@jimr1,

Based on the screenshot, it appears you “changed” your NIC’s primary IP address from “185” to “109” which changed the “default IP” address. Then you “added” the “185” address back as a “virtual adapter”.

Is there a reason you didn’t simply “add” the “109” address as the virtual adapter?

Just trying to make better sense of how you actually got to where you are now.

*** My next few responses may be delayed as it’s 4:30 am PST and I’ll be away much of tomorrow ***

I did, I didn’t mess with anything else & this was the result

Just So everyone is clear this is the process I followed

  1. reimage the vps with Ubuntu 22.04
  2. using install.sh installed virtualmin/webmin
  3. created some domains
    4 changed one of the domain’s IP to a new one using

    The result from this was

    then after a reboot it altered to this

    after reboot the netplan config file looked like this

This was the config for netplan with the nag screen.
To remove the nag screen the netplan config had to altered to

as you can see virtualmin forgot to add the 185 ip address to the netplan config, after adding the 109 address, as per above, and rebooting the vps everything returned to normal.
As I foot note up until now I have not researched network interfaces until now ( to try and fix this problem) in the past virtualmin has never failed but to be fair Ubuntu <= 20.04 you didn’t have to use net plan but it appears in 22.04 it’s the default. in fact in the past Jamie told me to remove the directory “/etc/netplan” as the boot up interfaces don’t show in the webmin module with this directory present therefore I am new to netplan

@jimr1,

I’m spinning up a test server to see if I can replicate your problem.

*** BTW: why are you using a dedicated IP for a single domain anyways? ***

The customer needs ports that are already used on the shared address so simple just to add a new address

To add to this the ports used on both Ip’s are 27000 through 27100 but to be fair I could have opened 26000 through 26100 and pointed the running software to the newly opened ports, however steam game users like to be on default ports i.e 27000 & upwards

Peter, IP address shouldn’t be changing, if this is a dedicated [virtual] machine in a datacenter.

You shouldn’t use DHCP. Use static configuration. For example:

network:
  ethernets:
        ens192:
            addresses: ['185.132.42.12/32, '109.228.35.223/32']
...

which it is so where do I go from here

Static configuration can also be setup using Webmin / Networking ⇾ Network Configuration: Network Interfaces page:

which one ?

I think it’s easier to just remove dhcp4: true line from your netplan config file and run netplan try to see if that works.

That failed in a big way … running netplan try just locked me out of the machine … back to a reimage I guess

ok after a reimage I now end up with this after a reboot


it looks really odd
on reimage the netplan original config was

network:
  ethernets:
    ens192:
      dhcp4: true
      accept-ra: true
  version: 2

after I added the extra IP it was

network:
  ethernets:
        ens192:
            dhcp4: true
            addresses: ['109.228.35.223/32']
            accept-ra: true
  version: 2

to get it to work It was altered to

network:
  ethernets:
        ens192:
            dhcp4: true
            addresses: ['185.132.42.12/32','109.228.35.223/32']
            accept-ra: true
  version: 2

I wasted a whole afternoon turning DHCP off :slight_smile:

I don’t see DHCP4 being disabled, as config option named dhcp4: true still present on your netplan config file. You may also want to setup routes and nameservers in static IP configuration.

It can be done in Webmin using Networking ⇾ Network Configuration: Routing and Gateways and Networking ⇾ Network Configuration: Hostname and DNS Client pages.

After all your netplan config should look something like:

network:
  ethernets:
        ens3:
            addresses: ['185.132.42.12/32','109.228.35.223/32']
            accept-ra: true
            nameservers:
                addresses: [127.0.0.53, 8.8.8.8]
                search: [.]
            routes:
              - to: default
                via: 185.132.42.254  # may vary depending on your network configuration
  version: 2

Also, I would suggest to contact your ISP to help you to switch to static network configuration.

If you wish to do it on your own consider using ip route and resolvectl status commands to fill the right network configuration.

Additionally refer to this netplan manual:

I’m just going to leave it as it is as it’s working

went back to ubuntu 20.04 … as vm seams to have issues with 22.04 … this did fix the above problems but that said after reboot the virtual interface disappears rather than adding loads of interfaces with the same ip

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.