{"id":3193,"date":"2019-06-25T13:23:06","date_gmt":"2019-06-25T05:23:06","guid":{"rendered":"https:\/\/www.linuxcool.com\/?p=3193"},"modified":"2022-05-29T14:07:22","modified_gmt":"2022-05-29T06:07:22","slug":"nmcli","status":"publish","type":"post","link":"https:\/\/www.linuxcool.com\/nmcli","title":{"rendered":"nmcli\u547d\u4ee4 – \u57fa\u4e8e\u547d\u4ee4\u884c\u914d\u7f6e\u7f51\u5361\u53c2\u6570"},"content":{"rendered":"\n

nmcli\u547d\u4ee4\u6765\u81ea\u4e8e\u82f1\u6587\u8bcd\u7ec4\u201cNetworkManager command-line\u201d\u7684\u7f29\u5199\uff0c\u5176\u529f\u80fd\u662f\u7528\u4e8e\u57fa\u4e8e\u547d\u4ee4\u884c\u914d\u7f6e\u7f51\u5361\u53c2\u6570\u3002nmcli\u4e0enmtui\u547d\u4ee4\u5de5\u5177\u914d\u7f6e\u8fc7\u7684\u53c2\u6570\u4f1a\u76f4\u63a5\u5199\u5165\u5230\u7f51\u5361\u670d\u52a1\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u6c38\u4e45\u751f\u6548\u3002<\/p>\n\n\n\n

\u8bed\u6cd5\u683c\u5f0f\uff1a<\/strong>nmcli [\u53c2\u6570]<\/p>\n\n\n\n

\u5e38\u7528\u53c2\u6570\uff1a<\/strong><\/p>\n\n\n\n

d<\/td>\u76d1\u63a7\u548c\u7ba1\u7406\u7f51\u7edc\u8bbe\u5907\u7684\u63a5\u53e3<\/td><\/tr>
c<\/td>\u76d1\u63a7\u548c\u7ba1\u7406\u7f51\u7edc\u8bbe\u5907\u7684\u8fde\u63a5<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n

\u53c2\u8003\u5b9e\u4f8b<\/strong><\/p>\n\n\n\n

\u663e\u793a\u6240\u6709\u7f51\u7edc\u8fde\u63a5\u7684\u5217\u8868\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# nmcli con show<\/strong>\r\nNAME    UUID                                  TYPE      DEVICE \r\nens160  1136e9fc-4549-4737-b9e5-86e8250f2b5d  ethernet  ens160\r\nvirbr0  8065a10b-356e-439a-a55f-ccb965059640  bridge    virbr0<\/pre>\n\n\n\n

\u663e\u793a\u6240\u6709\u7f51\u7edc\u8fde\u63a5\u7684\u8be6\u7ec6\u4fe1\u606f\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# nmcli device show <\/strong>\r\nGENERAL.DEVICE:                         ens160\r\nGENERAL.TYPE:                           ethernet\r\nGENERAL.HWADDR:                         00:0C:29:22:31:9C\r\nGENERAL.MTU:                            1500\r\nGENERAL.STATE:                          100 (connected)\r\nGENERAL.CONNECTION:                     ens160\r\n\u2026\u2026\u2026\u2026\u2026\u2026\u7701\u7565\u90e8\u5206\u8f93\u51fa\u4fe1\u606f\u2026\u2026\u2026\u2026\u2026\u2026<\/pre>\n\n\n\n

\u5bf9\u6307\u5b9a\u7f51\u5361\u521b\u5efa\u4e00\u4e2a\u7f51\u7edc\u4f1a\u8bdd\u8fde\u63a5\uff0c\u7f51\u5361\u53c2\u6570\u7531DHCP\u670d\u52a1\u83b7\u53d6\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# nmcli connection add con-name house type ethernet ifname ens160<\/strong>\r\nConnection 'house' (d848242a-4bdf-4446-9079-6e12ab5d1f15) successfully added.<\/pre>\n\n\n\n

\u5bf9\u6307\u5b9a\u7f51\u5361\u521b\u5efa\u4e00\u4e2a\u7f51\u7edc\u4f1a\u8bdd\u8fde\u63a5\uff0c\u7f51\u5361\u53c2\u6570\u7531\u624b\u52a8\u6307\u5b9a\u914d\u7f6e\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# nmcli connection add con-name company ifname ens160 autoconnect no type ethernet ip4 192.168.10.10\/24 gw4 192.168.10.1<\/strong>\nConnection 'company' (6ac8f3ad-0846-42f4-819a-e1ae84f4da86) successfully added.<\/pre>\n\n\n\n

\u5bf9\u4e00\u4e2a\u6307\u5b9a\u7684\u7f51\u7edc\u4f1a\u8bdd\u8fde\u63a5\u6dfb\u52a0DNS\u5730\u5740\u53c2\u6570\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# nmcli connection modify company ipv4.dns 8.8.8.8<\/strong>\n<\/pre>\n","protected":false},"excerpt":{"rendered":"

nmcli\u547d\u4ee4\u6765\u81ea\u4e8e\u82f1\u6587\u8bcd\u7ec4\u201cNetworkManager command-line\u201d\u7684\u7f29\u5199\uff0c\u5176\u529f\u80fd\u662f\u7528\u4e8e\u57fa\u4e8e […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/3193"}],"collection":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/comments?post=3193"}],"version-history":[{"count":10,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/3193\/revisions"}],"predecessor-version":[{"id":10184,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/3193\/revisions\/10184"}],"wp:attachment":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/media?parent=3193"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/categories?post=3193"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/tags?post=3193"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}