网络桥接与网络接口

时间:2021-04-23 16:21:15

一、网络桥接

brctl show        ##查看有无网桥

网络桥接与网络接口

无网桥的情况下,需要先安装网桥
brctl addbr br0

网络桥接与网络接口

给网桥一个合法的身份使得其可以与虚拟机的内核可以进行沟通
ifconfig br0 172.25.254.108 netmask 255.255.255.0
ifconfig ##查看br0是否与172.25.254.108联系成功

网络桥接与网络接口

网桥设置成功之后,再添加接口
brctl addif br0 eth0 ##将eth0添加到br0上
删除网桥的步骤:

ifconfig eth0 down ##指定网卡停止工作
brctl delif br0 eth0 ##删除网桥上的网卡
ifconfig br0 down ##指定网桥停止工作
brctl delbr br0 ##删除网桥

二、网络接口

1)bond

   首先,在一台虚拟机上添加两块网卡 

网络桥接与网络接口
网络桥接与网络接口
网络桥接与网络接口

BOND的应添加与应用:
nmcli connection add type bond con-name bond0 ifname bond0 mode active-backup ip4 172.25.254.108/24
nmcli connection add con-name eth0 ifname eth0 type bond-slave master bond0 ##在bond0上添加第一块网卡eth0
nmcli connection add con-name eth1 ifname eth1 type bond-slave master bond0 ##在bond0上添加第二块网卡eth1
   两块网卡绑定在一起,一块网卡损坏后,第二块网卡可以立即开始工作,从而不会影响客户端的使用效果,下面的实验,我们来体验一下!
ping 172.25.254.8              ##确保畅通的前提下
ifconfig eth0/eth1 down/up ##交替进行,只要保证一块网卡工作,ping就可以成功

网络桥接与网络接口

BOND删除:
nmcli connection delete eth0
nmcli connection delete eth
ifconfig bond0 down

2)team

----------特点-------------
TEAM和bond0功能类似
TEAM不需要手动加载相应内核模块
TEAM有更强的拓展性
支持8块网卡
------------种类-------------
broadcast 广播容错
roundrobin 平衡轮叫
activebackup 主备
loadbalance 负载均衡
TEAM的建立:
nmcli connection add type team con-name team0 ifname team0 config '{"runner":{"name":"activebackup"}}' ip4 172.25.254.208/24
TEAM的查看:
teamdctl team0 state
TEAM的应用:
nmcli connection add con-name eth0 ifname eth0 type team-slave master team0 ##在team0上加第一块网卡eth0
nmcli connection add con-name eth1 ifname eth1 type team-slave master team0 ##在team0上加第二块网卡eth1
测试:
ping 172.25.254.8 ##确保可以畅通
ifconfig eth0/eth1 down/up ##交替进行,只要保证一块网卡工作,ping就可以成功

网络桥接与网络接口

网络桥接与网络接口