CentOS7下的网络设定方法

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-eno16777736
TYPE="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]#

确定network状态

systemctl status network

[root@host31 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.
[root@host31 network-scripts]#

重新启动network服务

systemctl restart network

你可能感兴趣的:(Unix/Linux)