CentOS自動開啟網路連線
阿新 • • 發佈:2018-12-15
CentOS開機網路預設的關閉的,檢視網絡卡:
$ ifconfig ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.52.128 netmask 255.255.255.0 broadcast 192.168.52.255 inet6 fe80::25c5:e1ad:cf86:88fc prefixlen 64 scopeid 0x20<link> ether 00:0c:29:a5:d3:82 txqueuelen 1000 (Ethernet) RX packets 342 bytes 29392 (28.7 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 210 bytes 30952 (30.2 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
找到對應的配置檔案:
$ sudo more /etc/sysconfig/network-scripts/ifcfg-ens33 [sudo] Toa 的密碼: TYPE=Ethernet PROXY_METHOD=none BROWSER_ONLY=no BOOTPROTO=dhcp DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_FAILURE_FATAL=no IPV6_ADDR_GEN_MODE=stable-privacy NAME=ens33 UUID=a80268f2-6e1b-41f2-8e45-f197b703f2ce DEVICE=ens33 ONBOOT=no ZONE=public
可以看到他的ONBOOT是no,將其改成yes(需要管理員許可權)
$ sudo vim /etc/sysconfig/network-scripts/ifcfg-ens33 [[email protected] ~]$ sudo more /etc/sysconfig/network-scripts/ifcfg-ens33 TYPE=Ethernet PROXY_METHOD=none BROWSER_ONLY=no BOOTPROTO=dhcp DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_FAILURE_FATAL=no IPV6_ADDR_GEN_MODE=stable-privacy NAME=ens33 UUID=a80268f2-6e1b-41f2-8e45-f197b703f2ce DEVICE=ens33 ONBOOT=yes ZONE=public
下次開機就會直接開啟下圖位置處的聯網了