Netplan - 网络定义错误:更新的定义更改了设备类型

Netplan - 网络定义错误:更新的定义更改了设备类型

我正在尝试在 Ubuntu 上设置静态 IP。

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

默认“/etc/netplan/00-installer-config.yaml”:

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

当我尝试将 yaml 文件更改为以下内容时:

“/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]

它给出了这个错误:

sudo netplan 尝试

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

我究竟做错了什么?

我知道我原来的 yaml 文件正在为另一个适配器 epn2s0 设置 dhcp,但即使它这样做,wkp1s0 也会获取一个 ip。

当我在 yaml 文件中将 wkp1s0 更改为 epn2s0 以尝试为 epn2s0 设置静态 ip 时,出现此错误:

sudo netplan 尝试

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

我究竟做错了什么?

更新:

当我尝试这个 yaml 文件时:

# 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 尝试:

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

此后,“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.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

因此现在 wifi 适配器似乎有 2 个 ip 地址,其中 1 个是动态的

这两个 IP 地址现在都可以工作(我在其上托管一个 apache2 服务器),其中一个是静态的,所以也许它已经解决了,但是我不想要动态 IP,只想要静态 IP。

答案1

您的设备 wkp1s0 似乎是 wifi 接口,而不是以太网接口。根据 netplan(5) 手册页,这需要放在一个wifis:部分中,而不是ethernets:部分中。

手册页还指出您需要安装 wpasupplicant,并且您可能还需要添加静态配置选项来设置与您的 wifi 接入点的连接,例如 passwordaccess-point

相关内容