Linux下配置桥接网络
#前期准备
1、关闭NetwokManager服务 (因为其会自动配置管理网络设置,不关闭的话,我们做的修改会失效) 且设置开机禁止
CentOS6 service NetworkManager stop
chkconfig NetworkManager off
CentOS7 systemctl stop NetworkManager .service
systemctl disable NetworkManager.service
2、修改网卡文件
CentOS6和7的文件名可能是由差别的,所以去/etc/sysconfig/network-scripts目录下查看,ifcfg-exxxxx这样的文件
我的CentOS7为ifcfg-ens33 CnetOS6为eth0
vi /etc/sysconfig/network-scripts/ifcfg-eth0 清空后写入以下内容
DEVICE=ens33
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=none
BRIDGE=br0
新建一个/etc/sysconfig/network-scripts/ifcfg-br0文件
写入以下内容
DEVICE=br0
TYPE=Bridge
ONBOOT=yes
BOOTPROTO=static
IPADDR=10.100.55.201 //IP地址
NETMASK=255.255.255.0
GATEWAY=10.100.55.254 //网关地址 查看自己电脑的网络连接获取
DNS1=211.161.159.115 //DNS服务器地址
DNS2=211.161.158.102
3、重启网络即可
CentOS7 systemctl restart network.service
CentOS6 service network restart
4、如果想要远程连接,最好关闭防火墙
CentOS6 service iptables stop
chkconfig iptables off
CentOS7 systemctl stop firewalld
systemctl disable firewalld