Netplan - Error in network definition: Updated definition changes device type

I'm trying to set a static ip on Ubuntu.

ip a:

1: lo <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
   ...
2: epn2s0: <NO-CARRIER,BROADCAST,MULTICAST> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
   link/ether ... brd ff:ff:ff:ff:ff:ff
3: wkp1s0: <BROADCAST,MULTICAST,UP_LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
   link/ether ... brd ff:ff:ff:ff:ff:ff
   inet 192.168.1.15/24 brd 192.168.1.255 scope global dynamic wkp1s0
      valid_lft 86000sec preferred_lft 86000sec
   inet6 ... scope link
      forever preferred_lft forever

ethtool -i wkp1s0:

driver: iwlwifi
version: ...
firmware-version: ...
expansion-rom-version:
bus-info: 0000:01:00.0
supports-statistics: yes
supports-test: no
supports-eeprom-access: no
supports-register-dump: no
supports-priv-flags: no

ethtool -i epn2s0:

driver: r8169
version:
firmware-version: ...
expansion-rom-version:
bus-info: 0000:02:00.0
supports-statistics: yes
supports-test: no
supports-eeprom-access: no
supports-register-dump: yes
supports-priv-flags: no

default "/etc/netplan/00-installer-config.yaml":

# This is the network config written by 'subiquity'
network:
  ethernets:
    epn2s0:
      dhcp4: true
  version: 2

When I try to change the yaml file to this:

"/etc/netplan/00-installer-config.yaml":

# This is the network config written by 'subiquity'
network:
  version: 2
  ethernets:
    wkp1s0:
      addresses:
        [192.168.1.100/24]
      nameservers:
        addresses: [8.8.8.8,8.8.4.4]

it gives this error:

sudo netplan try

/etc/netplan/00-installer-config.yaml:5:5: Error in network definition: Updated definition 'wkp1s0' changes device type
    wkp1s0:
    ^

What am I doing wrong?

I know that my original yaml file is setting dhcp for the other adapter, epn2s0, but even though it's doing that, wkp1s0 is getting an ip.

When I change wkp1s0 -> epn2s0 in the yaml file to try to set static ip for epn2s0, I get this error:

sudo netplan try

An error occurred: Command '['systemctl], 'stop', 'systemd-networkd.service', 'netplan-wpa-*.service']' returned non-zero exit status 1.

What am I doing wrong?

UPDATE:

when I try this yaml file:

# This is the network config written by 'subiquity'
network:
  version: 2
  wifis:
    wkp1s0:
      addresses:
        [192.168.1.151/24]
      nameservers:
        addresses: [8.8.8.8,8.8.4.4]
  ethernets:
    epn2s0:
      dhcp4:
        true

netplan try:

An error occurred: Command '['systemctl', 'stop', 'systemd-networkd.service', 'netplan-wpa-*.service']' returned non-zero exit status 1.

After that, "ip a" now shows:

1: lo <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
   ...
2: epn2s0: <NO-CARRIER,BROADCAST,MULTICAST> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
   link/ether ... brd ff:ff:ff:ff:ff:ff
3: wkp1s0: <BROADCAST,MULTICAST,UP_LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
   link/ether ... brd ff:ff:ff:ff:ff:ff
   inet 192.168.1.151/24 brd 192.168.1.255 scope global global wkp1s0
      valid_lft 86000sec preferred_lft 86000sec
   inet 192.168.1.44/24 brd 192.168.1.255 scope global secondary dynamic wkp1s0
      valid_lft 86000sec preferred_lft 86000sec
   inet6 ... scope link
      valid_lft forever preferred_lft forever

So now the wifi adapter seems to have 2 ip addresses, 1 of which is dynamic

Both of these ip addresses now work (I'm hosting an apache2 server on it), and one of them is static, so perhaps it's solved, but I don't want the dynamic IP, only the static one.


Your device wkp1s0 appears to be a wifi interface, not a ethernet interface. According to the netplan(5) man page, this needs to be in a wifis: section instead of a ethernets: section.

The man page also notes you will need wpasupplicant installed, and you may also need to add static configuration options to set up the connection to your wifi access point, such as password and access-point.