0

I have edited /etc/netplan/01-network-manager-all.yaml to get a static ip address:

network:
  version: 2
  renderer: networkd
  ethernets:
    wlp0s20f3:
      dhcp4: no
      addresses:
        - 10.1.10.23/24
      routes:
        - to: default
          via: 10.1.10.1
      nameservers:
          addresses: [10.1.1.10]

After netplan apply everything is fine, the interface is configured according to the config, but after reboot, the interface gets some additional automatic dhcp configuration:

2: wlp0s20f3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether cc:15:31:5e:bf:41 brd ff:ff:ff:ff:ff:ff
    inet 10.1.10.101/24 brd 10.1.10.255 scope global dynamic noprefixroute wlp0s20f3
       valid_lft 5652sec preferred_lft 5652sec
    inet 10.1.10.23/24 brd 10.1.10.255 scope global secondary noprefixroute wlp0s20f3
       valid_lft forever preferred_lft forever
    inet6 fe80::d6f7:2c10:8bf1:af66/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

It is even somehow assigned an ipv6 address despite

net.ipv6.conf.all.disable_ipv6=1

being set in /etc/sysctl.conf

It seems like some service is changing the configuration, it didn't happen on 20.04.

How to disable this automatic configuration?

ZDV
  • 3
  • I suggest that you return netplan to its default configuration and set the static IP in Network Manager. Welcome to Ask Ubuntu. – chili555 Apr 02 '22 at 18:32
  • @chili555 I am actually trying to automate the deployment of several laptops in a network, so I need to be able to do the configuration with bash. – ZDV Apr 02 '22 at 18:47
  • May I assume that wlp0s20f3 is a wireless interface? – chili555 Apr 02 '22 at 20:31
  • See https://netplan.io and https://netplan.io/examples. – waltinator Apr 02 '22 at 22:28
  • @chili555 yes, it is – ZDV Apr 03 '22 at 05:04
  • Edit your question and show me ls -al /etc/netplan and cat /etc/network/interfaces. Your .yaml file is incomplete for a wireless configuration. Where is the SSID and password? – heynnema Apr 03 '22 at 15:55
  • @chili555 wlp0s20f3 means "wl" is wireless, "p0" is port zero, "s20f3" means slot #. Don't you just love the new naming convention? It used to be much easier when it was just wlan0... – heynnema Apr 03 '22 at 15:59
  • @heynnema I am quite aware. It means extra work for OP who is "trying to automate the deployment of several laptops in a network" – chili555 Apr 03 '22 at 16:16
  • 1
    @chili555 Yes. The idea of using a bash script will require that they interrogate each computer's configuration, as it won't always be wlp0s20f3, and you probably wouldn't want to enter the wifi ssid/password in such a script anyway. Not easy. – heynnema Apr 03 '22 at 16:26
  • Your .yaml should use wifis, not ethernets. – heynnema Apr 03 '22 at 16:29

2 Answers2

1

The DHCP address is provided by Network Manager. In order to use a scipt and therefore netplan, disable NM like this: How do I disable network manager permanently?

Next, your netplan file fails to provide the SSID and WPA2 password. I suggest that you amend it:

network:
  version: 2
  renderer: networkd
  wifis:
    wlp0s20f3:
      dhcp4: no
      dhcp6: no
      addresses: [10.1.10.23/24]
      nameservers:
        addresses: [10.1.1.10]
      access-points:
        "network_ssid_name":
          password: "**********"
      routes:
        - to: default
          via: 10.1.10.1

Note that the SSID and password are enclosed in quotation marks ". Netplan is very specific about indentation, spacing, etc., so proofread carefully twice. Follow with:

sudo netplan generate
sudo netplan apply

Please note that in a deployment of several laptops in a network, wlp0s20f3 is very unlikely to be the same interface name for all. As @heynnema points out above, you will need to interrogate each laptop for its logical interface name.

chili555
  • 60,188
  • I actually suspect that they have two .yaml in /etc/netplan (or an old /etc/network/interfaces), and that's where the DHCP address is coming from. I wouldn't personally put in the part about disabling NetworkManager, as you've already specified the use of networkd. They may wish to use NM someday. – heynnema Apr 03 '22 at 17:27
  • @heynnema All of the NM steps are easily reversible if needed. – chili555 Apr 03 '22 at 19:12
0

Try with renderer. NetworkManager works perfectly for me in Ubuntu 21.10.

network:
  version: 2
  renderer: NetworkManager
  ethernets:
    wlp0s20f3:
      addresses:
          - tu ip asignada/**
  nameservers:
    search: [tu dominio]
    addresses: [8.8.8.8, 8.8.4.4]
  routes:
      - to: default
        via: tu touter
karel
  • 114,770
  • 1
    Keep in mind that English is the required language for posts here on Ask Ubuntu (and most Stack Exchange sites). There's a strong moderation system in place here, and we need posts to be in a language that the majority of users and moderators can understand without additional translation. Thanks! – NotTheDr01ds Jan 04 '23 at 14:20