![为 Ubuntu Server 上的无线接口设置静态 IP](https://linux22.com/image/1073675/%E4%B8%BA%20Ubuntu%20Server%20%E4%B8%8A%E7%9A%84%E6%97%A0%E7%BA%BF%E6%8E%A5%E5%8F%A3%E8%AE%BE%E7%BD%AE%E9%9D%99%E6%80%81%20IP.png)
我正在尝试配置我的无线接口以使用静态 IPv4 地址,但突然失去了与互联网的连接。
这是我的配置文件内容:
# This is the network config written by 'subiquity'
network:
version: 2
renderer: networkd
wifis:
wlp2s0:
dhcp4: false
dhcp6: false
access-points:
"bssid": "mybssid"
password: "mypassword"
addresses:
- 192.168.1.100/24
routes:
- to: default
via: 192.168.1.254
nameservers:
addresses: [8.8.8.8, 8.8.8.0]
然后当我运行“sudo netplan apply”
我明白了:
/etc/netplan/00-installer-config-wifi.yaml:11:10: Invalid YAML: inconsistent indentation:
password: "mypassword"
^
在bssid和password字段中,我输入了我的Wi-Fi的SSID和密码,并在这篇文章中仅将它们替换为mybssid和mypassword,我不知道是否正确。
感谢您的帮助和时间。
答案1
修复 00-installer-config-wifi.yaml 文件:
# This is the network config written by 'subiquity'
network:
version: 2
renderer: networkd
wifis:
wlp2s0:
dhcp4: no
dhcp6: no
access-points:
"my-bssid":
password: "my-pass"
addresses: [192.168.1.100/24]
routes:
- to: default
via: 192.168.1.254
nameservers:
addresses: [192.168.1.254, 8.8.8.8]
如果有人正在阅读本文,只需将“my-bssid”替换为您的 Wi-Fi SSID,将“my-pass”替换为您的 Wi-Fi 密码,将 192.168.1.254 替换为您的默认网关地址。
谢谢你们。