netplan 配置 wifi

1. 首先安装程序

sudo apt-get install wpasupplicant
sudo apt-get install network-manager

2. 查看无线网卡名

ifconfig -a

ip a

找到无线网卡: wlan0

3. 配置无线网卡节点

sudo vi /etc/netplan/50-cloud-init.yaml

格式需要严格缩进

# This file is generated from information provided by the datasource.  Changes
# to it will not persist across an instance reboot.  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:
        renderer: NetworkManager
        ethernets:
                eth0:
                        dhcp4: true
                        optional: true
        wifis:
                wlan0:
                        dhcp4: true
                        access-points:
                                "HUAWEI-00452L":
                                        password: "Abcd1234"

        version: 2

network:
    renderer: NetworkManager
    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"
解释说明 `/24` 含义

4. 重启网络

sudo netplan generate
sudo netplan apply

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容