用的是server版本,所以要用过ssh来配置。
从此认识了yaml这个语言,有史以来用过最烂的语言,没有之一。
# This file is generated from information provided by
# the datasource. Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
ethernets:
eth0:
dhcp4: true
optional: true
wifis:
wlan0:
dhcp4: false
addresses: [192.168.1.101/24]
gateway4: 192.168.1.1
nameservers:
addresses: [192.168.1.1]
optional: true
access-points:
"xxxxx":
password: "xxxxx"
version: 2
wifi的配置文件为/etc/netplan/50-cloud-init.yaml
这种语言严格缩进,而且是空格缩进,而且这个配置里面需要有上下父子关系,更奇葩的是,冒号后代表列表内容,必须有个空格!!!
改这个脚本用了快半个小时!!!
网上的资料看着多,欣喜若狂的用,个个有坑,个个格式一动就洗白,所以最后用的官方参考。
可以搜到wifi段落,参考着来。
本来想偷懒写个转载,结果非得逼得写个原创。。
再更:
以上还是不好使,这个比上个强点:
按步来就行。