centos动态IP更换静态IP
Last updated
2023-01-18 17:56:04
{"value":"### CentOS \u52a8\u6001IP\u66f4\u6539\u9759\u6001IP\n\n\u8f93\u5165\u547d\u4ee4 ip a\n\n\t[root@ ~]# ip a\n\n\t1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000\n\t\tlink\/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00\n\t\tinet 127.0.0.1\/8 scope host lo\n\t\t valid_lft forever preferred_lft forever\n\t\tinet6 ::1\/128 scope host \n\t\t valid_lft forever preferred_lft forever\n\n\t2: **eth0**: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000\n\t\tlink\/ether fa:2c:c1:7a:a0:00 brd ff:ff:ff:ff:ff:ff\n\t\tinet **xxx.xxx.xxx.xxx**\/24 brd xxx.xxx.xxx.255 scope global noprefixroute eth0\n\t\t valid_lft forever preferred_lft forever\n\t\tinet6 fe80::8cc3:3dc8:b69f:f32f\/64 scope link noprefixroute \n\t\t valid_lft forever preferred_lft forever\n\n\u53ef\u4ee5\u67e5\u770b\u5230\u672c\u673aIP **xxx.xxx.xxx.xxx** \u5728**eth0**\u7f51\u5361\u914d\u7f6e\u6587\u4ef6\u4e2d\n\n\u8f93\u5165\u547d\u4ee4 vi \/etc\/sysconfig\/network-scripts\/ifcfg-eth0\n\n\t[root@ ~]# vi \/etc\/sysconfig\/network-scripts\/ifcfg-eth0 \n\n\tBOOTPROTO=dhcp\n\n\tDEVICE=eth0\n\n\tHWADDR=fa:33:e7:4d:7e:00\n\n\tONBOOT=yes\n\n\tSTARTMODE=auto\n\n\tTYPE=Ethernet\n\n\tUSERCTL=no\n\n\u8f93\u5165 \u201ci\u201d \u8fdb\u5165\u7f16\u8f91\u6a21\u5f0f\uff0c\u5c06 dhcp \u4fee\u6539\u4e3a static\n\n\u5c06HWADDR\u5f00\u5934\u7684\u4e00\u884c\u5220\u9664\n\n\u5728\u6700\u540e\u4e00\u884c\u7ee7\u7eed\u6dfb\u52a0\n\n\tIPADDR=xxx.xxx.xxx.xxx\n\n\tNETMASK=255.255.255.0\n\n\tGATEWAY=xxx.xxx.xxx.1\n\n\tDNS1=8.8.8.8\n\n\tDNS2=114.114.114.114\n\n\u5176\u4e2dIPADDR\u548c\u7f51\u5173GATEWAY\u4fe1\u606f\u4fee\u6539\u4e3a\u672c\u673aIP\n\n\u7f16\u8f91\u5b8c\u6210\n\n\tBOOTPROTO=static\n\n\tDEVICE=eth0\n\n\tONBOOT=yes\n\n\tSTARTMODE=auto\n\n\tTYPE=Ethernet\n\n\tUSERCTL=no\n\n\tIPADDR=xxx.xxx.xxx.xxx\n\n\tNETMASK=255.255.255.0\n\n\tGATEWAY=xxx.xxx.xxx.1\n\n\tDNS1=8.8.8.8\n\n\tDNS2=114.114.114.114\n\n\u4e0e\u4ee5\u4e0a\u76f8\u540c\u5c31\u662f\u914d\u7f6e\u5b8c\u6210\uff0c\u63a5\u4e0b\u6765\u4fdd\u5b58\u6587\u4ef6\u4fe1\u606f\n\u201cEsc\u201d\u9000\u51fa\u7f16\u8f91\u6a21\u5f0f\uff0c\u8f93\u5165\u201c:wq\u201d\u56de\u8f66\u4fdd\u5b58\u9000\u51fa\n\n\u6587\u4ef6\u4fdd\u5b58\u5b8c\u6210\uff0c\u9700\u8981\u91cd\u542f\u7f51\u5361\u8ba9\u914d\u7f6e\u6587\u4ef6\u751f\u6548\n\ncentos7\u91cd\u542f\u7f51\u5361\u547d\u4ee4 systemctl restart network\n\n\t[root@ ~]# systemctl restart network\n\n\u9664\u4e86\u91cd\u542f\u7f51\u5361\u8fd8\u53ef\u4ee5\u76f4\u63a5\u91cd\u542f\u673a\u5668\n\n\u8f93\u5165reboot \u56de\u8f66 \n\n\t[root@ ~]# reboot\n\n\u91cd\u542f\u5b8c\u6210\u529f\u8fdc\u7a0b\u8fde\u63a5\u5230\u673a\u5668\u4e0a\u5c31\u662f\u6210\u529f\u914d\u7f6e\u9759\u6001IP\n"}