系统相关
首页 > 系统相关> > Linux多运营商线路网卡配置

Linux多运营商线路网卡配置

作者:互联网

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

标签:up,网卡,etc,dx,Linux,运营商,post,路由,路由表
来源: https://www.cnblogs.com/feng0919/p/15187491.html