{"id":116301,"date":"2018-08-31T08:47:28","date_gmt":"2018-08-31T00:47:28","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=116301"},"modified":"2018-08-24T09:28:14","modified_gmt":"2018-08-24T01:28:14","slug":"linux-cmd-new","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/linux-cmd-new.html","title":{"rendered":"ifconfig\u5df2\u8fc7\u65f6\uff0c\u6765\u770b\u770b\u73b0\u5728\u7684\u65b0\u547d\u4ee4\uff01"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nLinux\u7684ip\u547d\u4ee4\u548cifconfig\u7c7b\u4f3c\uff0c\u4f46\u524d\u8005\u529f\u80fd\u66f4\u5f3a\u5927\uff0c\u5e76\u65e8\u5728\u53d6\u4ee3\u540e\u8005\u3002\u4f7f\u7528ip\u547d\u4ee4\uff0c\u53ea\u9700\u4e00\u4e2a\u547d\u4ee4\uff0c\u4f60\u5c31\u80fd\u5f88\u8f7b\u677e\u5730\u6267\u884c\u4e00\u4e9b\u7f51\u7edc\u7ba1\u7406\u4efb\u52a1\u3002ifconfig\u662fnet-tools\u4e2d\u5df2\u88ab\u5e9f\u5f03\u4f7f\u7528\u7684\u4e00\u4e2a\u547d\u4ee4\uff0c\u8bb8\u591a\u5e74\u524d\u5c31\u5df2\u7ecf\u6ca1\u6709\u7ef4\u62a4\u4e86\u3002iproute2\u5957\u4ef6\u91cc\u63d0\u4f9b\u4e86\u8bb8\u591a\u589e\u5f3a\u529f\u80fd\u7684\u547d\u4ee4\uff0cip\u547d\u4ee4\u5373\u662f\u5176\u4e2d\u4e4b\u4e00\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\"\"<\/p>\n

\u8981\u5b89\u88c5ip\uff0c\u8fd9\u91cc\u4e0b\u8f7diproute2\u5957\u88c5\u5de5\u5177 \u3002\u4e0d\u8fc7\uff0c\u5927\u591a\u6570Linux\u53d1\u884c\u7248\u5df2\u7ecf\u9884\u88c5\u4e86iproute2\u5de5\u5177\u3002<\/p>\n

\u4f60\u4e5f\u53ef\u4ee5\u4f7f\u7528git\u547d\u4ee4\u6765\u4e0b\u8f7d\u6700\u65b0\u6e90\u4ee3\u7801\u6765\u7f16\u8bd1:<\/p>\n

$ git clone https:\/\/kernel.googlesource.com\/pub\/scm\/linux\/kernel\/git\/shemminger\/iproute2.git<\/pre>\n

\"\"<\/p>\n

\u8bbe\u7f6e\u548c\u5220\u9664Ip\u5730\u5740<\/strong><\/div>\n

\u8981\u7ed9\u4f60\u7684\u673a\u5668\u8bbe\u7f6e\u4e00\u4e2aIP\u5730\u5740\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e0b\u5217ip\u547d\u4ee4:<\/p>\n

$ sudo ip addr add 192.168.0.193\/24 dev wlan0<\/pre>\n

\u8bf7\u6ce8\u610fIP\u5730\u5740\u8981\u6709\u4e00\u4e2a\u540e\u7f00\uff0c\u6bd4\u5982\/24\u3002\u8fd9\u79cd\u7528\u6cd5\u7528\u4e8e\u5728\u65e0\u7c7b\u57df\u5185\u8def\u7531\u9009\u62e9\uff08CIDR\uff09\u4e2d\u6765\u663e\u793a\u6240\u7528\u7684\u5b50\u7f51\u63a9\u7801\u3002\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u5b50\u7f51\u63a9\u7801\u662f255.255.255.0\u3002<\/p>\n

\u5728\u4f60\u6309\u7167\u4e0a\u8ff0\u65b9\u5f0f\u8bbe\u7f6e\u597dIP\u5730\u5740\u540e\uff0c\u9700\u8981\u67e5\u770b\u662f\u5426\u5df2\u7ecf\u751f\u6548.<\/p>\n

$ ip addr show wlan0<\/pre>\n

\"\"<\/p>\n

\u4f60\u4e5f\u53ef\u4ee5\u4f7f\u7528\u76f8\u540c\u7684\u65b9\u5f0f\u6765\u5220\u9664IP\u5730\u5740\uff0c\u53ea\u9700\u7528del\u4ee3\u66ffadd.<\/p>\n

$ sudo ip addr del 192.168.0.193\/24 dev wlan0<\/pre>\n

\"\"<\/p>\n

\u5217\u51fa\u8def\u7531\u8868\u6761\u76ee<\/strong><\/div>\n

ip\u547d\u4ee4\u7684\u8def\u7531\u5bf9\u8c61\u7684\u53c2\u6570\u8fd8\u53ef\u4ee5\u5e2e\u52a9\u4f60\u67e5\u770b\u7f51\u7edc\u4e2d\u7684\u8def\u7531\u6570\u636e\uff0c\u5e76\u8bbe\u7f6e\u4f60\u7684\u8def\u7531\u8868\u3002\u7b2c\u4e00\u4e2a\u6761\u76ee\u662f\u9ed8\u8ba4\u7684\u8def\u7531\u6761\u76ee\uff0c\u4f60\u53ef\u4ee5\u968f\u610f\u6539\u52a8\u5b83\u3002<\/p>\n

\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6709\u51e0\u4e2a\u8def\u7531\u6761\u76ee\u3002\u8fd9\u4e2a\u7ed3\u679c\u663e\u793a\u6709\u51e0\u4e2a\u8bbe\u5907\u901a\u8fc7\u4e0d\u540c\u7684\u7f51\u7edc\u63a5\u53e3\u8fde\u63a5\u8d77\u6765\u3002\u5b83\u4eec\u5305\u62ecWIFI\u3001\u4ee5\u592a\u7f51\u548c\u4e00\u4e2a\u70b9\u5bf9\u70b9\u8fde\u63a5.<\/p>\n

$ ip route show<\/pre>\n

\"\"<\/p>\n

\u5047\u8bbe\u73b0\u5728\u4f60\u6709\u4e00\u4e2aIP\u5730\u5740\uff0c\u4f60\u9700\u8981\u77e5\u9053\u8def\u7531\u5305\u4ece\u54ea\u91cc\u6765\u3002\u53ef\u4ee5\u4f7f\u7528\u4e0b\u9762\u7684\u8def\u7531\u9009\u9879\uff08\u8bd1\u6ce8\uff1a\u5217\u51fa\u4e86\u8def\u7531\u6240\u4f7f\u7528\u7684\u63a5\u53e3\u7b49\uff09:<\/p>\n

$ ip route get 10.42.0.47<\/pre>\n

\"\"<\/p>\n

\u66f4\u6539\u9ed8\u8ba4\u8def\u7531<\/strong><\/div>\n

\u8981\u66f4\u6539\u9ed8\u8ba4\u8def\u7531\uff0c\u4f7f\u7528\u4e0b\u9762ip\u547d\u4ee4<\/p>\n

$ sudo ip route add default via 192.168.0.196<\/pre>\n
\u663e\u793a\u7f51\u7edc\u7edf\u8ba1\u6570\u636e<\/strong><\/div>\n

\u4f7f\u7528ip\u547d\u4ee4\u8fd8\u53ef\u4ee5\u663e\u793a\u4e0d\u540c\u7f51\u7edc\u63a5\u53e3\u7684\u7edf\u8ba1\u6570\u636e\u3002<\/p>\n

\"\"<\/p>\n

\u5f53\u4f60\u9700\u8981\u83b7\u53d6\u4e00\u4e2a\u7279\u5b9a\u7f51\u7edc\u63a5\u53e3\u7684\u4fe1\u606f\u65f6\uff0c\u5728\u7f51\u7edc\u63a5\u53e3\u540d\u5b57\u540e\u9762\u6dfb\u52a0\u9009\u9879ls\u5373\u53ef\u3002\u4f7f\u7528\u591a\u4e2a\u9009\u9879-s\u4f1a\u7ed9\u4f60\u8fd9\u4e2a\u7279\u5b9a\u63a5\u53e3\u66f4\u8be6\u7ec6\u7684\u4fe1\u606f\u3002\u7279\u522b\u662f\u5728\u6392\u9664\u7f51\u7edc\u8fde\u63a5\u6545\u969c\u65f6\uff0c\u8fd9\u4f1a\u975e\u5e38\u6709\u7528.<\/p>\n

$ ip -s -s link ls p2p1<\/pre>\n

\"\"<\/p>\n

ARP\u6761\u76ee<\/strong><\/div>\n

\u5730\u5740\u89e3\u6790\u534f\u8bae\uff08ARP\uff09\u7528\u4e8e\u5c06\u4e00\u4e2aIP\u5730\u5740\u8f6c\u6362\u6210\u5b83\u5bf9\u5e94\u7684\u7269\u7406\u5730\u5740\uff0c\u4e5f\u5c31\u662f\u901a\u5e38\u6240\u8bf4\u7684MAC\u5730\u5740\u3002\u4f7f\u7528ip\u547d\u4ee4\u7684neigh\u6216\u8005neighbour\u9009\u9879\uff0c\u4f60\u53ef\u4ee5\u67e5\u770b\u63a5\u5165\u4f60\u6240\u5728\u7684\u5c40\u57df\u7f51\u7684\u8bbe\u5907\u7684MAC\u5730\u5740.<\/p>\n

$ ip neighbour<\/pre>\n

\"\"<\/p>\n

\u76d1\u63a7netlink\u6d88\u606f<\/strong><\/div>\n

\u4e5f\u53ef\u4ee5\u4f7f\u7528ip\u547d\u4ee4\u67e5\u770bnetlink\u6d88\u606f\u3002monitor\u9009\u9879\u5141\u8bb8\u4f60\u67e5\u770b\u7f51\u7edc\u8bbe\u5907\u7684\u72b6\u6001\u3002\u6bd4\u5982\uff0c\u6240\u5728\u5c40\u57df\u7f51\u7684\u4e00\u53f0\u7535\u8111\u6839\u636e\u5b83\u7684\u72b6\u6001\u53ef\u4ee5\u88ab\u5206\u7c7b\u6210REACHABLE\u6216\u8005STALE\u3002\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4:<\/p>\n

$ ip monitor all<\/pre>\n

\"\"<\/p>\n

\u6fc0\u6d3b\u548c\u505c\u6b62\u7f51\u7edc\u63a5\u53e3<\/strong><\/div>\n

\u4f60\u53ef\u4ee5\u4f7f\u7528ip\u547d\u4ee4\u7684up\u548cdown\u9009\u9879\u6765\u6fc0\u67d0\u4e2a\u7279\u5b9a\u7684\u63a5\u53e3\uff0c\u5c31\u50cfifconfig\u7684\u7528\u6cd5\u4e00\u6837\u3002<\/p>\n

\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u5f53ppp0\u63a5\u53e3\u88ab\u6fc0\u6d3b\u548c\u5728\u5b83\u88ab\u505c\u6b62\u548c\u518d\u6b21\u6fc0\u6d3b\u4e4b\u540e\uff0c\u4f60\u53ef\u4ee5\u770b\u5230\u76f8\u5e94\u7684\u8def\u7531\u8868\u6761\u76ee\u3002\u8fd9\u4e2a\u63a5\u53e3\u53ef\u80fd\u662fwlan0\u6216\u8005eth0\u3002\u5c06ppp0\u66f4\u6539\u4e3a\u4f60\u53ef\u7528\u7684\u4efb\u610f\u63a5\u53e3\u5373\u53ef.<\/p>\n

$ sudo ip link set ppp0 down<\/pre>\n
$ sudo ip link set ppp0 up<\/pre>\n

\"\"<\/p>\n

\u83b7\u53d6\u5e2e\u52a9<\/strong><\/div>\n

\u5f53\u4f60\u9677\u5165\u56f0\u5883\uff0c\u4e0d\u77e5\u9053\u67d0\u4e00\u4e2a\u7279\u5b9a\u7684\u9009\u9879\u600e\u4e48\u7528\u7684\u65f6\u5019\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528help\u9009\u9879\u3002man\u9875\u9762\u5e76\u4e0d\u4f1a\u63d0\u4f9b\u8bb8\u591a\u5173\u4e8e\u5982\u4f55\u4f7f\u7528ip\u9009\u9879\u7684\u4fe1\u606f\uff0c\u56e0\u6b64\u8fd9\u91cc\u5c31\u662f\u83b7\u53d6\u5e2e\u52a9\u7684\u5730\u65b9\u3002<\/p>\n

\u6bd4\u5982\uff0c\u60f3\u77e5\u9053\u5173\u4e8eroute\u9009\u9879\u66f4\u591a\u7684\u4fe1\u606f:<\/p>\n

$ ip route help<\/pre>\n

\"\"<\/p>\n

\u5c0f\u7ed3<\/strong><\/div>\n

\u5bf9\u4e8e\u7f51\u7edc\u7ba1\u7406\u5458\u4eec\u548c\u6240\u6709\u7684Linux\u4f7f\u7528\u8005\u4eec\uff0cip\u547d\u4ee4\u662f\u5fc5\u5907\u5de5\u5177\u3002\u662f\u65f6\u5019\u629b\u5f03ifconfig\u547d\u4ee4\u4e86\uff0c\u7279\u522b\u662f\u5f53\u4f60\u5199\u811a\u672c\u65f6\u3002<\/p>\n

\n

\u539f\u6587\u6765\u81ea\uff1ahttp:\/\/linoxide.com\/linux-command\/use-ip-command-linux\/<\/a><\/p>\n

\u672c\u6587\u5730\u5740\uff1ahttps:\/\/lrxjmw.cn\/linux-cmd-new.html<\/a>\u7f16\u8f91\uff1a\u6731\u57f9\u68cb\uff0c\u5ba1\u6838\u5458\uff1a\u9004\u589e\u5b9d<\/span><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"

\u5bfc\u8bfb Linux\u7684ip\u547d\u4ee4\u548cifconfig\u7c7b\u4f3c\uff0c\u4f46\u524d\u8005\u529f\u80fd\u66f4\u5f3a\u5927\uff0c\u5e76\u65e8\u5728\u53d6\u4ee3\u540e\u8005\u3002\u4f7f\u7528ip\u547d\u4ee4\uff0c\u53ea\u9700\u4e00\u4e2a\u547d\u4ee4 […]<\/p>\n","protected":false},"author":63,"featured_media":116306,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-116301","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\/116301","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\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=116301"}],"version-history":[{"count":12,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/116301\/revisions"}],"predecessor-version":[{"id":117047,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/116301\/revisions\/117047"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/116306"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=116301"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=116301"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=116301"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}