高级网络配置

来源:互联网 发布:怎样走路没声音 知乎 编辑:程序博客网 时间:2024/06/03 15:20

####bond####

1.bond网络

linux允许管理员使用bonding内核模块和称为通道绑定接口的特殊网络接口将多个网络接口绑定到一个通道。根据选择的绑定模式,通道绑定使两个或更多个网络接口作为一个网络接口,从而增加带宽和提供冗余性。

2.绑定模式

-模式0(平衡轮循):轮循策略,所有接口都是用轮循方式在所有Slave中传输封包,任何slave都可以接收

-模式1(主动备份):容错,一次只能使用一个slave接口,但是如果该接口出现故障,另一个slave将代替他

-模式2(广播):容错,所有封包都通过所有slave接口广播

3.主动备份

nmcli connection add con-name bond0 ifname bond0 type bond mode active-backup ip4 172.25.254.100/24

##添加模式主动备份的bond bond0


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



测试:

watch -n 1 cat /proc/net/bonding/bond0


ifconfig eth1 down

##使eth1损坏


##eth1损坏后由eth0接替继续工作,网络不断


####team####

1.team也是链路聚合的一种方式,最多支持8块网卡

支持模式:广播容错(broadcast),轮询(round-robin),主备(activebackup),负载均衡(loadbalance,心跳机制)


2.配置

nmcli connection add cpn-name team0 ifname team0 type team config '{"runner":{"name":"activebackup"}}'  ip4 172.25.254.127/24



nmcli connection add con-name eth0 ifname eth0 type team-slave master team0

nmcli connection add con-name eth1 ifname eth1 type team-slave master team0



3.测试

watch -n 1 teamctl team0 stat



ping 172.25.254.127

ifconfig eth0 down


效果:


ifconfig eth0 up


效果:



####网桥####

1.配置方式

- 先将/etc/sysconfig/network-scripts/中ifcfg-*(除lo)移出避免冲突



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


DEVICE=br0                          ##设备名称

ONBOOT=yes                       ##开启服务设备自动激活

BOOTPROTO=none            ##网卡工作状态

BRIDGE=br0                         ##网卡开启的网桥接口



vim/etc/sysconfig/network-scripts/ifcfg-br0


DEVICE=br0

ONBOOT=yes

BOOTPROTO=none

IPADDR=172.25.254.127

NETMASK=255.255.255.0

TYPE=Bridge                          ##网络接口类型是桥接



systemctl stop NetworkManager.service

systemctl restart network

systemctl start NetworkManager.service


测试:

ifconfig:



####网桥命令管理方式####

1.添加

systemctl stop NetworkManager.service

brctl show                      ##查看网桥



brctl addbr br0               ##添加网桥br0



brctl addif br0 eth0        ##为网桥br0添加网卡eth0



ifconfig eth0 up              ##开启网卡eth0

ifconfig br0 172.25.254.127 netmask 255.255.255.0            ##零时设定br0的IP为172.25.254.127,子网掩码为255.255.255.0



ping 172.25.254.127



2.删除

ifconfig br0 down             ##关闭网桥

brctl delif br0 eth0            ##删除网桥br0的网卡



brctl delbr br0                   ##删除网桥



brctl show 



####IPV6####

1.internet proto version 6

ipv4 32/2                    ##地址枯竭,子网掩码:24,16,8

ipv6 128/2                  ##子网掩码:16,32,48,64,80

128/2--------->128/8    16-------->0-f

e.g.2017:0:0:0:f:0:0:1/48

       2017::f:0:0:1

       2017:0:0:0:f::1

       0000------->ffff


2.配置

vim ifcfg-eth0


配置如下:



systemctl restart network


ifconfig:



测试:

ping6 2017::27




原创粉丝点击