linux---桥接

1.主机 超级用户 nm-connection-editor 删除所有


 
2.查看空闲网卡 ifconfig

3.设定enp2s0的ip :ifconfig enp2s0 172.25.254.20/24


4.编辑enp2s0的配置文件:

cd /etc/sysconfig/network-scripts/
   vim ifcfg-enp0s25

DEVICE=enp2s0
ONBOOT=yes
BOOTPROTO=none
IPADDR=172.25.254.20
NETMASK=255.255.255.0


 5.重启网络:systemctl restart network



二.有桥接的网络较快
硬件设备受内核的调度
内核上开启kvm--虚拟化功能----虚拟机----虚拟网卡---
虚拟机内核
nat  地址转化
网桥br0 搭键两个不能通信的接口----由真实内核开启


1.cd /etc/sysconfig/network-scripts/
vim ifcfg-enp2s0


DEVICE=enp0s25
ONBOOT=yes
BOOTPROTO=none 以静态方式获取ip
BRIDGE=br0
2.编辑br0配置文件: vim ifcfg-br0


DEVICE=br0
ONBOOT=yes
BOOTPROTO=none
IPADDR=172.25.254.20
NETMASK=255.255.255.0
TYPE=Bridge


3.查看brctl=bridge control ,此时br0已经和enp0s25桥接上了
         brctl show

控制桥接接口
虚拟机desktop


1,nm-connection-editor  删除网卡


2,brctl addbr br0 建立br0


3,设定ip ifconfig br0 172.25.254.120/24


4, brctl show  此时ping不通


5,brctl addif br0 eth0 将br0与eth0 连接


6,brctl show 此时可以ping通


三.删除桥接


1,ifconfig br0 down 关闭br0


2,brctl delif br0 eth0 摘除br0与eth0 的桥接


3,brctl delbr br0  删除br0


4,brctl show 查看设备已经不存在

猜你喜欢

转载自blog.csdn.net/xys2333/article/details/84331286
今日推荐