{"id":254520,"date":"2022-10-19T08:58:34","date_gmt":"2022-10-19T00:58:34","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=254520"},"modified":"2022-10-13T09:08:37","modified_gmt":"2022-10-13T01:08:37","slug":"modifiy-ubuntu-address","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/modifiy-ubuntu-address.html","title":{"rendered":"\u5982\u4f55\u7528\u547d\u4ee4\u884c\u5728Ubuntu20.04\u4fee\u6539\u7cfb\u7edfIP\u5730\u5740"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u5982\u4f55\u7528\u547d\u4ee4\u884c\u5728Ubuntu20.04\u4fee\u6539\u7cfb\u7edfIP\u5730\u5740 <\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\"\"<\/p>\n

1. \u4fee\u6539\u914d\u7f6e\u6587\u4ef6<\/strong><\/div>\n

\u6253\u5f00 \u914d\u7f6eIP\u7684\u6587\u4ef6 \u8def\u5f84\u5982\u4e0b<\/p>\n

sudo vi \/etc\/netplan\/01-network-manager-all.yaml<\/pre>\n
1.1 \u8f93\u5165\uff08\u4fee\u6539\uff09\u4ee5\u4e0b\u5185\u5bb9<\/strong><\/span><\/div>\n
# This is the network config written by 'subiquity'\r\nnetwork:\r\n  ethernets:\r\n    ens0:\r\n      dhcp4: false\r\n      addresses: [192.168.1.123\/24]\r\n      gateway4: 192.168.1.1\r\n    ens1:\r\n      dhcp4: false\r\n      addresses: [192.168.1.124\/24]\r\n      gateway4: 192.168.1.1\r\n  version: 2\r\n<\/pre>\n

\u6ce8\u610f\uff1a \u8fd9\u662f\u4fee\u6539\u4e3a\u9759\u6001IP\u7684\u65b9\u5f0f\uff0c\u6240\u4ee5\u4e0a\u9762\u7684 DHCP4\uff1a\u6700\u597d\u6539\u6210 FALSE\uff0c\u9632\u6b62\u81ea\u52a8\u83b7\u53d6IP\uff0c\u5bfc\u81f4IP\u53c8\u53d8\u4e86<\/p>\n

1.2 \u793a\u4f8b\u5982\u4e0b<\/strong><\/span><\/div>\n

\"\"<\/p>\n

1.3 \u66f4\u65b0\u7f51\u7edc\u8bbe\u7f6e<\/strong><\/span><\/div>\n
\/etc\/init.d\/openibd restart<\/pre>\n
2. \u547d\u4ee4\u884c\u4fee\u6539 ifconfig - route<\/strong><\/span><\/div>\n

\u6839\u636eifconfig \u547d\u4ee4\uff0c\u8fd9\u4e2a\u547d\u4ee4\u4e00\u822c\u7cfb\u7edf\u81ea\u5e26\uff0c\u4e5f\u53ef\u4ee5\u540e\u671f\u5b89\u88c5
\nsudo apt install net-tools<\/p>\n

2.1 \u5148\u627e\u5230\u9700\u8981\u4fee\u6539\u7684\u7f51\u5361<\/strong><\/span><\/div>\n
ifconfig<\/pre>\n

\"\"<\/p>\n

2.2 \u8f93\u5165\u8bbe\u7f6eIP\u547d\u4ee4<\/strong><\/span><\/div>\n
sudo ifconfig ens33 192.168.1.123\/24 up\r\n<\/pre>\n

\u5927\u4f53\u683c\u5f0f\u5982\u4e0b\uff1a
\nsudo\u6743\u9650 ifconfig \u7f51\u5361\u540d IP\u5730\u5740\/\u63a9\u7801 up<\/p>\n

2.3 \u8f93\u5165\u8bbe\u7f6e\u7f51\u5173\u547d\u4ee4<\/strong><\/span><\/div>\n
sudo route add default gw 192.168.1.1\r\n<\/pre>\n

\u683c\u5f0f\uff1a
\nsudo\u6743\u9650 route add default gw \u7f51\u5173\u5730\u5740\n<\/p>\n

1.3 \u66f4\u65b0\u7f51\u7edc\u8bbe\u7f6e<\/strong><\/span><\/div>\n

-- ifconfig \u4fee\u6539 -- end --<\/p>\n

\u7531\u4e8e ifconfig \u5728Ubuntu \u91cc\u5927\u90e8\u5206\u662f\u901a\u8fc7\u540e\u671f\u5b89\u88c5 net-tools \u5305\uff0c\u5b89\u88c5\u4e0a\u7684 \uff0c\u521a\u5b89\u88c5\u5b8c\u7684\u7cfb\u7edf\u53ef\u80fd\u6ca1\u6709\u8fd9\u4e2a net-tools \u5305\uff0c\u6240\u4ee5 ifconfig \u547d\u4ee4\u65e0\u6cd5\u4f7f\u7528
\n \u4f46 ip \u547d\u4ee4\u662f \u81ea\u5e26\u7684<\/p>\n

3. \u547d\u4ee4\u884c\u4fee\u6539 ip link - ip route<\/strong><\/div>\n
3.1 \u627e\u5230\u9700\u8981\u8bbe\u7f6e\u7684\u7f51\u5361<\/strong><\/span><\/div>\n
ip a \u6216 ip addr<\/pre>\n

\"\"<\/p>\n

(\u4e00\u6bdb\u4e00\u6837\uff0c\u6bd5\u7adf\u662f\u4e00\u4e2a\u547d\u4ee4.....\u54c8\u54c8\uff09<\/p>\n

3.2 \u8bbe\u7f6eip\u5730\u5740 \u53ca \u8def\u7531<\/strong><\/span><\/div>\n
ip link set eth0 up # eth0 \u662f\u524d\u9762\u7684 \u7f51\u5361\u7aef\u53e3\u540d\r\nip link show eth0 # \u8fd9\u4e2a eth0 \u4e5f\u662f\r\nip addr add  dev eth0 # \u8fd9\u4e2a\u4e5f\u662f\r\nip route add default via <\u7f51\u5173>\r\n<\/pre>\n

-- ip link - ip route -- end --<\/p>\n<\/p>\n<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"

\u6253\u5f00 \u914d\u7f6eIP\u7684\u6587\u4ef6 \u8def\u5f84\u5982\u4e0b sudo vi \/etc\/netplan\/01-network-manager […]<\/p>\n","protected":false},"author":310,"featured_media":254528,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-254520","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\/254520","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\/310"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=254520"}],"version-history":[{"count":5,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/254520\/revisions"}],"predecessor-version":[{"id":254530,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/254520\/revisions\/254530"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/254528"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=254520"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=254520"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=254520"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}