配置IP

1.进入目录/etc/sysconfig/network-scripts/ ls看到配置文件ifcfg-网卡名称

[root@CentOS7 ~]#cd /etc/sysconfig/network-scripts/
[root@CentOS7 network-scripts]#ls
ifcfg-eth0   ifdown-post      ifup-eth     ifup-sit
ifcfg-eth1   ifdown-ppp       ifup-ib      ifup-Team
ifcfg-lo     ifdown-routes    ifup-ippp    ifup-TeamPort
ifdown       ifdown-sit       ifup-ipv6    ifup-tunnel
ifdown-bnep  ifdown-Team      ifup-isdn    ifup-wireless
ifdown-eth   ifdown-TeamPort  ifup-plip    init.ipv6-global
ifdown-ib    ifdown-tunnel    ifup-plusb   network-functions
ifdown-ippp  ifup             ifup-post    network-functions-ipv6
ifdown-ipv6  ifup-aliases     ifup-ppp
ifdown-isdn  ifup-bnep        ifup-routes
[root@CentOS7 network-scripts]#

2.编辑

ifcfg-eth0为本地IP

[root@CentOS7 network-scripts]#vim ifcfg-eth0
BOOTPROTO=static  #设置网卡状态为静态   dhcp为自动获取
NAME=eth0  #网卡描述
DEVICE=eth0  #标明对那个网卡设置
ONBOOT=yes  #开机自动启动
IPADDR=192.168.50.7  #ip地址
GATEWAY=192.168.50.1   #网关
NETMASK=255.255.255.0   #子网掩码

wq  #保存退出

ifcfg-eth1为桥接IP 这里我是DHCP自动获取

[root@CentOS7 network-scripts]#vim ifcfg-eth1
DEVICE=eth1  #标明对那个网卡设置
NAME=eth1   #网卡描述
ONBOOT=yes  #开机自动启动
BOOTPROTO=dhcp  #自动获取
#IPADDR=172.18.133.223  #因为自动获取注释掉了
#GATEWAY=172.18.0.1     #同上
#NETMASK=255.255.0.0    #同上

wq  #保存退出

3.重启网络服务

centos6

[root@CentOS6 ~]#service network restart

centos7

[root@CentOS7 ~]#systemctl restart network