\u6b65\u9aa4 2\uff1a\u7f16\u8f91 Netplan \u914d\u7f6e\u6587\u4ef6\u4e2d\u7684 wifi \u63a5\u53e3\u8be6\u7ec6\u4fe1\u606f<\/strong><\/span><\/div>\nNetplan \u914d\u7f6e\u6587\u4ef6\u5728 \/etc\/netplan \u76ee\u5f55\u4e0b\u3002\u5982\u679c\u4f60\u67e5\u770b\u8fd9\u4e2a\u76ee\u5f55\u7684\u5185\u5bb9\uff0c\u4f60\u5e94\u8be5\u770b\u5230\u7c7b\u4f3c 01-network-manager-all.yml \u6216 50-cloud-init.yaml \u7b49\u6587\u4ef6\u3002<\/p>\n
\u5982\u679c\u662f Ubuntu \u670d\u52a1\u5668\uff0c\u4f60\u5e94\u8be5\u6709 50-cloud-init.yaml \u6587\u4ef6\u3002\u5982\u679c\u662f\u684c\u9762\u8ba1\u7b97\u673a\uff0c\u5e94\u8be5\u662f 01-network-manager-all.yml \u6587\u4ef6\u3002<\/p>\n
Linux \u684c\u9762\u8ba1\u7b97\u673a\u7684 Network Manager \u5141\u8bb8\u4f60\u9009\u62e9\u4e00\u4e2a\u65e0\u7ebf\u7f51\u7edc\u3002\u4f60\u53ef\u4ee5\u5728\u5b83\u7684\u914d\u7f6e\u4e2d\u786c\u7f16\u7801\u5199\u5165 WiFi \u63a5\u5165\u70b9\u3002\u8fd9\u53ef\u4ee5\u5728\u81ea\u52a8\u6389\u7ebf\u7684\u60c5\u51b5\u4e0b\uff08\u6bd4\u5982\u6302\u8d77\uff09\u65f6\u5e2e\u52a9\u5230\u4f60\u3002<\/p>\n
\u4e0d\u7ba1\u662f\u54ea\u4e2a\u6587\u4ef6\uff0c\u90fd\u53ef\u4ee5\u6253\u5f00\u7f16\u8f91\u3002\u6211\u5e0c\u671b\u4f60\u5bf9 Nano \u7f16\u8f91\u5668\u6709\u4e00\u70b9\u719f\u6089\uff0c\u56e0\u4e3a Ubuntu \u9884\u88c5\u4e86\u5b83\u3002<\/p>\n
\r\nsudo nano \/etc\/netplan\/50-cloud-init.yaml \r\n<\/pre>\nYAML \u6587\u4ef6\u5bf9\u7a7a\u683c\u3001\u7f29\u8fdb\u548c\u5bf9\u9f50\u65b9\u5f0f\u975e\u5e38\u654f\u611f\u3002\u4e0d\u8981\u4f7f\u7528\u5236\u8868\u7b26\uff0c\u5728\u770b\u5230\u7f29\u8fdb\u7684\u5730\u65b9\u4f7f\u7528 4 \u4e2a\u7a7a\u683c\uff08\u6216 2 \u4e2a\uff0c\u4ee5 YAML \u6587\u4ef6\u4e2d\u5df2\u7ecf\u4f7f\u7528\u7684\u4e3a\u51c6\uff09\u4ee3\u66ff\u3002<\/p>\n
\u57fa\u672c\u4e0a\uff0c\u4f60\u9700\u8981\u6dfb\u52a0\u4ee5\u4e0b\u51e0\u884c\uff0c\u5f15\u53f7\u4e2d\u662f\u63a5\u5165\u70b9\u540d\u79f0\uff08SSID\uff09 \u548c\u5bc6\u7801\uff08\u901a\u5e38\uff09\uff1a<\/p>\n
\r\nwifis: \r\n wlan0: \r\n dhcp4: true \r\n optional: true \r\n access-points: \r\n \"SSID_name\": \r\n password: \"WiFi_password\" \r\n<\/pre>\n\u518d\u8bf4\u4e00\u6b21\uff0c\u4fdd\u6301\u6211\u6240\u5c55\u793a\u7684\u5bf9\u9f50\u65b9\u5f0f\uff0c\u5426\u5219 YAML \u6587\u4ef6\u4e0d\u80fd\u88ab\u89e3\u6790\uff0c\u5b83\u4f1a\u629b\u51fa\u4e00\u4e2a\u9519\u8bef\u3002<\/p>\n
\u4f60\u7684\u5b8c\u6574\u914d\u7f6e\u6587\u4ef6\u53ef\u80fd\u662f\u8fd9\u6837\u7684\uff1a<\/p>\n
\r\n# This file is generated from information provided by the datasource. Changes \r\n# to it will not persist across an instance reboot. To disable cloud-init's \r\n# network configuration capabilities, write a file \r\n# \/etc\/cloud\/cloud.cfg.d\/99-disable-network-config.cfg with the following: \r\n# network: {config: disabled} \r\nnetwork: \r\n ethernets: \r\n eth0: \r\n dhcp4: true \r\n optional: true \r\n version: 2 \r\n wifis: \r\n wlan0: \r\n dhcp4: true \r\n optional: true \r\n access-points: \r\n \"SSID_name\": \r\n password: \"WiFi_password\" \r\n<\/pre>\n\u6211\u89c9\u5f97\u5f88\u5947\u602a\uff0c\u5c3d\u7ba1\u6709\u6d88\u606f\u8bf4\u66f4\u6539\u4e0d\u4f1a\u5728\u5b9e\u4f8b\u91cd\u542f\u540e\u4fdd\u7559\uff0c\u4f46\u5b83\u4ecd\u7136\u53ef\u4ee5\u5de5\u4f5c\u3002<\/p>\n
\u4e0d\u7ba1\u600e\u6837\uff0c\u7528\u8fd9\u4e2a\u547d\u4ee4\u751f\u6210\u914d\u7f6e\uff1a<\/p>\n
\r\nsudo netplan generate \r\n<\/pre>\n\u5982\u679c\u4f60\u5e78\u8fd0\u7684\u8bdd\uff0c\u4f60\u5e94\u8be5\u8fde\u4e0a\u7f51\u7edc\u3002\u5c1d\u8bd5 ping \u4e00\u4e2a\u7f51\u7ad9\u6216\u8fd0\u884c apt \u66f4\u65b0\u547d\u4ee4\u3002<\/p>\n
\u7136\u800c\uff0c\u4e8b\u60c5\u53ef\u80fd\u4e0d\u4f1a\u90a3\u4e48\u987a\u5229\uff0c\u4f60\u53ef\u80fd\u4f1a\u770b\u5230\u4e00\u4e9b\u9519\u8bef\u3002\u5982\u679c\u662f\u8fd9\u79cd\u60c5\u51b5\uff0c\u8bf7\u5c1d\u8bd5\u4e00\u4e9b\u989d\u5916\u7684\u6b65\u9aa4\u3002<\/p>\n
\u53ef\u80fd\u7684\u6545\u969c\u6392\u9664<\/strong><\/div>\n\u5f53\u4f60\u4f7f\u7528 netplan apply \u547d\u4ee4\u65f6\uff0c\u4f60\u6709\u53ef\u80fd\u5728\u8f93\u51fa\u4e2d\u770b\u5230\u7c7b\u4f3c\u8fd9\u6837\u7684\u9519\u8bef\u3002<\/p>\n
\r\nFailed to start netplan-wpa-wlan0.service: Unit netplan-wpa-wlan0.service not found. \r\nTraceback (most recent call last): \r\n File \"\/usr\/sbin\/netplan\", line 23, in \r\n netplan.main() \r\n File \"\/usr\/share\/netplan\/netplan\/cli\/core.py\", line 50, in main \r\n self.run_command() \r\n File \"\/usr\/share\/netplan\/netplan\/cli\/utils.py\", line 179, in run_command \r\n self.func() \r\n File \"\/usr\/share\/netplan\/netplan\/cli\/commands\/apply.py\", line 46, in run \r\n self.run_command() \r\n File \"\/usr\/share\/netplan\/netplan\/cli\/utils.py\", line 179, in run_command \r\n self.func() \r\n File \"\/usr\/share\/netplan\/netplan\/cli\/commands\/apply.py\", line 173, in command_apply \r\n utils.systemctl_networkd('start', sync=sync, extra_services=netplan_wpa) \r\n File \"\/usr\/share\/netplan\/netplan\/cli\/utils.py\", line 86, in systemctl_networkd \r\n subprocess.check_call(command) \r\n File \"\/usr\/lib\/python3.8\/subprocess.py\", line 364, in check_call \r\n raise CalledProcessError(retcode, cmd) \r\nsubprocess.CalledProcessError: Command '['systemctl', 'start', '--no-block', 'systemd-networkd.service', 'netplan-wpa-wlan0.service']' returned non-zero exit status 5. \r\n<\/module><\/pre>\n\u53ef\u80fd\u662f wpa_supplicant \u670d\u52a1\u6ca1\u6709\u8fd0\u884c\u3002\u8fd0\u884c\u8fd9\u4e2a\u547d\u4ee4\uff1a<\/p>\n
\r\nsudo systemctl start wpa_supplicant \r\n<\/pre>\n\u518d\u6b21\u8fd0\u884c netplan apply\u3002\u5982\u679c\u5b83\u80fd\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u90a3\u5c31\u592a\u597d\u4e86\u3002\u5426\u5219\uff0c\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u5173\u95ed Ubuntu \u7cfb\u7edf\uff1a<\/p>\n
\r\nshutdown now \r\n<\/pre>\n\u91cd\u65b0\u542f\u52a8 Ubuntu \u7cfb\u7edf\uff0c\u767b\u5f55\u5e76\u518d\u6b21\u751f\u6210\u548c\u8fd0\u884c netplan apply\uff1a<\/p>\n
\r\nsudo netplan generate \r\nsudo netplan apply \r\n<\/pre>\n\u73b0\u5728\u53ef\u80fd\u4f1a\u663e\u793a\u8b66\u544a\uff08\u800c\u4e0d\u662f\u9519\u8bef\uff09\u3002\u8fd9\u662f\u8b66\u544a\u800c\u4e0d\u662f\u9519\u8bef\u3002\u6211\u68c0\u67e5\u4e86\u6b63\u5728\u8fd0\u884c\u7684 systemd \u670d\u52a1\uff0c\u53d1\u73b0 netplan-wpa-wlan0.service \u5df2\u7ecf\u5728\u8fd0\u884c\u4e86\u3002\u53ef\u80fd\u662f\u56e0\u4e3a\u5b83\u5df2\u7ecf\u5728\u8fd0\u884c\u4e86\uff0c\u800c\u4e14 netplan apply \u66f4\u65b0\u4e86\u914d\u7f6e\u6587\u4ef6\uff08\u5373\u4f7f\u6ca1\u6709\u4efb\u4f55\u6539\u53d8\uff09\uff0c\u6240\u4ee5\u663e\u793a\u4e86\u8b66\u544a\u3002<\/p>\n
\r\nWarning: The unit file, source configuration file or drop-ins of netplan-wpa-wlan0.service changed on disk. Run 'systemctl daemon-reload' to reload units.\r\n<\/pre>\n\u8fd9\u5e76\u4e0d\u91cd\u8981\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u8fd0\u884c apt update \u6765\u68c0\u67e5\u7f51\u7edc\u662f\u5426\u5df2\u7ecf\u6b63\u5e38\u5de5\u4f5c\u3002<\/p>\n
\u6211\u5e0c\u671b\u4f60\u80fd\u591f\u5728\u672c\u6559\u7a0b\u7684\u5e2e\u52a9\u4e0b\uff0c\u5728 Ubuntu \u4e2d\u4f7f\u7528\u547d\u4ee4\u884c\u8fde\u63a5\u5230 WiFi\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"
\u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u4f60\u5c06\u5b66\u4e60\u5982\u4f55\u5728 Ubuntu \u4e2d\u4ece\u7ec8\u7aef\u8fde\u63a5\u5230\u65e0\u7ebf\u7f51\u7edc\u3002\u5982\u679c\u4f60\u5728\u4f7f\u7528 Ubuntu \u670d\u52a1\u5668\u65f6\uff0c\u65e0\u6cd5\u8bbf\u95ee\u5e38\u89c4\u7684\u684c\u9762\u73af\u5883\uff0c\u8fd9\u5c06\u5bf9\u4f60\u975e\u5e38\u6709\u5e2e\u52a9\u3002<\/p>\n","protected":false},"author":370,"featured_media":124395,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-201557","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/201557","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/370"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=201557"}],"version-history":[{"count":3,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/201557\/revisions"}],"predecessor-version":[{"id":201561,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/201557\/revisions\/201561"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/124395"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=201557"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=201557"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=201557"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}