0
点赞
收藏
分享

微信扫一扫

网卡聚合、静态路由

静守幸福 2022-01-31 阅读 53

网卡聚合

  • loadbalance
    • 负载均衡模式
    • 所有数据要通过两块网卡进入服务器
  • activebackup
    • 主备模式
    • 同一个时间,只有一块网卡传输数据

创建聚合网卡

nmcli conn add type team ifname team1 con-name team1 config '{"runner":{"name":"loadbalance"}}'

# type team
# 指定聚合网卡类型

绑定物理网卡

nmcli conn add type team-slave ifname ens33 con-name team1-ens33 master team1
nmcli conn add type team-slave ifname ens37 con-name team1-ens37 master team1


# type team-slave
# 为聚合网卡绑定物理网卡

配置IP

激活网卡

验证通信

静态路由

开启路由转发

  • 临时
    • echo 1 > /proc/sys/net/ipv4/ip_forward
  •  永久
    • 编写配置文件/etc/sysconfig/network-scripts/route-出网卡名称

      例如:

      1.1.1.0/24 via 172.16.10.1 dev ens37

      格式

      网段 via 下一跳地址 dev 出网卡名称

  添加静态路由

route add -net 网段 gw 下一跳地址

删除静态路由

route del -net 网段 gw 下一跳地址

查看内核参数

[root@hosta ~]# sysctl -a

[root@hosta ~]# sysctl -a | grep "ip_forward"
net.ipv4.ip_forward = 0

永久修改内核参数

[root@hosta ~]# vim /etc/sysctl.conf 
net.ipv4.ip_forward = 1

// 让系统重新读取/etc/sysct.conf文件,让修改立即生效
[root@hosta ~]# sysctl -p
net.ipv4.ip_forward = 1

[root@hosta ~]# sysctl -a | grep "ip_forward"
net.ipv4.ip_forward = 1
举报

相关推荐

0 条评论