Score:0

Static IP is disappearing after restart Ubuntu Server 20.04.2 : Please help

fi flag

I have a Ubuntu 20.04.2 Server version template. I have configured IP addresses, Name servers gateway4, etc. as per the process via netplan. Whenever I am deploying VM from that template and provide specific IP (using custom specs). VM is showing the correct IP while it's configured correctly for the first time. If I reboot the new VM then again it's taking the old template IP address. No clue what I am missing.

Few result:

administrator@Ubuntu20LTS:~$ ls -al /etc/netplan
total 20
drwxr-xr-x   2 root root 4096 Jun 12 16:44 .
drwxr-xr-x 100 root root 4096 Jun  9 10:28 ..
-rw-r--r--   1 root root 1024 Jun 12 16:44 .99-netcfg-vmware.yaml.swp
-rw-r--r--   1 root root  485 Jun 12 16:43 50-cloud-init.yaml
-rw-r--r--   1 root root  346 Jun 12 16:42 99-netcfg-vmware.yaml 

administrator@Ubuntu20LTS:~$ cat /etc/netplan/99-netcfg-vmware.yaml

# Generated by VMware customization engine.
network:
  version: 2
  renderer: networkd
  ethernets:
    ens192:
      dhcp4: no
      dhcp6: no
      addresses: [10.xx.xx.xx/23]
      gateway4: 10.xx.xx.1
      nameservers:
        search: [xxx.xxx.com, xxx.xxx.com, xxx.xxx.com]
        addresses: [xxxx.xxxx.xxxx.xxxx]

administrator@Ubuntu20LTS:~$ cat /etc/netplan/50-cloud-init.yaml
# This file is generated from information provided by the datasource.  Changes
# to it will not persist across an instance reboot.  To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
    ethernets:
        ens192:
            dhcp4: true
            match:
                macaddress: 00:50:56:82:b7:a0
            set-name: ens192
    version: 2

more result: 
    administrator@Ubuntu20LTS:/etc/netplan$ ls
    50-cloud-init.yaml  99-netcfg-vmware.yaml

Cat .99-netcfg

administrator@Ubuntu20LTS:~$ cat /etc/netplan/.99-netcfg-vmware.yaml.swp
b0nano 4.8▒rootUbuntu20LTS/etc/netplan/99-netcfg-vmware.yamladministrator@Ubuntu20LTS:~$

Can anyone help me with this issue? configured IP in 99-netcfg.yaml available file in netplan dhcp enabled in 50-cloud-init.yaml

