高级网络服务

来源:互联网 发布:宁泽涛傅园慧cp乐乎 编辑:程序博客网 时间:2024/05/17 21:58

高级网络服务

bond

主要功能就是在有两块网卡的情况下,不论哪一块网卡出现故障,例外一块网卡就直接继续工作,不会造成网络中断

添加一个bond,网卡名字bond0  模式为主备,设置地址为172.25.254.225,子网掩码为24位

将两块网卡加入到bond0组中


这样设置完成之后无论哪个网卡停止工作,另外一块会接替工作,网络不会中断


team模式

team
team模式最多可以支持八块网卡

查看team0的组信息
teamdctl team0 state
监控命令
watch -n 1 teamdctl team0 state

首先给虚拟机添加双网卡

添加双网卡
nm-connection-editor


添加team组
nmcli connection add con-name team0 ifname team0 type team config '{"runner":{"name":"activebackup"}}' ip4 172.25.254.203/24


添加完之后还是ping不通同网段的其他地址,因为这只是一个虚拟的组,并没有添加网卡
给team组添加网卡,将eth0和eth1都添加到team组当中
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


添加完网卡之后,这台主机就可以ping通其他主机,即使一块网卡down掉之后,另外一块网卡会直接接替工作,不会影响网络通信


网桥
配置网桥
网卡配置文件  ifcfg-enp0s25
vim ifcfg-enp0s25
 DEVICE=enp0s25
 ONBOOT=yes
 BOOTPROTO=none
 BRIDGE=br0


网桥配置文件  ifcfg-br0
 DEVICE=br0
 ONBOOT=yes
 BOOTPROTO=none
 IPADDR=172.25.254.3
 NETMASK=255.255.255.0
 TYPE=Bridge

测试,可以查看到配置的网桥
systemctl restart network
network-scripts]# brctl show

 bridge name    bridge id        STP enabled    interfaces
 br0        8000.0021cc6373cf    no        enp0s25
 virbr0        8000.5254003c2938    yes        virbr0-nic
 virbr1        8000.525400da6c72    yes        virbr1-nic

虚拟机添加网桥
查看网桥
brctl show
bridge name    bridge id        STP enabled    interfaces
添加网桥br0
[root@www network-scripts]# brctl addbr br0
[root@www network-scripts]# brctl show
bridge name    bridge id        STP enabled    interfaces
br0        8000.000000000000    no


给br0添加ip地址
ifconfig br0 172.25.254.203 netmask 255.255.255.0  
ifconfig br0 172.25.254.203/24
设置完ip地址之后,ping172.25.254.3时不通的,因为还没有添加网卡


把br0链接到真实网卡上 此时可ping通网络
[root@www network-scripts]# brctl addif br0 ens3
[root@www network-scripts]# brctl show
bridge name    brdge id        STP enabled    interfaces
br0        8000.525400a00ce8    no        ens3
这时添加完网卡之后就可以ping通172.25.254.3


删除br0
[root@www network-scripts]# ifconfig br0 down  ##停止br0工作
##[root@www network-scripts]# brctl delif br0 eth0  ##断开br0 和网卡的链接
##[root@www network-scripts]# brctl show
##bridge name    bridge id        STP enabled    interfaces
##br0        8000.000000000000    no        
[root@www network-scripts]# brctl delbr br0 ##删除br0
[root@www network-scripts]# brctl show
bridge name    bridge id        STP enabled    interfaces

原创粉丝点击