0

I'm new to Linux and learning. I'm not the person that set these systems up - but I need to understand and manage them now.

In /etc/netplan - both 01-netcfg.yaml and 50-cloud-init.yaml exist.

The 01 file - is static - showing 192.168.100.30 the 50 file - is dhcp

the 100.30 address is visible when I do an ipconfig -a. The 100.50 address is not visible anywhere that I have found. I don't need dhcp - the server should be set to the 100.30 static IP only.

Can I simply delete the 50-cloud-init.yaml file - or what is best practice?

results of ifconfig -a:

docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:c0:4b:ea:91  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.100.30  netmask 255.255.255.0  broadcast 192.168.100.255
        inet6 fe80::215:5dff:fe00:700e  prefixlen 64  scopeid 0x20<link>
        ether 00:15:5d:00:70:0e  txqueuelen 1000  (Ethernet)
        RX packets 17211039  bytes 1688816727 (1.6 GB)
        RX errors 0  dropped 4  overruns 0  frame 0
        TX packets 137882  bytes 550823194 (550.8 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 11147  bytes 843462 (843.4 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 11147  bytes 843462 (843.4 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

@heynnema Contents of 01-netcfg.yaml

network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: no
      addresses: [192.168.100.30/24]
      gateway4: 192.168.100.1
      nameservers:
        addresses: [192.168.100.26,192.168.100.19,8.8.8.8,8.8.4.4]

Contents of 50-cloud-init.yaml

# This file is generated from information provided by
# the datasource.  Changes to it will not persist across an instance.
# 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:
        eth0:
            addresses: []
            dhcp4: true
    version: 2

Contents of /etc/netork/interfaces:

# ifupdown has been replaced by netplan(5) on this system.  See
# /etc/netplan for current configuration.
# To re-enable ifupdown on this system, you can run:
#    sudo apt install ifupdown
  • Edit your question and show me the contents of both .yaml files (using copy/paste, not a screenshot), and cat /etc/network/interfaces. Start comments to me with @heynnema or I may miss them. – heynnema Apr 14 at 17:15
  • I just noticed, quite by accident, that you updated your answer with my request. You have to let us know by starting a comment with @heynnema. Anyway, your 2nd .yaml is not needed. The first .yaml should be fine, but you can only have 3 DNS servers. Then sudo netplan generate, sudo netplan apply, and reboot. – heynnema Apr 15 at 22:04
1

The two files differ in that one uses static IP addresses, and the other uses dhcp. As long as the addresses are appropriate for your network, just use /etc/netplan/01-netcfg.yaml. Remove /etc/netplan/50-cloud-init.yaml.

Use this .yaml... but with no dhcp4, and max 3 DNS (comma-space) servers...

network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      addresses: [192.168.100.30/24]
      gateway4: 192.168.100.1
      nameservers:
        addresses: [192.168.100.26, 192.168.100.19]

sudo netplan --debug generate

sudo netplan apply

reboot

| improve this answer | |
  • @heynema - thanks for the answer. most all of the ubuntu servers here have 'just' the 50-cloud-init file. It looks like many admins stop using that file and create the 01-netcfg file. Is there a reason for that? – jim459 Apr 16 at 13:53
  • @jim459 Because most admins want their servers at a static IP address, not dhcp. My .yaml removes "dhcp4: no", as "no" is the default anyway, and also changes the DNS nameservers to a comma-space limit of 3 addresses. – heynnema Apr 16 at 13:58
1

Both config yaml files have same interface name.

First netplan config file name is starting 01... According to the string order 01 is before 50. So 01-netcfg.yaml file works first.

And you have not DHCP server.

In this case, the file 50-cloud-init.yaml is not needed

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.