Linux双网关配置(电信网通)

默北 Linux1 15,1253字数 1384阅读4分36秒阅读模式

经常有这种需求,一台Linux服务器配置电信IP和网通IP,默认情况下,后启动的网卡的网关生效。南电信北网通,配置电信和网通IP,无非是为了减少网络延时,使电信用户的请求响应在电信网络中传输,网通用户的请求响应在网通网络中传输。

修改/etc/iproute2/rt_tables
252 tel  #电信路由表
251 cnc #网通路由表

添加原路返回路由规则,注意:此处原路是广义上的说法,并不是请求的路径与响应的路径完全相同。数据包在internet传输是挺复杂的。文章源自运维生存时间-https://www.ttlsa.com/linux/linux-double-gate-configure/

配置电信路由:文章源自运维生存时间-https://www.ttlsa.com/linux/linux-double-gate-configure/

ip route flush table tel
ip route add default via TEL_IP_GATEWAY dev TEL_NETWORK_INTERFACE src TEL_IP_ADDRESS table tel
ip rule add from TEL_IP_ADDRESS table tel

配置网通路由:文章源自运维生存时间-https://www.ttlsa.com/linux/linux-double-gate-configure/

ip route flush table cnc
ip route add default via CNC_IP_GATEWAY dev CNC_NETWORK_INTERFACE src CNC_IP_ADDRESS table cnc
ip rule add from CNC_IP_ADDRESS table cnc

实例如下:文章源自运维生存时间-https://www.ttlsa.com/linux/linux-double-gate-configure/

电信IP信息:ip 183.60.139.111 netmask 255.255.255.0 gw 183.60.139.1文章源自运维生存时间-https://www.ttlsa.com/linux/linux-double-gate-configure/

网通IP信息:ip 58.253.94.111 netmask 255.255.255.0 gw 58.253.94.254文章源自运维生存时间-https://www.ttlsa.com/linux/linux-double-gate-configure/

eth0网卡配置电信IP,eth1网卡配置网通IP,两网卡都不要配置网关。文章源自运维生存时间-https://www.ttlsa.com/linux/linux-double-gate-configure/

# vi /etc/iproute2/rt_tables 添加以下内容
252 tel
251 cnc

添加路由文章源自运维生存时间-https://www.ttlsa.com/linux/linux-double-gate-configure/

# ip route flush table tel
# ip route add default via 183.60.139.1 dev eth0 src 183.60.139.111 table tel
# ip route add from 183.60.139.111 table tel
# ip route flush table cnc
# ip route add default via 58.253.94.254 dev eth1 src 58.253.94.111 table cnc
# ip route add from 58.253.94.111 table cnc

服务器单条网线单个网卡配置多个vlan文章源自运维生存时间-https://www.ttlsa.com/linux/linux-double-gate-configure/

https://wiki.ubuntu.com/vlan?highlight=%28CategoryNetworking%29文章源自运维生存时间-https://www.ttlsa.com/linux/linux-double-gate-configure/

# apt-get install vlan
# echo "8021q" >> /etc/modules
# vi /etc/network/interfaces
auto eth1.10
iface eth1.10 inet static
address 183.60.139.111
netmask 255.255.255.0
vlan-raw-device eth1

auto eth1.100
iface eth1.100 inet static
address 58.253.94.111
netmask 255.255.255.0
vlan-raw-device eth1

同时,交换机上需要允许vlan10,valn100 文章源自运维生存时间-https://www.ttlsa.com/linux/linux-double-gate-configure/

swithchport access valn 10 100
如需转载请注明出处:Linux双网关配置(电信网通)
文章源自运维生存时间-https://www.ttlsa.com/linux/linux-double-gate-configure/文章源自运维生存时间-https://www.ttlsa.com/linux/linux-double-gate-configure/
weinxin
我的微信
微信公众号
扫一扫关注运维生存时间公众号,获取最新技术文章~
默北
  • 本文由 发表于 01/02/2012 12:26:22
  • 转载请务必保留本文链接:https://www.ttlsa.com/linux/linux-double-gate-configure/
  • cnc
  • internet
  • ip route
  • iproute
  • Linux
  • rt_tables
  • tel
  • 电信
  • 网关
  • 网通
  • 路由
评论  1  访客  1
    • el
      el 9

      实例中写的不对啊! 是 ip rule add from IP table tel

    评论已关闭!