Ubuntu and netplan

Patrice Brien 26 Reputation points
2021-09-09T21:23:04.573+00:00

I start playing with netplan.
What I apply is working, until I reboot.

Netplan YAML file reset and what I done is lost.

  • How to keep my new configuration after reboot?
  • Also, why if I set nameservers in the netplan file, when I do a nslookup, these new NS are not used?
Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
9,013 questions
Microsoft 365 and Office Skype for Business Linux
{count} votes

Accepted answer
  1. prmanhas-MSFT 17,946 Reputation points Microsoft Employee Moderator
    2021-09-22T05:32:48.84+00:00

    @Patrice Brien Thank you for your patience over the matter!!!

    I had discussion internally and below are the inputs I got :

    It looks like DHCP is overwriting the Netplan file when rebooted. Please try below format.

    network:  
    version: 2  
    renderer: networkd  
    ethernets:  
     eno1:  
     dhcp4: no                                             #No DHCP  
     dhcp6: no                                             #No DHCP  
     addresses: [ 10.64.12.18/29 ]  
     nameservers:  
              addresses: [10.64.5.5,10.64.6.6]            #DNS IPs  
          routes:                                   #Static routes  
                  - to: 10.0.0.0/8  
                    via: 10.64.12.17  
        eno2:                                     #Second interface in this example  
          dhcp4: no                                               #No DHCP  
          dhcp6: no                                               #No DHCP  
          addresses: [ 104.44.223.89/26 ]  
          gateway4: 104.44.223.65                         #Default gateway in this case  
    

    Also If you are looking for adding custom name servers alone its better to do it from Portal rather than updating from OS. When DHCP in place, any changes to all this files will get reset during reboot or refreshing the dhcp service.

    134212-image.png

    If we need to add custom domain as well then use /etc/dhcp/dhclient.conf for both

    Hope it helps!!!

    Please "Accept as Answer" if it helped so it can help others in community looking for help on similar topics.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.