0

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.

Gimme the 411
  • 101
  • 1
  • 4

1 Answers1

1

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.

user10489
  • 474
  • 1
  • 2
  • 12
  • Yes, I'm trying to set a static ip for the wifi interface. The ethernet interface is not used. Even though my default yaml file doesn't mention the wifi interface at all, and sets the ethernet interface to use dhcp, ip a shows that the wifi interface obtains an ip by dhcp. And the wifi connects and works correctly, I just want to make it use a static ip. Can you suggest what my yaml file should look like? Because changing ethernets: to wifis: gives a general error. – Gimme the 411 Jan 01 '22 at 14:40
  • Very possibly your existing yaml will work, but you need to put the wkp1s0 section in a wifis: section rather than an ethernets: section. If you have an ethernets: section at all, only epn2s0 should be in it. – user10489 Jan 01 '22 at 14:43
  • I updated with the error that it gives when I change my yaml file like that – Gimme the 411 Jan 01 '22 at 15:35
  • I also added the new result of "ip a", which shows that the wifi adapter now has 2 ip addresses, 1 of which seems to be dynamic. – Gimme the 411 Jan 01 '22 at 15:41
  • Netplan doesn't seem to remove old configurations from interfaces, so getting two addresses happens. That should go away on some future boot or maybe when the dhcp lease expires; ignore it for now. Focus on fixing the netplan error. At a guess, there's something wrong with your wpasupplicant configuration, and you need to see what the errors are that are breaking netplan-wpa-*.service. (Probably it isn't configured at all and needs to be.) Possibly adding more directives in the netplan section (like password, access-points) would fix it. – user10489 Jan 01 '22 at 16:52