type
status
date
slug
summary
tags
category
icon
password
comment_flag
SLUGS

问题与解决思路

问题
  1. 有时候Linux设备需要通过PPTP进行联网,通常会设置默认路由为PPTP关联的网卡设备(如ip route add default dev ppp0),那么出入流量都会经过ppp0来进行转发,会给远程代理服务器带来流量压力(通常代理服务器带宽有限)。
  1. 另外就是如果进行了PPTP联网,有些网络段是无法访问该Linux设备的。(比如不进行PPTP联网,该设备可由某网络段SSH连接,然而进行PPTP联网后,就无法进行ssh连接了)。
解决思路
主要是设置静态路由:
  1. 问题1是关于该Linux设备的出方向的流量,所以对destination网络段设置静态路由,让其通过指定网卡设备转发。
  1. 问题2是关于该Linux设备的入方向的流量,应该为source ip设置静态路由。
下面就是示例。

destination-based routing

让服务器通向10.xxx.xxx.xxx的连接通过网关10.2xx.xxx.1进行路由,而不是由ppp0接口转发流量。
查看更改后的路由表:

source-based routing

[可选]sudo vim /etc/iproute2/rt_tables添加路由表table id + table name,如100 mytable
希望来访该服务器的连接通过网关10.2xx.xxx.1进行路由:
查看路由策略:
可以看到访问10.2xx.xxx.2xeth3所获取的ip)的入流量都通过mytable来进行路由。
查看mytable路由表:
可以看到路由表mytable规定流量默认通过接口eth3来转发。
这样访问该Linux设备10.2xx.xxx.2x就不会被PPTP连接所影响。

references

  1. https://superuser.com/questions/376667/how-to-route-only-specific-subnet-source-ip-to-a-particular-interface
  1. http://wiki.wlug.org.nz/SourceBasedRouting
Zynq7000三种GPIO的使用之点亮流水灯摘要ArchLinux安装(二)-安装并配置AwesomeWM
Loading...