{"id":118094,"date":"2018-08-28T09:49:57","date_gmt":"2018-08-28T01:49:57","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=118094"},"modified":"2018-08-28T09:49:57","modified_gmt":"2018-08-28T01:49:57","slug":"nmcli-4-linux-wifi","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/nmcli-4-linux-wifi.html","title":{"rendered":"\u4f7f\u7528Nmcli\u547d\u4ee4\u4eceLinux\u7ec8\u7aef\u8fde\u63a5WiFi"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nnmcli\u662f\u4e00\u4e2a\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u7528\u4e8e\u521b\u5efa\uff0c\u663e\u793a\uff0c\u7f16\u8f91\uff0c\u5220\u9664\uff0c\u542f\u7528\u548c\u7981\u7528\u7f51\u7edc\u8fde\u63a5\uff0c\u4ee5\u53ca\u63a7\u5236\u548c\u663e\u793a\u7f51\u7edc\u8bbe\u5907\u72b6\u6001\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\n
\n

\"\"<\/p>\n

\u5728Linux\u7cfb\u7edf\u4e2d\u6709\u51e0\u79cd\u7528\u4e8e\u7ba1\u7406\u65e0\u7ebf\u7f51\u7edc\u63a5\u53e3\u7684\u547d\u4ee4\u884c\u5de5\u5177\u3002\u00a0\u5176\u4e2d\u7684\u4e00\u4e9b\u53ef\u7528\u4e8e\u7b80\u5355\u67e5\u770b\u65e0\u7ebf\u7f51\u7edc\u63a5\u53e3\u72b6\u6001\uff08\u65e0\u8bba\u662f\u542f\u52a8<\/strong>\u8fd8\u662f\u5173\u95ed<\/strong>\u00a0\uff0c\u6216\u8005\u662f\u5426\u8fde\u63a5\u5230\u4efb\u4f55\u7f51\u7edc\uff09\uff0c\u5982iw<\/strong>\u00a0\uff0c\u00a0iwlist<\/strong>\u00a0\uff0c\u00a0ip\u00a0\uff0c\u00a0ifconfig\u7b49\u3002<\/p>\n

\u5176\u4e2d\u4e00\u4e9b\u7528\u4e8e\u8fde\u63a5\u65e0\u7ebf\u7f51\u7edc\uff0c\u5176\u4e2d\u5305\u62ec\uff1a\u00a0nmcli\u00a0\uff0c\u662f\u7528\u4e8e\u521b\u5efa\uff0c\u663e\u793a\uff0c\u7f16\u8f91\uff0c\u5220\u9664\uff0c\u542f\u7528\u548c\u7981\u7528\u7f51\u7edc\u8fde\u63a5\u4ee5\u53ca\u63a7\u5236\u548c\u663e\u793a\u7f51\u7edc\u8bbe\u5907\u72b6\u6001\u7684\u547d\u4ee4\u884c\u5de5\u5177\u3002<\/p>\n

\u9996\u5148\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u68c0\u67e5\u7f51\u7edc\u8bbe\u5907\u7684\u540d\u79f0\u3002\u00a0\u4ece\u8be5\u547d\u4ee4\u7684\u8f93\u51fa\u4e2d\uff0c\u8bbe\u5907\u540d\u79f0\/\u63a5\u53e3\u662fwlp1s0<\/strong>\u00a0\uff0c\u5982\u56fe\u6240\u793a\u3002<\/p>\n

$ iw dev<\/span><\/strong>\r\nphy<\/span>#0<\/span>\r\nInterface<\/span> wlp1s0<\/span><\/strong>\r\nifindex <\/span>3<\/span>\r\nwdev <\/span>0x1<\/span>\r\naddr <\/span>38<\/span>:<\/span>b1<\/span>:<\/span>db<\/span>:<\/span>7c<\/span>:<\/span>78<\/span>:<\/span>c7\r\ntype managed<\/span><\/pre>\n

\u63a5\u4e0b\u6765\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u68c0\u67e5Wi-Fi\u8bbe\u5907\u8fde\u63a5\u72b6\u6001\u3002<\/p>\n

iw wlp2s0 link<\/span><\/strong>\r\nNot<\/span> connected<\/span>.<\/span><\/strong>\r\n<\/pre>\n

\u4ece\u8bbe\u5907\u4e0a\u65b9\u7684\u8f93\u51fa\u672a\u8fde\u63a5\u5230\u4efb\u4f55\u7f51\u7edc\uff0c\u8bf7\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u626b\u63cf\u53ef\u7528\u7684Wi-Fi\u7f51\u7edc\u3002<\/p>\n

sudo iw wlp2s0 scan<\/span><\/strong>\r\ncommand failed<\/span>:<\/span> Network<\/span> is<\/span> down <\/span>(-<\/span>100<\/span>)<\/span><\/strong>\r\n<\/pre>\n

\u8003\u8651\u5230\u4e0a\u8ff0\u547d\u4ee4\u7684\u8f93\u51fa\uff0c\u7f51\u7edc\u8bbe\u5907\/\u63a5\u53e3\u5904\u4e8eDOWN\u72b6\u6001<\/strong>\u00a0\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528ip\u547d\u4ee4<\/a>\u5c06\u5176\u6253\u5f00<\/strong>\u00a0\uff08UP<\/strong>\u00a0\uff09\uff0c\u5982\u56fe\u6240\u793a\u3002<\/p>\n

$ sudo ip link <\/span>set<\/span> wlp1s0 up<\/span><\/pre>\n

\u5982\u679c\u51fa\u73b0\u4ee5\u4e0b\u9519\u8bef\uff0c\u8fd9\u610f\u5473\u7740\u60a8\u7684Wifi\u5728\u7b14\u8bb0\u672c\u7535\u8111\u6216\u8ba1\u7b97\u673a\u4e0a\u5f88\u96be\u88ab\u5c4f\u853d\u3002<\/p>\n

RTNETLINK answers<\/span>:<\/span> Operation<\/span> not<\/span> possible due to RF<\/span>-<\/span>kill<\/span><\/pre>\n

\u8981\u5220\u9664\u6216\u53d6\u6d88\u963b\u6b62\uff0c\u60a8\u9700\u8981\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u89e3\u51b3\u9519\u8bef\u3002<\/p>\n

$ echo <\/span>\"blacklist hp_wmi\"<\/span> |<\/span> sudo tee <\/span>\/<\/span>etc<\/span>\/<\/span>modprobe<\/span>.<\/span>d<\/span>\/<\/span>hp<\/span>.<\/span>conf\r\n$ sudo rfkill unblock all<\/span><\/pre>\n

\u7136\u540e\u5c1d\u8bd5\u518d\u6b21\u6253\u5f00<\/strong>\u7f51\u7edc\u8bbe\u5907\uff0c\u5e76\u4e14\u8fd9\u6b21\u5e94\u8be5\u53ef\u4ee5\u5de5\u4f5c\u3002<\/p>\n

$ sudo ip link <\/span>set<\/span> wlp1s0 up<\/span><\/pre>\n

\u5982\u679c\u60a8\u77e5\u9053\u8981\u8fde\u63a5\u7684Wi-Fi\u7f51\u7edc\u7684ESSID<\/strong>\u00a0\uff0c\u8bf7\u8f6c\u81f3\u4e0b\u4e00\u6b65\uff0c\u5426\u5219\u8bf7\u53d1\u51fa\u4ee5\u4e0b\u547d\u4ee4\u4ee5\u518d\u6b21\u626b\u63cf\u53ef\u7528\u7684Wi-Fi\u7f51\u7edc\u3002<\/p>\n

$ sudo iw wlp1s0 scan<\/span><\/pre>\n

\u6700\u540e\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fde\u63a5\u5230Wi-Fi\u7f51\u7edc\uff0c\u5176\u4e2dHackernet<\/strong>\u00a0\uff08Wi-Fi\u7f51\u7edcSSID\uff09\u548clocalhost22<\/strong>\u00a0\uff08\u5bc6\u7801\/\u9884\u5171\u4eab\u5bc6\u94a5\uff09\u3002<\/p>\n

$ nmcli dev wifi connect <\/span>Hackernet<\/span> password localhost22<\/span><\/pre>\n

\u8fde\u63a5\u540e\uff0c\u901a\u8fc7\u5bf9\u5916\u90e8\u8ba1\u7b97\u673a\u6267\u884cping\u64cd\u4f5c\u6765\u9a8c\u8bc1\u8fde\u63a5\uff0c\u5e76\u5982\u56fe\u6240\u793a\u5206\u6790ping\u7684\u8f93\u51fa\u3002<\/p>\n

$ ping <\/span>8.8<\/span>.<\/span>8.8<\/span><\/strong>\r\nPING <\/span>8.8<\/span>.<\/span>8.8<\/span> (<\/span>8.8<\/span>.<\/span>8.8<\/span>)<\/span> 56<\/span>(<\/span>84<\/span>)<\/span> bytes of data<\/span>.<\/span>\r\n64<\/span> bytes <\/span>from<\/span> 8.8<\/span>.<\/span>8.8<\/span>:<\/span> icmp_seq<\/span>=<\/span>1<\/span> ttl<\/span>=<\/span>48<\/span> time<\/span>=<\/span>61.7<\/span> ms\r\n<\/span>64<\/span> bytes <\/span>from<\/span> 8.8<\/span>.<\/span>8.8<\/span>:<\/span> icmp_seq<\/span>=<\/span>2<\/span> ttl<\/span>=<\/span>48<\/span> time<\/span>=<\/span>61.5<\/span> ms\r\n<\/span>64<\/span> bytes <\/span>from<\/span> 8.8<\/span>.<\/span>8.8<\/span>:<\/span> icmp_seq<\/span>=<\/span>3<\/span> ttl<\/span>=<\/span>48<\/span> time<\/span>=<\/span>61.6<\/span> ms\r\n<\/span>64<\/span> bytes <\/span>from<\/span> 8.8<\/span>.<\/span>8.8<\/span>:<\/span> icmp_seq<\/span>=<\/span>4<\/span> ttl<\/span>=<\/span>48<\/span> time<\/span>=<\/span>61.3<\/span> ms\r\n<\/span>64<\/span> bytes <\/span>from<\/span> 8.8<\/span>.<\/span>8.8<\/span>:<\/span> icmp_seq<\/span>=<\/span>5<\/span> ttl<\/span>=<\/span>48<\/span> time<\/span>=<\/span>63.9<\/span> ms\r\n<\/span>^<\/span>C\r\n<\/span>---<\/span> 8.8<\/span>.<\/span>8.8<\/span> ping statistics <\/span>---<\/span>\r\n5<\/span> packets transmitted<\/span>,<\/span> 5<\/span> received<\/span>,<\/span> 0<\/span>%<\/span> packet loss<\/span>,<\/span> time <\/span>4006ms<\/span>\r\nrtt min<\/span>\/<\/span>avg<\/span>\/<\/span>max<\/span>\/<\/span>mdev <\/span>=<\/span> 61.338<\/span>\/<\/span>62.047<\/span>\/<\/span>63.928<\/span>\/<\/span>0.950<\/span> ms<\/span><\/pre>\n

\u800c\u5df2\uff01\u00a0\u6211\u5e0c\u671b\u8fd9\u7bc7\u6587\u7ae0\u80fd\u5e2e\u52a9\u4f60\u4eceLinux\u547d\u4ee4\u884c\u8bbe\u7f6e\u4f60\u7684Wi-Fi<\/strong>\u7f51\u7edc\u3002\u00a0\u4e0e\u5f80\u5e38\u4e00\u6837\uff0c\u5982\u679c\u60a8\u53d1\u73b0\u8fd9\u7bc7\u6587\u7ae0\u6709\u7528\uff0c\u8bf7\u5728\u4e0b\u9762\u7684\u8bc4\u8bba\u90e8\u5206\u5206\u4eab\u60a8\u7684\u60f3\u6cd5\u3002<\/p>\n<\/div>\n<\/div>\n

\n

\u539f\u6587\u6765\u81ea\uff1ahttps:\/\/www.howtoing.com\/nmcli-connect-wi-fi-from-linux-terminal<\/a><\/p>\n

\u672c\u6587\u5730\u5740\uff1ahttps:\/\/lrxjmw.cn\/nmcli-4-linux-wifi.html<\/a>\u7f16\u8f91\uff1a\u502a\u5bb6\u5174\uff0c\u5ba1\u6838\u5458\uff1a\u9004\u589e\u5b9d<\/span><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"

\u5bfc\u8bfb nmcli\u662f\u4e00\u4e2a\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u7528\u4e8e\u521b\u5efa\uff0c\u663e\u793a\uff0c\u7f16\u8f91\uff0c\u5220\u9664\uff0c\u542f\u7528\u548c\u7981\u7528\u7f51\u7edc\u8fde\u63a5\uff0c\u4ee5\u53ca\u63a7\u5236\u548c\u663e\u793a\u7f51\u7edc\u8bbe\u5907\u72b6\u6001\u3002 […]<\/p>\n","protected":false},"author":362,"featured_media":118107,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-118094","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\/118094","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\/362"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=118094"}],"version-history":[{"count":4,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/118094\/revisions"}],"predecessor-version":[{"id":118156,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/118094\/revisions\/118156"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/118107"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=118094"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=118094"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=118094"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}