Static IP keeps resetting on Ubuntu VM (ESXi) – Moodle frontend unreachable after reboot

Static IP keeps resetting on Ubuntu VM (ESXi) – Moodle frontend unreachable after reboot

by Vasanth Raj -
Number of replies: 5

Hello everyone,

I’m facing a persistent networking issue while setting up Moodle on Ubuntu running inside VMware ESXi, and I’m looking for guidance or best practices from the community.


Environment

  • Hypervisor: VMware ESXi 8

  • OS: Ubuntu Server 20.04 / 22.04

  • Application: Moodle (Frontend VM)

  • Database: MariaDB on separate VM

  • Network Type:

    • Public IP: 117.x.x.x

    • Private Network: 172.16.1.0/24

  • Interface: ens34

  • Network Manager: Netplan + cloud-init


Problem Description

I attempted to assign a static private IP to the Moodle frontend VM so it can communicate with the database VM.

What happens:

  • Static IP works temporarily after applying netplan.

  • After reboot:

    • IPv4 disappears completely.

    • Only IPv6 (fe80::) remains.

    • ip a shows no IPv4 address.

  • netplan apply works but the IP is lost again after reboot.

  • The VM automatically reverts to a public IP (117.x.x.x).

  • Ping to DB server (172.16.1.27) fails.

  • Moodle frontend becomes unreachable.


⚠️ Observations

  • Netplan configuration is correct but not persistent.

  • Cloud-init appears to overwrite network settings.

  • ESXi seems to control the NIC behavior.

  • Static IP cannot be retained on reboot.

  • Interface resets even after:

    • Disabling NetworkManager

    • Recreating netplan files

    • Fixing file permissions

    • Flushing interfaces


❓ What I’m Trying to Understand

  1. What is the correct way to assign a private IP to a VM in ESXi?

  2. Should the private IP be configured in:

    • ESXi port group?

    • Netplan only?

    • A second NIC?

  3. Is it wrong to assign a static IP when the VM is attached to a public network?

  4. How should Moodle frontend + DB networking be designed properly?


Goal

I want:

  • Moodle frontend to run on Public IP (117.x.x.x)

  • Database to remain private

  • Network config to persist after reboot

  • No IP reset or loss after restart


Any advice, best practices, or architecture suggestions would be very helpful.
Thanks in advance! 🙏

Average of ratings: -
In reply to Vasanth Raj

Static IP keeps resetting on Ubuntu VM (ESXi) – Moodle frontend unreachable after reboot

by Ken Task -
Picture of Particularly helpful Moodlers

These forums are about moodle ... while networking does come before application (in your case a moodle), there are too many things in your description that need exact information .... which you cannot provide via public forum.

So I'll bite (even though it's a holiday) .... I'll send you a PM here no this server and encourage you to respond with answers to the few questions ask.

'SoS', Ken

In reply to Ken Task

Static IP keeps resetting on Ubuntu VM (ESXi) – Moodle frontend unreachable after reboot

by Ken Task -
Picture of Particularly helpful Moodlers

Well, no response via PM, so must not be pressing .... so here is what Google's Gemini suggest ...

"If your Ubuntu server loses its IPv4 address,
it's usually due to conflicting network managers (like NetworkManager vs. Netplan), DHCP issues, or incorrect static IP settings in Netplan; the fix involves editing /etc/netplan/*.yaml to define a static IP, applying changes with sudo netplan apply, and ensuring no other tools like NetworkManager interfere, or purging conflicting packages like `wicd'"

Do know if editing config files related via command line, the formatting of those config files are sensitive.

'SoS', Ken

In reply to Ken Task

Static IP keeps resetting on Ubuntu VM (ESXi) – Moodle frontend unreachable after reboot

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators

A server configuring its network through network managers? Ha, ha, ha!

In reply to Vasanth Raj

Static IP keeps resetting on Ubuntu VM (ESXi) – Moodle frontend unreachable after reboot

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Hi

Your issue "persistent networking issue while setting up Moodle" is a networking issue, right? Moodle is a (web) application, it depends on many things below the ladder, networking is one of them. The whole list of questions that follow are all on how to set up the network on Ubuntu Linux. Have you done that independently (before starting to run a Moodle server)? Some obvious questions like "Network config to persist after reboot" say, you haven't.

You should consult Ubuntu documentation and forums and confirm that the VM has a valid and stable network connection. By that I mean the (old-school) commands like ifconfig, route, host behaving as expected. That in turn means, they should behave as set in config files like /etc/hosts, /etc/network/interfaces (since Ubuntu is a Debian derivative), /etc/hosts.conf, etc. This is not "best practice", it is _the_ practice.
 
Considering the flowery language and the fancy formatting, have you got the help of AI by any chance? The Code of conduct here says, "If you use AI to help write your question or reply, then add a note to your post 'AI used to help write this post'" (in which case, I wouldn't have joined.)
In reply to Visvanath Ratnaweera

Static IP keeps resetting on Ubuntu VM (ESXi) – Moodle frontend unreachable after reboot

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
BTW, there is a Step-by-step Installation Guide for Ubuntu. You can see where the software stack below it ends and where Moodle starts. Please read the docs and previous discussions in this forum and also make use of the forum Advanced search https://moodle.org/mod/forum/search.php?id=5 - for the Moodle-part. But currently the software stack below it, including the operating system and the network configuration, that are missing.