Irsu85 avatar
cn flag
I don't know if netplan uses DHCP, but if it does, you need to set the IP during install, it will become static then
Surajit A avatar
fi flag
I have added a few screenshots for better understanding. I have configured DHCP4 NO. But in another file it's showing enable. I don't know how to disable.
Irsu85 avatar
cn flag
Maybe don't use netplan but set the IP during install. Never had issues with my minecraft server that way
Surajit A avatar
fi flag
I am providing IP during VM install from the template. VM was showing correct IP once VM creation finished. If I restart the VM then IP is going back to the template's IP address.
us flag
What exactly is the "old template IP address"? Is that an address that is statically configured somewhere other than netplan?
heynnema avatar
ru flag
Edit your question and show me `ls -al /etc/netplan` and `cat /etc/netplan/*.yaml` and `cat /etc/network/interfaces`. Edit that into your question using copy/paste... not screenshots. Start comments to me with @heynnema or I'll miss them.
Surajit A avatar
fi flag
@slangasek - I had given an IP address while I created the Ubuntu VM template. From that template, I am creating a new VM with a different set of IP addresses. after the creation of the VM, the new IP is showing properly. But if I restart the VM once, the IP is getting change back to old template IP.
heynnema avatar
ru flag
You never answered my request for more info. It looks like you have two .yaml files in /etc/netplan... one static IP and one DHCP.
Surajit A avatar
fi flag
@heynnema - I am unable to do copy and paste the data here. yes, I have two .yaml files 1. 50-cloud-init.yaml 2. 99-netcfg-vmware.yaml
heynnema avatar
ru flag
In `terminal` do `cat /etc/netplan/*.yaml`, copy that output to the clipboard, edit your question, paste the clipboard, select the pasted text, click on the {} icon to format it. Don't redact any info. Also show me `sudo lshw -C network`.
Surajit A avatar
fi flag
@heynnema - Result of cat /etc/netplan/*.yaml pasted there.
heynnema avatar
ru flag
You didn't give me all of the info I requested. And you redacted non-secret info. What is `.99-netcfg-vmware.yaml.swp`? It shouldn't be in /etc/netplan. Your two .yaml files contradict each other, for ens192. Are 10.xx.xx.xx and 10.xx.xx.1 valid addresses on your network? You'll probably end up removing /etc/netplan/50-cloud-init.yaml.
Surajit A avatar
fi flag
@heynnema - I am not sure what is ".99-netcfg-vmware.yaml.swp". It's not there in /etc/netplan , only two .yaml file available there (given the details). I have not given you all the details IP address as IP address is from my client project. So I given XX instead of real numbers. All IP addresses are valid. I am able to take putty session of the VM.
heynnema avatar
ru flag
You don't see `.99-netcfg-vmware.yaml.swp` because the filename starts with a period, making the file invisible to the `ls` command. You need to use `ls -al` to see it. Edit your question and show me `cat /etc/netplan/.99-netcfg-vmware.yaml.swp`. You'll probably need to delete /etc/netplan/50-cloud-init.yaml with `sudo rm -i /etc/netplan/50-cloud-init.yaml`, then `sudo netplan generate` and `sudo netplan apply` and `reboot`, and retest.
Surajit A avatar
fi flag
@heynnema - I have pasted the output of .swp. Shall I do the deletion of cloud-init.yaml file and generate netplan as you suggested above ?
heynnema avatar
ru flag
@SurajitA You should be able to delete /etc/netplan/.99-netcfg-vmware.yaml.swp and /etc/netplan/50-cloud-init.yaml, and then do the other commands that I list. Report back.
us flag
I noted the conflict between the two yaml files, however since the presenting complaint was about a wrong STATIC IP being set, I believe the problem must lie outside of netplan. Having netplan config that specifies both static and DHCP addresses just results in two addresses being assigned, not the replacement of the static IP address with another. It is unclear to me what virtualization platform this is running on, or what template system is used, or where that template system is writing network config.
Surajit A avatar
fi flag
@heynnema - I have deleted both the files and generate the netplan and applied. After that, I have converted the VM to a template and deploy a VM from that. It picks the correct IP but after a restart, again, VM took the old template IP.
heynnema avatar
ru flag
@SurajitA You keep describing a "template". We don't know what this is or what it does. What VM? What host? How do you convert a VM to a template?
Surajit A avatar
fi flag
@heynnema - I am so sorry, we use vSphere VMWare. So in VMWare VM (virtual machine), Host (ESXi hypervisor). VMWare technology helps with virtualization. The template is nothing but a pre-configured virtual machine with an operating system, application, and other configuration as per user or application demand. we'll use that as a master image and from there we'll deploy new VM as per user demand with ready application and other configuration settings.
Surajit A avatar
fi flag
@heynnema - I am so sorry, we use vSphere VMWare. So in VMWare VM (virtual machine), Host (ESXi hypervisor). VMWare technology helps with virtualization. The template is nothing but a pre-configured virtual machine with an operating system, application, and other configuration as per user or application demand. we'll use that as a master image and from there we'll deploy a new VM as per user demand with ready application and other configuration settings. My sincere apology for using all those VMware word.
heynnema avatar
ru flag
@SurajitA Sorry, but this one may be over my head.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.