{"id":150,"date":"2025-08-26T20:52:56","date_gmt":"2025-08-26T12:52:56","guid":{"rendered":"https:\/\/www.mooloco.com\/?p=150"},"modified":"2025-09-05T10:21:57","modified_gmt":"2025-09-05T02:21:57","slug":"networkmanager","status":"publish","type":"post","link":"https:\/\/www.mooloco.com\/?p=150","title":{"rendered":"NetworkManager"},"content":{"rendered":"\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_75 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.mooloco.com\/?p=150\/#%E6%A6%82%E5%BF%B5\" >\u6982\u5ff5<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.mooloco.com\/?p=150\/#%E7%BB%99%E7%BD%91%E5%8D%A1%E9%85%8D%E7%BD%AE%E9%9D%99%E6%80%81IP%E5%9C%B0%E5%9D%80\" >\u7ed9\u7f51\u5361\u914d\u7f6e\u9759\u6001IP\u5730\u5740<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.mooloco.com\/?p=150\/#%E9%87%8D%E5%90%AF%E7%BD%91%E5%8D%A1\" >\u91cd\u542f\u7f51\u5361<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.mooloco.com\/?p=150\/#%E6%81%A2%E5%A4%8D_DHCP%E8%87%AA%E5%8A%A8%E8%8E%B7%E5%8F%96IP\" >\u6062\u590d DHCP\u81ea\u52a8\u83b7\u53d6IP<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%A6%82%E5%BF%B5\"><\/span>\u6982\u5ff5<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728NetworkManager\u91cc\uff0c\u6709\u4e24\u4e2a\u975e\u5e38\u91cd\u8981\u7684\u6982\u5ff5\u3002\u57fa\u672c\u4e0a\uff0c\u7406\u6e05\u695a\u8fd9\u4e24\u4e2a\u6982\u5ff5\u5bf9\u5e94\u7684\u542b\u4e49\u548c\u533a\u522b\uff0c\u5269\u4e0b\u7684\u901a\u8fc7\u6587\u6863\u5c31\u53ef\u4ee5\u975e\u5e38\u5bb9\u6613\u7684\u638c\u63e1NetworkManager\u7684\u4f7f\u7528\u4e86\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7b2c\u4e00\u4e2a\u6982\u5ff5\u662f<em>device<\/em>\uff0c\u4e5f\u5c31\u662f\u8bbe\u5907\uff0c\u600e\u4e48\u7406\u89e3\u5462\uff0c\u4e00\u4e2a\u8bbe\u5907\u5bf9\u5e94\u4e00\u4e2a\u7f51\u53e3\uff0c\u57fa\u672c\u4e0a<code>ip link<\/code>\u91cc\u770b\u5230\u7684\u90a3\u4e9b\u90fd\u6709\u5bf9\u5e94\u7684\u8bbe\u5907\uff0c\u57fa\u672c\u4e0a\u53ef\u4ee5\u8ba4\u4e3a\u5c31\u662f\u7269\u7406\u7684\u7f51\u5361\uff0c\u6bcf\u4e2a\u7269\u7406\u7f51\u5361\u90fd\u4f1a\u662f\u4e00\u4e2a<em>device<\/em>\uff0c\u5f53\u7136\uff0c\u6709\u4e9b\u865a\u62df\u7684\u7f51\u5361\uff0c\u4e5f\u4f1a\u662f\u4e00\u4e2a<em>device<\/em>\uff0c\u6bd4\u5982\u7f51\u6865bridge\u7b49\u3002\u5f53\u7136\u4e5f\u6709\u4e9b\u533a\u522b\uff0c\u7269\u7406\u7f51\u5361\u662f\u73b0\u5b9e\u5b58\u5728\u7684\u8bbe\u5907\uff0c\u672c\u8d28\u4e0a\u6700\u7ec8\u662fNetworkManager\u6765\u7ba1\u7406\u5b83\uff0c\u800c\u865a\u62df\u673a\u7f51\u5361\u5c31\u662fNetworkManager\u56e0\u4e3a\u8fde\u63a5\u9700\u8981\u800c\u751f\u6210\u7684\u7f51\u5361\u3002\u4f7f\u7528<code>nmcli device<\/code>\u547d\u4ee4\uff0c\u53ef\u4ee5\u770b\u5230\u5f53\u524dNetworkManager\u6240\u8bc6\u522b\u7684\u8bbe\u5907\uff0c\u4ee5\u53ca\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n- \u8fd9\u4e2a\u8bbe\u5907\u662f\u5426\u5728NetworkManager\u7684\u7ba1\u7406\u4e4b\u4e0b\n- \u8bbe\u5907\u6240\u5bf9\u5e94\u7684\u8fde\u63a5\u914d\u7f6e\u4fe1\u606f\n- \u8bbe\u5907\u5f53\u524d\u7684\u8fde\u63a5\u914d\u7f6e\n\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">\u4e3e\u4e2a\u4f8b\u5b50\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;root@localhost ~]# nmcli device\nDEVICE  TYPE      STATE      CONNECTION\neth0    ethernet  connected  eth0\nlo      loopback  unmanaged  --\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">\u53ef\u4ee5\u5f88\u660e\u786e\u7684\u770b\u5230\u6211\u8fd9\u53f0\u673a\u5668\u6709\u4e24\u4e2a\u8bbe\u5907\uff0c\u5206\u522b\u662f<code>eth0<\/code>\u548c<code>lo<\/code>\uff0c\u5176\u4e2d<code>eth0<\/code>\u662f\u4ee5\u592a\u7f51\u7c7b\u578b\uff0c\u88abNetworkManager\u7ba1\u7406\u4e14\u5bf9\u5e94\u7684\u8fde\u63a5\u914d\u7f6e\u4e3a<code>eth0<\/code>\uff0c\u800c<code>lo<\/code>\u662floopback\uff0c\u76ee\u524d\u4e0d\u88abNetworkManager\u6240\u7ba1\u7406\u3002\u5728\u7ec8\u7aef\u91cc\u6267\u884c\uff0c\u6b63\u5e38\u7684\u8bbe\u5907\u4f1a\u663e\u793a\u7eff\u8272\uff0c\u4e0d\u6b63\u5e38\u7684\u8bbe\u5907\u663e\u793a\u6210\u7ea2\u8272\uff0c\u4e0d\u88ab\u7ba1\u7406\u7684\u663e\u793a\u4e3a\u7070\u8272\uff0c\u8fd8\u662f\u5f88\u6e05\u6670\u7684\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u53e6\u5916\u4e00\u4e2a\u6982\u5ff5\u662f<em>connection<\/em>\uff0c\u4e5f\u5c31\u662f\u8fde\u63a5\u3002\u600e\u4e48\u7406\u89e3\u5462\uff0c\u8fde\u63a5\u5c31\u662f\u4e00\u7cfb\u5217\u914d\u7f6e\uff0c\u6bd4\u5982IP\u5730\u5740\u83b7\u53d6\u65b9\u5f0f\u662fDHCP\u6216\u8005\u624b\u52a8\u914d\u7f6e\uff0c\u5982\u679c\u662f\u624b\u52a8\u914d\u7f6e\uff0c\u5219\u914d\u7f6e\u54ea\u4e9bIP\u5730\u5740\uff0c\u7f51\u5173\uff0cDNS\u7b49\u7b49\u4fe1\u606f\uff0c\u8fd9\u4e9b\u914d\u7f6e\u975e\u5e38\u7684\u591a\uff0c\u5c31\u4e0d\u4e00\u4e00\u7ec6\u8bf4\u4e86\uff0c\u5177\u4f53\u7684\u770b\u6587\u6863\u5c31\u597d\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u8fde\u63a5\u662f\u9700\u8981\u6700\u7ec8\u88abapply\u5230\u67d0\u4e2a<em>device<\/em>\u4e0a\u7684\uff0c\u800c\u4e14\u9488\u5bf9\u540c\u4e00\u4e2a<em>device<\/em>\uff0c\u53ef\u4ee5\u6709\u591a\u4e2a<em>connection<\/em>\u3002\u4f46\u662f\uff0c\u5728\u4efb\u610f\u65f6\u523b\uff0c\u6709\u4e14\u53ea\u80fd\u6709\u4e00\u4e2a\u6d3b\u52a8\u7684<em>connection<\/em>\u88abapply\u5230\u4e00\u4e2a<em>device<\/em>\u3002\u6709\u70b9\u7ed5\uff0c\u4f46\u662f\u601d\u8003\u4e00\u4e0b\u8fd9\u4e2a\u573a\u666f\u5c31\u5f88\u5bb9\u6613\u7406\u89e3\u4e86\uff1a\u9488\u5bf9\u7b14\u8bb0\u672c\u7684\u65e0\u7ebf\u7f51\u5361\uff0c\u5728\u516c\u53f8\uff0c\u8fde\u63a5\u7684\u81ea\u7136\u662f\u516c\u53f8\u7684WIFI\uff0c\u8fd9\u5c31\u9700\u8981\u4e00\u4e2a<em>connection<\/em>\uff0c\u5230\u4e86\u5bb6\u91cc\uff0c\u53c8\u9700\u8981\u8fde\u63a5\u5bb6\u91cc\u7684WIFI\uff0c\u8fd9\u5c31\u662f\u53e6\u5916\u4e00\u4e2a<em>connection<\/em>\uff0c\u8fd9\u4fe9\u90fd\u662f\u9488\u5bf9\u540c\u4e00\u4e2a<em>device<\/em>\u7684\u914d\u7f6e\uff0c\u4e5f\u4e0d\u4f1a\u540c\u65f6\u8d77\u4f5c\u7528\u3002\u5176\u5b9e\u8fd9\u4e2a\u573a\u666f\u5728\u670d\u52a1\u5668\u4e0a\u4e0d\u592a\u5e38\u89c1\uff0c\u6240\u4ee5\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u670d\u52a1\u5668\u4e0a\u57fa\u672c\u5c31\u53ef\u4ee5\u914d\u7f6e\u6210\u4e00\u4e2a<em>connection<\/em>\u5bf9\u5e94\u4e00\u4e2a<em>device<\/em>\u5c31\u89e3\u51b3\u4e86\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5f04\u660e\u767d\u8fd9\u4fe9\u8005\u4e4b\u95f4\u7684\u5173\u7cfb\uff0c\u5f88\u591a\u4e1c\u897f\u5c31\u5f88\u987a\u7545\u4e86\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E7%BB%99%E7%BD%91%E5%8D%A1%E9%85%8D%E7%BD%AE%E9%9D%99%E6%80%81IP%E5%9C%B0%E5%9D%80\"><\/span>\u7ed9\u7f51\u5361\u914d\u7f6e\u9759\u6001IP\u5730\u5740<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">NetworkManager\u4f7f\u7528nmcli\u8fd9\u4e2a\u547d\u4ee4\u6765\u914d\u7f6e\u7cfb\u7edf\u7684\u7f51\u5361<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u53ef\u4ee5\u901a\u8fc7<code>nmcli connection show<\/code>\u67e5\u770b\u5f53\u524d\u7684\u94fe\u63a5<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"569\" height=\"77\" src=\"https:\/\/www.mooloco.com\/wp-content\/uploads\/2025\/08\/image-23.png\" alt=\"\" class=\"wp-image-151\" srcset=\"https:\/\/www.mooloco.com\/wp-content\/uploads\/2025\/08\/image-23.png 569w, https:\/\/www.mooloco.com\/wp-content\/uploads\/2025\/08\/image-23-300x41.png 300w\" sizes=\"(max-width: 569px) 100vw, 569px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u5047\u8bbe\u7f51\u5361\u662fens33\uff0c\u4f60\u8981\u8bbe\u7f6e\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>IP\uff1a<code>192.168.1.100<\/code><\/li>\n\n\n\n<li>\u5b50\u7f51\u63a9\u7801\uff1a<code>255.255.255.0<\/code><\/li>\n\n\n\n<li>\u7f51\u5173\uff1a<code>192.168.1.1<\/code><\/li>\n\n\n\n<li>DNS\uff1a<code>8.8.8.8<\/code><\/li>\n<\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nnmcli connection modify ens33 ipv4.addresses 192.168.1.100\/24   #\u5730\u5740\u548c\u5b50\u7f51\u63a9\u7801\nnmcli connection modify ens33 ipv4.gateway 192.168.1.1  #\u7f51\u5173\nnmcli connection modify ens33 ipv4.dns &quot;8.8.8.8 114.114.114.114&quot;   #  DNS\u670d\u52a1\u5668\nnmcli connection modify ens33 ipv4.method manual    #  \u9759\u6001IP\u6a21\u5f0f\nnmcli connection modify ens33 connection.autoconnect yes  #\u81ea\u52a8\u542f\u52a8\u8fde\u63a5\u7f51\u5361\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u89c9\u5f97\u4ee5\u4e0a\u592a\u590d\u6742\uff0c\u53ef\u4ee5\u7528\u4e00\u6761\u547d\u4ee4\u5b8c\u6210<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nnmcli con mod ens33 ipv4.addresses 192.168.1.100\/24 ipv4.gateway 192.168.1.1 ipv4.dns 8.8.8.8 ipv4.method manual\nnmcli con up ens33\n\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\"><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E9%87%8D%E5%90%AF%E7%BD%91%E5%8D%A1\"><\/span>\u91cd\u542f\u7f51\u5361<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nnmcli connection down ens33   #\u505c\u7528\u7f51\u5361\nnmcli connection up ens33  #  \u542f\u7528\u7f51\u5361\nnmcli connection modify ens33 connection.autoconnect yes   # \u8bbe\u7f6e\u5f00\u673a\u81ea\u542f\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%81%A2%E5%A4%8D_DHCP%E8%87%AA%E5%8A%A8%E8%8E%B7%E5%8F%96IP\"><\/span>\u6062\u590d DHCP\u81ea\u52a8\u83b7\u53d6IP<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nnmcli connection modify ens33 ipv4.method auto\nnmcli connection up ens33\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u5ff5 \u5728NetworkManager\u91cc\uff0c\u6709\u4e24\u4e2a\u975e\u5e38\u91cd\u8981\u7684\u6982\u5ff5\u3002\u57fa\u672c\u4e0a\uff0c\u7406\u6e05\u695a\u8fd9\u4e24\u4e2a\u6982\u5ff5\u5bf9\u5e94\u7684\u542b\u4e49\u548c\u533a\u522b\uff0c\u5269\u4e0b\u7684<\/p>\n<div class=\"more-link\">\n\t\t\t\t <a href=\"https:\/\/www.mooloco.com\/?p=150\" class=\"link-btn theme-btn\"><span>Read More <\/span> <i class=\"fa fa-caret-right\"><\/i><\/a>\n\t\t\t<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-150","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.mooloco.com\/index.php?rest_route=\/wp\/v2\/posts\/150","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mooloco.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mooloco.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mooloco.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mooloco.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=150"}],"version-history":[{"count":4,"href":"https:\/\/www.mooloco.com\/index.php?rest_route=\/wp\/v2\/posts\/150\/revisions"}],"predecessor-version":[{"id":258,"href":"https:\/\/www.mooloco.com\/index.php?rest_route=\/wp\/v2\/posts\/150\/revisions\/258"}],"wp:attachment":[{"href":"https:\/\/www.mooloco.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=150"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mooloco.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=150"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mooloco.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=150"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}