{"id":178046,"date":"2020-04-28T12:13:39","date_gmt":"2020-04-28T04:13:39","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=178046"},"modified":"2020-04-26T09:18:51","modified_gmt":"2020-04-26T01:18:51","slug":"rhel7-centos7-network","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/rhel7-centos7-network.html","title":{"rendered":"\u66f4\u6539 RHEL7 \u6216\u8005 CentOS 7 \u7684\u7f51\u5361\u540d\u79f0"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u672c\u6587\u6863\u4ecb\u7ecd\u66f4\u6539 RHEL7 \u6216\u8005 CentOS 7 \u7684\u7f51\u5361\u540d\u79f0\u7684\u65b9\u6cd5\uff0c\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u6765\u64cd\u4f5c\u5c31\u53ef\u4ee5\u5b9e\u73b0\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\u4e00\u3001\u7f51\u5361\u914d\u7f6e\u6587\u4ef6\u540d\u79f0\u91cd\u547d\u540d\u4e3aeth0 (\u4e5f\u53ef\u4ee5\u6539\u4e3a\u5176\u4ed6\u540d\u79f0)<\/strong><\/div>\n
\r\n[root@Jaking11 ~]# ifconfig\r\nens33: flags=4163  mtu 1500\r\n        inet 192.168.10.11  netmask 255.255.255.0  broadcast 192.168.10.255\r\n        inet6 fe80::250:56ff:fe29:eae  prefixlen 64  scopeid 0x20\r\n        ether 00:50:56:29:0e:ae  txqueuelen 1000  (Ethernet)\r\n        RX packets 132  bytes 14492 (14.1 KiB)\r\n        RX errors 0  dropped 0  overruns 0  frame 0\r\n        TX packets 115  bytes 13105 (12.7 KiB)\r\n        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0\r\n\r\nlo: flags=73  mtu 65536\r\n        inet 127.0.0.1  netmask 255.0.0.0\r\n        inet6 ::1  prefixlen 128  scopeid 0x10\r\n        loop  txqueuelen 1000  (Local Loopback)\r\n        RX packets 140  bytes 11204 (10.9 KiB)\r\n        RX errors 0  dropped 0  overruns 0  frame 0\r\n        TX packets 140  bytes 11204 (10.9 KiB)\r\n        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0\r\n\r\n[root@Jaking11 ~]# \r\n[root@Jaking11 ~]# cd \/etc\/sysconfig\/network-scripts\/\r\n[root@Jaking11 network-scripts]# ls\r\nifcfg-ens33  ifdown-ppp       ifup-eth     ifup-sit\r\nifcfg-lo     ifdown-routes    ifup-ippp    ifup-Team\r\nifdown       ifdown-sit       ifup-ipv6    ifup-TeamPort\r\nifdown-bnep  ifdown-Team      ifup-isdn    ifup-tunnel\r\nifdown-eth   ifdown-TeamPort  ifup-plip    ifup-wireless\r\nifdown-ippp  ifdown-tunnel    ifup-plusb   init.ipv6-global\r\nifdown-ipv6  ifup             ifup-post    network-functions\r\nifdown-isdn  ifup-aliases     ifup-ppp     network-functions-ipv6\r\nifdown-post  ifup-bnep        ifup-routes\r\n[root@Jaking11 network-scripts]# mv ifcfg-ens33 ifcfg-eth0\r\n[root@Jaking11 network-scripts]# vim ifcfg-eth0 \r\nTYPE=Ethernet\r\nPROXY_METHOD=none\r\nBROWSER_ONLY=no\r\nBOOTPROTO=static\r\nDEFROUTE=yes\r\nIPV4_FAILURE_FATAL=no\r\nNAME=eth0\r\nDEVICE=eth0\r\nONBOOT=yes\r\nIPADDR=192.168.10.11\r\nGATEWAY=192.168.10.2\r\nNETMASK=255.255.255.0\r\n<\/host><\/pre>\n
\u4e8c\u3001\u7981\u7528\u7f51\u5361\u547d\u540d\u89c4\u5219<\/strong><\/div>\n

\u6b64\u529f\u80fd\u901a\u8fc7<\/p>\n

\/etc\/default\/grub<\/pre>\n

\u6587\u4ef6\u6765\u63a7\u5236\uff0c\u8981\u7981\u7528\u6b64\u529f\u80fd\uff0c\u5728\u6587\u4ef6\u4e2d\u52a0\u5165<\/p>\n

\"net.ifnames=0  biosdevname=0\"<\/pre>\n

\u5373\u53ef<\/p>\n

\r\n[root@Jaking11 network-scripts]# vim \/etc\/default\/grub\r\n  \r\nGRUB_TIMEOUT=5\r\nGRUB_DISTRIBUTOR=\"$(sed 's, release .*$,,g' \/etc\/system-release)\"\r\nGRUB_DEFAULT=saved\r\nGRUB_DISABLE_SUBMENU=true\r\nGRUB_TERMINAL_OUTPUT=\"console\"\r\nGRUB_CMDLINE_LINUX=\"crashkernel=auto rd.lvm.lv=centos\/root rd.lvm.lv=centos\/swap\r\n rhgb quiet net.ifnames=0 biosdevname=0\"\r\nGRUB_DISABLE_RECOVERY=\"true\"\r\n<\/pre>\n
\u4e09\u3001\u6dfb\u52a0udev\u7f51\u5361\u89c4\u5219<\/strong><\/div>\n

\u5728\/etc\/udev\/rules.d\u76ee\u5f55\u4e2d\u521b\u5efa\u4e00\u4e2a\u7f51\u5361\u89c4\u521970-persistent-net.rules\u6587\u4ef6\uff0c\u5728\u6587\u4ef6\u4e2d\u5199\u5165\u4ee5\u4e0b\u53c2\u6570\uff1a<\/p>\n

SUBSYSTEM==\"net\",ACTION==\"add\",DRIVERS==\"?*\",ATTR{address}==\"\u9700\u8981\u4fee\u6539\u540d\u79f0\u7684\u7f51\u5361MAC\u5730\u5740\",ATTR\uff5btype\uff5d==\"1\" ,KERNEL==\"eth*\",NAME=\"eth0\"<\/pre>\n

\u53c2\u8003\u914d\u7f6e\uff1a<\/p>\n

\r\n[root@Jaking11 rules.d]# vim 70-persistent-net.rules\r\nSUBSYSTEM==\"net\",ACTION==\"add\",DRIVERS==\"?*\",ATTR{address}==\"00:50:56:29:0e:ae\",\r\nATTR\uff5btype\uff5d==\"1\" ,KERNEL==\"eth*\",NAME=\"eth0\"\r\n<\/pre>\n
\u6267\u884cgrub2-mkconfig -o \/boot\/grub2\/grub.cfg\u547d\u4ee4\u751f\u6210\u66f4\u65b0grub\u914d\u7f6e\u53c2\u6570<\/strong><\/div>\n
\r\n[root@Jaking11 rules.d]# grub2-mkconfig -o \/boot\/grub2\/grub.cfg\r\nGenerating grub configuration file ...\r\nFound linux image: \/boot\/vmlinuz-3.10.0-957.el7.x86_64\r\nFound initrd image: \/boot\/initramfs-3.10.0-957.el7.x86_64.img\r\nFound linux image: \/boot\/vmlinuz-0-rescue-fe49b659ccb940fa8d260a5897c0b08a\r\nFound initrd image: \/boot\/initramfs-0-rescue-fe49b659ccb940fa8d260a5897c0b08a.img\r\ndone\r\n<\/pre>\n
\u91cd\u542fLinux\u7cfb\u7edf\u540e\u9a8c\u8bc1\u7f51\u5361\u540d\u79f0\u662f\u5426\u66f4\u6539\u6210\u529f<\/strong><\/div>\n
\r\n[root@Jaking11 ~]# ifconfig\r\neth0: flags=4163  mtu 1500\r\n        inet 192.168.10.11  netmask 255.255.255.0  broadcast 192.168.10.255\r\n        inet6 fe80::250:56ff:fe29:eae  prefixlen 64  scopeid 0x20\r\n        ether 00:50:56:29:0e:ae  txqueuelen 1000  (Ethernet)\r\n        RX packets 86  bytes 10889 (10.6 KiB)\r\n        RX errors 0  dropped 0  overruns 0  frame 0\r\n        TX packets 95  bytes 10828 (10.5 KiB)\r\n        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0\r\n\r\nlo: flags=73  mtu 65536\r\n        inet 127.0.0.1  netmask 255.0.0.0\r\n        inet6 ::1  prefixlen 128  scopeid 0x10\r\n        loop  txqueuelen 1000  (Local Loopback)\r\n        RX packets 0  bytes 0 (0.0 B)\r\n        RX errors 0  dropped 0  overruns 0  frame 0\r\n        TX packets 0  bytes 0 (0.0 B)\r\n        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0\r\n<\/host><\/pre>\n
\u603b\u7ed3<\/strong><\/div>\n

\u4ee5\u4e0a\u5c31\u662f\u66f4\u6539 RHEL7 \u6216\u8005 CentOS 7 \u7684\u7f51\u5361\u540d\u79f0\u7684\u65b9\u6cd5\uff0c\u6700\u540e\u770b\u5230 eth0 \u8bf4\u660e\u7f51\u5361\u540d\u79f0\u66f4\u6539\u6210\u529f\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"

[root@Jaking11 ~]# ifconfig ens33: flags=4163 mtu 1500 […]<\/p>\n","protected":false},"author":63,"featured_media":178047,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-178046","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\/178046","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=178046"}],"version-history":[{"count":5,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/178046\/revisions"}],"predecessor-version":[{"id":180802,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/178046\/revisions\/180802"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/178047"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=178046"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=178046"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=178046"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}