首页 > 系统服务 > 详细

Linux多运营商线路网卡配置

时间:2021-08-26 09:12:45      阅读:13      评论:0      收藏:0      [点我收藏+]

Linux多运营商线路网卡配置

配置方法:

  • 配置网络
  • 增加路由表
  • 增加默认网关
  • 增加回源路由

配置网络

这个根据运营商提供的IP来进行配置

举个例子:在bond模式下新增一个ip:

vim /etc/network/interfaces
post-up ifconfig bond0:0 电信IP netmask 子网掩码 up

配置路由表部分

Linux路由规则组成部分包括路由规则和路由表。

路由规则制定当数据包满足规则时,转交给某个路由表。

路由表根据数据包的信息,选择下一跳地址

  • 增加路由表

举个例子:添加一个电信路由表

vim /etc/network/interfaces
post-up (grep "101 dx" /etc/iproute2/rt_tables)|| (echo "101 dx" >> /etc/iproute2/rt_tables)
  • 增加默认路由

为dx这张表添加默认路由

vim /etc/network/interfaces
post-up ip route add default via ‘网关IP’ dev bond0:0 table dx
  • 增加路由返回功能,实现源进源出

根据源ip决定路由表

vim /etc/network/interfaces
post-up ip rule add from 电信IP table dx

汇总:

已添加一个电信线路为例,全部配置如下

vim /etc/network/interfaces
post-up (grep "101 dx" /etc/iproute2/rt_tables)|| (echo "101 dx" >> /etc/iproute2/rt_tables)
post-up ip route add default via ‘网关IP’ dev bond0:0 table dx
post-up ip rule add from 电信IP table dx

参考文档:

https://www.hi-linux.com/posts/64963.html#vip-container

https://www.cnblogs.com/jmilkfan-fanguiju/p/10589729.html

Linux多运营商线路网卡配置

原文:https://www.cnblogs.com/feng0919/p/15187491.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!