CentOS7下的網路設定方法
阿新 • • 發佈:2018-11-02
分享一下我老師大神的人工智慧教程!零基礎,通俗易懂!http://blog.csdn.net/jiangjunshow
也歡迎大家轉載本篇文章。分享知識,造福人民,實現我們中華民族偉大復興!
CentOS7下,設定網路非常簡單,如果你是ServerGUI的安裝,基本上和windows一樣簡單的設定既可。如果是最小化安裝也可以通過編輯一和設定/etc/sysconfig/network-scripts下面的檔案,然後systemctl restart network既可起效。
設定檔案
設定專案 | 設定詳細 |
---|---|
設定檔案 | /etc/sysconfig/network-scripts/ifcfg-eth0 |
ifcfg-eth0有的時候實際的名字可能類似於:ifcfg-eno16777736
設定內容例項
[root@host31 network-scripts]# cat ifcfg-eno16777736TYPE="Ethernet"BOOTPROTO ="none"DEFROUTE="yes"IPV4_FAILURE_FATAL="no"IPV6INIT="yes"IPV6_AUTOCONF="yes"IPV6_DEFROUTE="yes"IPV6_FAILURE_FATAL="no"NAME="eth0"UUID="9b7e0728-7c25-46e7-b4e1-387ffeb5a66c"DEVICE="eno16777736"ONBOOT="yes"IPADDR="192.168.32.31"PREFIX="24"GATEWAY="192.169.32.2"DNS1="8.8.4.4"IPV6_PEERDNS="yes"IPV6_PEERROUTES ="yes"IPV6_PRIVACY="no"[root@host31 network-scripts]#
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
確定network狀態
systemctl status network
[[email protected] network-scripts]# systemctl status network● network.service - LSB: Bring up/down networking Loaded: loaded (/etc/rc.d/init.d/network) Active: active (exited) since Sun 2016-08-07 11:46:54 EDT; 7h ago Docs: man:systemd-sysv-generator(8) Process: 8862 ExecStop=/etc/rc.d/init.d/network stop (code=exited, status=0/SUCCESS) Process: 9025 ExecStart=/etc/rc.d/init.d/network start (code=exited, status=0/SUCCESS)Aug 07 11:46:54 host31 systemd[1]: Starting LSB: Bring up/down networking...Aug 07 11:46:54 host31 network[9025]: Bringing up loopback interface: Could not load file '/etc/sysconfig/network-scripts/ifcfg-lo'Aug 07 11:46:54 host31 network[9025]: Could not load file '/etc/sysconfig/network-scripts/ifcfg-lo'Aug 07 11:46:54 host31 network[9025]: Could not load file '/etc/sysconfig/network-scripts/ifcfg-lo'Aug 07 11:46:54 host31 network[9025]: Could not load file '/etc/sysconfig/network-scripts/ifcfg-lo'Aug 07 11:46:54 host31 network[9025]: [ OK ]Aug 07 11:46:54 host31 network[9025]: Bringing up interface eno16777736: Connection successfully activated (D-Bus active path: /org/fre...ction/1)Aug 07 11:46:54 host31 network[9025]: [ OK ]Aug 07 11:46:54 host31 systemd[1]: Started LSB: Bring up/down networking.Hint: Some lines were ellipsized, use -l to show in full.[[email protected] network-scripts]#
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
重新啟動network服務
systemctl restart network