高级网络配置
临时设置ip
ifconfig enp0s25 172.25.254.15/24
设置两块网卡
高级网络配置链路聚合
把两个线路拧到一块
1.网卡的bond
准备工作:将已有的网卡删除
balance 平衡轮循
active-backup 主备
查看bond0
cat /proc/net/bonding/bond0
多块网卡进行工作,down掉一块网卡 另外一块会顶替它而上
然而网络不会中断
bond网络
Red hat enterprise linux 允许管理员使用 bonding 内核模块和称为通道绑定接口的特殊网络接口将多个网络接口绑定到一个通道,根据选择的绑定模式,通道绑定使两个或更多个网络接口作为一个网络接口,从而增加带宽和提供冗余性
选择linux以太网绑定模式
模式0(平衡轮循)-轮循策略,所有接口都使用采用轮循方式在所有slave中传输封包;任何slave都可以接收
模式1(主动备份)-容错,一次只使用一个slave接口,但是如果该接口出现故障,另一个slave将接替它
模式3(广播)-容错。所有封包都通过所有slave接口广播(dhcp网络)
比较常用的是0 1 企业很少有用dhcp ip
测试:添加一块网卡
删除ip
添加一个bond0
监控
watch -n 1 cat /proc/net/bonding/bond0
将eth0加入进bond0
将eth1加入进bond0
ping172.25.254.xx
down掉eth0
ping依旧通
up eth0,将eth1 down掉,ping依旧通
即可实现在一台服务器坏掉的情况下另外一台主机轮换
实验完成之后删除bond0,eth0和eth1
2.team
种类
broadcast | 广播容错 |
---|---|
roundrobin | 平衡轮循 |
activebackup | 主备 |
loadbalance | 负载均衡 |
建立team
nmcli connection add con-name team0 ifname team0 type team config ‘{“runner”:{“name”:“activebackup”}}’ ip4 172.25.254.115/24
ifconfig 查看
watch -n 1 teamdctl team0 stat 监控
nmcli connection add con-name eth0 ifname eth0 type team-slave master team0
同理设置eth1
ping 172.25.254.xx
ifconfig eth0 down
而网络依旧通畅
down掉eht0,将eth1 up
网络依旧通畅
nat模式
网络地址转换
3.桥接
bro 链接虚拟机和真实主机
使虚拟机可以使用真实的物理网卡
在真机中做
cp ifcfg-ens ifcfg-br0 /mnt
nm-connection-editor
删除所有的东西,新建一个ip westos
vim ifcfg-westos
BOOTPROTO=none
NAME=westos
DEVICE=
ONBOOT=yes
BRIDGE=br0
vim ifcfg-br0
DEVICE=br0
IPADDR=172.25.254.10
NETMASK=255.255.255.0
TYPE=Bridge
重启网络服务
systemctl stop NetworkManager
systemctl restart network
4.命令方式设置桥接
先nm-connection-editor删除其他ip
addif 添加真实物理硬件
<1>命令添加桥接,都为临时
brctl show ##显示桥接及物理设备
brctl addbr br0 ##添加桥接
ifconfig 查看发现没有ip
ifconfig br0 172.25.254.115/24 ##给桥接一个ip
ping 172.25.254.14发现不通
brctl addif br0 eth0 ##添加br0到物理设备中
brctl show
ping 172.25.254.14就通了
<2>命令删除桥接
brctl show
brctl delif br0 eth0
brctl show
因为设备正在工作,所以不能直接删除,需要将br0 down掉
ifconfig br0 down
brctl show
brctl delbr br0
brctl show
ifconfig
就能看到br0已经被成功删除了