Linux雙網關配置(電信網通)


經常有這種需求,一臺Linux服務器配置電信IP和網通IP,默認情況下,後啓動的網卡的網關生效。南電信北網通,配置電信和網通IP,無非是爲了減少網絡延時,使電信用戶的請求響應在電信網絡中傳輸,網通用戶的請求響應在網通網絡中傳輸。

1
2
3
修改/etc/iproute2/rt_tables
252tel  #電信路由表
251cnc #網通路由表

添加原路返回路由規則,注意:此處原路是廣義上的說法,並不是請求的路徑與響應的路徑完全相同。數據包在internet傳輸是挺複雜的。

配置電信路由:

1
2
3
ip route flush table tel
ip route add defaultvia TEL_IP_GATEWAY dev TEL_NETWORK_INTERFACE src TEL_IP_ADDRESS table tel
ip rule add from TEL_IP_ADDRESS table tel

配置網通路由:

1
2
3
ip route flush table cnc
ip route add defaultvia CNC_IP_GATEWAY dev CNC_NETWORK_INTERFACE src CNC_IP_ADDRESS table cnc
ip rule add from CNC_IP_ADDRESS table cnc

實例如下:

電信IP信息:ip 183.60.139.111 netmask 255.255.255.0 gw 183.60.139.1

網通IP信息:ip 58.253.94.111 netmask 255.255.255.0 gw 58.253.94.254

eth0網卡配置電信IP,eth1網卡配置網通IP,兩網卡都不要配置網關。

1
2
3
# vi /etc/iproute2/rt_tables 添加以下內容
252tel
251cnc

添加路由

1
2
3
4
5
6
# ip route flush table tel
# ip route add defaultvia 183.60.139.1dev eth0 src 183.60.139.111table tel
# ip route add from 183.60.139.111table tel
# ip route flush table cnc
# ip route add defaultvia 58.253.94.254dev eth1 src 58.253.94.111table cnc
# ip route add from 58.253.94.111table cnc

服務器單條網線單個網卡配置多個vlan

https://wiki.ubuntu.com/vlan?highlight=%28CategoryNetworking%29

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# apt-getinstall vlan
# echo "8021q">> /etc/modules
# vi /etc/network/interfaces
auto eth1.10
iface eth1.10inet static
address 183.60.139.111
netmask 255.255.255.0
vlan-raw-device eth1
auto eth1.100
iface eth1.100inet static
address 58.253.94.111
netmask 255.255.255.0
vlan-raw-device eth1

同時,交換機上需要允許vlan10,valn100

1
swithchport access valn 10100
如需轉載請註明出處:Linux雙網關配置(電信網通)

本文鏈接:Linux雙網關配置(電信網通)

轉載聲明:本站文章若無特別說明,皆爲原創,轉載請註明來源:運維生存時間,謝謝!QQ羣:39514058^


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章