{"id":212157,"date":"2021-03-03T09:26:33","date_gmt":"2021-03-03T01:26:33","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=212157"},"modified":"2021-02-23T16:29:31","modified_gmt":"2021-02-23T08:29:31","slug":"ifconfig-ip","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/ifconfig-ip.html","title":{"rendered":"\u653e\u5f03 ifconfig\uff0c\u62e5\u62b1 ip \u547d\u4ee4"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u5728\u5f88\u957f\u4e00\u6bb5\u65f6\u95f4\u5185\uff0cifconfig \u547d\u4ee4\u662f\u914d\u7f6e\u7f51\u7edc\u63a5\u53e3\u7684\u9ed8\u8ba4\u65b9\u6cd5\u3002\u5b83\u4e3a Linux \u7528\u6237\u63d0\u4f9b\u4e86\u5f88\u597d\u7684\u670d\u52a1\uff0c\u4f46\u662f\u7f51\u7edc\u5f88\u590d\u6742\uff0c\u6240\u4ee5\u914d\u7f6e\u7f51\u7edc\u7684\u547d\u4ee4\u5fc5\u987b\u5065\u58ee\u3002ip \u547d\u4ee4\u662f\u73b0\u4ee3\u7cfb\u7edf\u4e2d\u65b0\u7684\u9ed8\u8ba4\u7f51\u7edc\u547d\u4ee4\uff0c\u5728\u672c\u6587\u4e2d\uff0c\u6211\u5c06\u5411\u4f60\u5c55\u793a\u5982\u4f55\u4f7f\u7528\u5b83.<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\"\"<\/a><\/p>\n
\u5f00\u59cb\u4f7f\u7528\u73b0\u4ee3\u65b9\u6cd5\u914d\u7f6e Linux \u7f51\u7edc\u63a5\u53e3\u3002<\/strong><\/div>\n

\u5728\u5f88\u957f\u4e00\u6bb5\u65f6\u95f4\u5185\uff0cifconfig<\/span>\u00a0\u547d\u4ee4\u662f\u914d\u7f6e\u7f51\u7edc\u63a5\u53e3\u7684\u9ed8\u8ba4\u65b9\u6cd5\u3002\u5b83\u4e3a Linux \u7528\u6237\u63d0\u4f9b\u4e86\u5f88\u597d\u7684\u670d\u52a1\uff0c\u4f46\u662f\u7f51\u7edc\u5f88\u590d\u6742\uff0c\u6240\u4ee5\u914d\u7f6e\u7f51\u7edc\u7684\u547d\u4ee4\u5fc5\u987b\u5065\u58ee\u3002ip<\/code>\u00a0\u547d\u4ee4\u662f\u73b0\u4ee3\u7cfb\u7edf\u4e2d\u65b0\u7684\u9ed8\u8ba4\u7f51\u7edc\u547d\u4ee4\uff0c\u5728\u672c\u6587\u4e2d\uff0c\u6211\u5c06\u5411\u4f60\u5c55\u793a\u5982\u4f55\u4f7f\u7528\u5b83\u3002ip\u00a0<\/span>\u547d\u4ee4\u5de5\u4f5c\u5728\u00a0OSI \u7f51\u7edc\u6808<\/a>\u00a0\u7684\u4e24\u4e2a\u5c42\u4e0a\uff1a\u7b2c\u4e8c\u5c42\uff08\u6570\u636e\u94fe\u8def\u5c42\uff09\u548c\u7b2c\u4e09\u5c42\uff08\u7f51\u7edc \u6216 IP\uff09\u5c42\u3002\u5b83\u505a\u4e86\u4e4b\u524d\u00a0net-tools<\/code>\u00a0\u5305\u7684\u6240\u6709\u5de5\u4f5c\u3002<\/p>\n

\u5b89\u88c5 ip <\/strong><\/span><\/div>\n

ip\u00a0<\/span>\u547d\u4ee4\u5305\u542b\u5728\u00a0iproute2util\u00a0<\/span>\u5305\u4e2d\uff0c\u5b83\u53ef\u80fd\u5df2\u7ecf\u5728\u4f60\u7684 Linux \u53d1\u884c\u7248\u4e2d\u5b89\u88c5\u4e86\u3002\u5982\u679c\u6ca1\u6709\uff0c\u4f60\u53ef\u4ee5\u4ece\u53d1\u884c\u7248\u7684\u4ed3\u5e93\u4e2d\u8fdb\u884c\u5b89\u88c5\u3002<\/p>\n

ifconfig \u548c ip \u4f7f\u7528\u5bf9\u6bd4<\/strong><\/span><\/div>\n

ip\u00a0\u548c\u00a0ifconfig\u00a0\u547d\u4ee4\u90fd\u53ef\u4ee5\u7528\u6765\u914d\u7f6e\u7f51\u7edc\u63a5\u53e3\uff0c\u4f46\u5b83\u4eec\u505a\u4e8b\u65b9\u6cd5\u4e0d\u540c\u3002\u63a5\u4e0b\u6765\uff0c\u4f5c\u4e3a\u5bf9\u6bd4\uff0c\u6211\u5c06\u7528\u5b83\u4eec\u6765\u6267\u884c\u4e00\u4e9b\u5e38\u89c1\u7684\u4efb\u52a1\u3002<\/p>\n

\u67e5\u770b\u7f51\u53e3\u548c IP \u5730\u5740<\/strong><\/span><\/div>\n

\u5982\u679c\u4f60\u60f3\u67e5\u770b\u4e3b\u673a\u7684 IP \u5730\u5740\u6216\u7f51\u7edc\u63a5\u53e3\u4fe1\u606f\uff0cifconfig\u00a0\uff08\u4e0d\u5e26\u4efb\u4f55\u53c2\u6570\uff09\u547d\u4ee4\u63d0\u4f9b\u4e86\u4e00\u4e2a\u5f88\u597d\u7684\u603b\u7ed3\u3002<\/p>\n

\r\n$ ifconfig\r\neth0: flags=4099 mtu 1500\r\nether bc:ee:7b:5e:7d:d8 txqueuelen 1000 (Ethernet)\r\nRX packets 0 bytes 0 (0.0 B)\r\nRX errors 0 dropped 0 overruns 0 frame 0\r\nTX packets 0 bytes 0 (0.0 B)\r\nTX errors 0 dropped 0 overruns 0 carrier 0 collisions 0\r\nlo: flags=73 mtu 65536\r\ninet 127.0.0.1 netmask 255.0.0.0\r\ninet6 ::1 prefixlen 128 scopeid 0x10\r\nloop txqueuelen 1000 (Local Loopback)\r\nRX packets 41 bytes 5551 (5.4 KiB)\r\nRX errors 0 dropped 0 overruns 0 frame 0\r\nTX packets 41 bytes 5551 (5.4 KiB)\r\nTX errors 0 dropped 0 overruns 0 carrier 0 collisions 0\r\nwlan0: flags=4163 mtu 1500\r\ninet 10.1.1.6 netmask 255.255.255.224 broadcast 10.1.1.31\r\ninet6 fdb4:f58e:49f:4900:d46d:146b:b16:7212 prefixlen 64 scopeid 0x0\r\ninet6 fe80::8eb3:4bc0:7cbb:59e8 prefixlen 64 scopeid 0x20\r\nether 08:71:90:81:1e:b5 txqueuelen 1000 (Ethernet)\r\nRX packets 569459 bytes 779147444 (743.0 MiB)\r\nRX errors 0 dropped 0 overruns 0 frame 0\r\nTX packets 302882 bytes 38131213 (36.3 MiB)\r\nTX errors 0 dropped 0 overruns 0 carrier 0 collisions 0<\/global><\/host><\/pre>\n

\u65b0\u7684\u00a0ip\u00a0\u547d\u4ee4\u63d0\u4f9b\u4e86\u7c7b\u4f3c\u7684\u7ed3\u679c\uff0c\u4f46\u547d\u4ee4\u662f\u00a0ip address show\uff0c\u6216\u8005\u7b80\u5199\u4e3a\u00a0ip a:<\/p>\n

\r\n$ ip a\r\n1: lo:  mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000\r\nlink\/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00\r\ninet 127.0.0.1\/8 scope host lo\r\nvalid_lft forever preferred_lft forever\r\ninet6 ::1\/128 scope host\r\nvalid_lft forever preferred_lft forever\r\n2: eth0:  mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000\r\nlink\/ether bc:ee:7b:5e:7d:d8 brd ff:ff:ff:ff:ff:ff\r\n3: wlan0:  mtu 1500 qdisc noqueue state UP group default qlen 1000\r\nlink\/ether 08:71:90:81:1e:b5 brd ff:ff:ff:ff:ff:ff\r\ninet 10.1.1.6\/27 brd 10.1.1.31 scope global dynamic wlan0\r\nvalid_lft 83490sec preferred_lft 83490sec\r\ninet6 fdb4:f58e:49f:4900:d46d:146b:b16:7212\/64 scope global noprefixroute dynamic\r\nvalid_lft 6909sec preferred_lft 3309sec\r\ninet6 fe80::8eb3:4bc0:7cbb:59e8\/64 scope link\r\nvalid_lft forever preferred_lft forever<\/pre>\n
\u6dfb\u52a0 IP \u5730\u5740<\/strong><\/span><\/div>\n

\u4f7f\u7528\u00a0ifconfig\u00a0\u547d\u4ee4\u6dfb\u52a0 IP \u5730\u5740\u547d\u4ee4\u4e3a\uff1a<\/p>\n

$ ifconfig eth0 add 192.9.203.21<\/pre>\n

ip\u00a0\u7c7b\u4f3c\uff1a<\/p>\n

$ ip address add 192.9.203.21 dev eth0<\/pre>\n

ip\u00a0\u4e2d\u7684\u5b50\u547d\u4ee4\u53ef\u4ee5\u7f29\u77ed\uff0c\u6240\u4ee5\u4e0b\u9762\u8fd9\u4e2a\u547d\u4ee4\u540c\u6837\u6709\u6548\uff1a<\/p>\n

$ ip addr add 192.9.203.21 dev eth0<\/pre>\n

\u4f60\u751a\u81f3\u53ef\u4ee5\u66f4\u77ed\u4e9b\uff1a<\/p>\n

$ ip a add 192.9.203.21 dev eth0<\/pre>\n
\u79fb\u9664\u4e00\u4e2a IP \u5730\u5740<\/strong><\/span><\/div>\n

\u6dfb\u52a0 IP \u5730\u5740\u4e0e\u5220\u9664 IP \u5730\u5740\u6b63\u597d\u76f8\u53cd\u3002<\/p>\n

\u4f7f\u7528\u00a0ifconfig\uff0c\u547d\u4ee4\u662f\uff1a<\/p>\n

$ ifconfig eth0 del 192.9.203.21<\/pre>\n

ip\u00a0\u547d\u4ee4\u7684\u8bed\u6cd5\u662f\uff1a<\/p>\n

$ ip a del 192.9.203.21 dev eth0<\/pre>\n
\u542f\u7528\u6216\u7981\u7528\u7ec4\u64ad<\/strong><\/span><\/div>\n

\u4f7f\u7528\u00a0ifconfig\u00a0\u63a5\u53e3\u6765\u542f\u7528\u6216\u7981\u7528\u00a0\u7ec4\u64admulticast\uff1a<\/p>\n

# ifconfig eth0 multicast<\/pre>\n

\u5bf9\u4e8e\u00a0ip\uff0c\u4f7f\u7528\u00a0set\u00a0\u5b50\u547d\u4ee4\u4e0e\u8bbe\u5907\uff08dev\uff09\u4ee5\u53ca\u4e00\u4e2a\u5e03\u5c14\u503c\u548c\u00a0multicast\u00a0\u9009\u9879\uff1a<\/p>\n

# ip link set dev eth0 multicast on<\/pre>\n
\u542f\u7528\u6216\u7981\u7528\u7f51\u7edc<\/strong><\/span><\/div>\n

\u6bcf\u4e2a\u7cfb\u7edf\u7ba1\u7406\u5458\u90fd\u719f\u6089\u201c\u5148\u5173\u95ed\uff0c\u7136\u540e\u6253\u5f00\u201d\u8fd9\u4e2a\u6280\u5de7\u6765\u89e3\u51b3\u95ee\u9898\u3002\u5bf9\u4e8e\u7f51\u7edc\u63a5\u53e3\u6765\u8bf4\uff0c\u5373\u6253\u5f00\u6216\u5173\u95ed\u7f51\u7edc\u3002<\/p>\n

ifconfig\u00a0\u547d\u4ee4\u4f7f\u7528\u00a0up\u00a0\u6216\u00a0down\u00a0\u5173\u952e\u5b57\u6765\u5b9e\u73b0\uff1a<\/p>\n

# ifconfig eth0 up<\/pre>\n

\u6216\u8005\u4f60\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e2a\u4e13\u7528\u547d\u4ee4\uff1a<\/p>\n

# ifup eth0<\/pre>\n

ip\u00a0\u547d\u4ee4\u4f7f\u7528\u00a0set\u00a0\u5b50\u547d\u4ee4\u5c06\u7f51\u7edc\u8bbe\u7f6e\u4e3a\u00a0up\u00a0\u6216\u00a0down\u00a0\u72b6\u6001\uff1a<\/p>\n

# ip link set eth0 up<\/pre>\n
\u5f00\u542f\u6216\u5173\u95ed\u5730\u5740\u89e3\u6790\u529f\u80fd\uff08ARP\uff09<\/strong><\/span><\/div>\n

\u4f7f\u7528\u00a0ifconfig\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u58f0\u660e\u5b83\u6765\u542f\u7528\uff1a<\/p>\n

# ifconfig eth0 arp<\/pre>\n

\u4f7f\u7528\u00a0ip\uff0c\u4f60\u53ef\u4ee5\u5c06\u00a0arp\u00a0\u5c5e\u6027\u8bbe\u7f6e\u4e3a\u00a0on\u00a0\u6216\u00a0off\uff1a<\/p>\n

# ip link set dev eth0 arp on<\/pre>\n<\/div>\n","protected":false},"excerpt":{"rendered":"

\u5728\u5f88\u957f\u4e00\u6bb5\u65f6\u95f4\u5185\uff0c\u00a0\u547d\u4ee4\u662f\u914d\u7f6e\u7f51\u7edc\u63a5\u53e3\u7684\u9ed8\u8ba4\u65b9\u6cd5\u3002\u5b83\u4e3a Linux \u7528\u6237\u63d0\u4f9b\u4e86\u5f88\u597d\u7684\u670d\u52a1\uff0c\u4f46\u662f\u7f51\u7edc\u5f88\u590d\u6742\uff0c\u6240\u4ee5 […]<\/p>\n","protected":false},"author":643,"featured_media":212162,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-212157","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\/212157","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\/643"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=212157"}],"version-history":[{"count":3,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/212157\/revisions"}],"predecessor-version":[{"id":212160,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/212157\/revisions\/212160"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/212162"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=212157"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=212157"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=212157"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}