我觉得我已经为此挣扎了很久了,需要一些帮助。
我有一个 pptp 隧道,正在尝试将目标流量从 208.85.40.20 路由到 pptp 隧道 (ppp0)。(敏锐的观察者可能会认出该 IP 是 pandora.com 的 IP)。我正在路由器上进行所有这些配置……我知道它没有成功运行,因为 traceroute 只产生星号。
我已将相关输出粘贴在下面:(对地址进行了一些“安全”编辑)
root@OpenWrt:~# ifconfig
br0 Link encap:Ethernet HWaddr 00:1A:92:BC:XX:XX
inet addr:192.168.1.1 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:28185 errors:0 dropped:0 overruns:0 frame:0
TX packets:24936 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:4894242 (4.6 MiB) TX bytes:5941902 (5.6 MiB)
eth0 Link encap:Ethernet HWaddr 00:1A:92:BC:XX:XX
UP BROADCAST RUNNING PROMISC MULTICAST MTU:1500 Metric:1
RX packets:51829 errors:0 dropped:0 overruns:0 frame:0
TX packets:56824 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:11490288 (10.9 MiB) TX bytes:11857913 (11.3 MiB)
Interrupt:4
eth2 Link encap:Ethernet HWaddr 00:1A:92:BC:XX:XX
UP BROADCAST RUNNING ALLMULTI MULTICAST MTU:1500 Metric:1
RX packets:4 errors:0 dropped:0 overruns:0 frame:15426
TX packets:9529 errors:21 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:423 (423.0 B) TX bytes:596036 (582.0 KiB)
Interrupt:2 Base address:0x2000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:30 errors:0 dropped:0 overruns:0 frame:0
TX packets:30 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2300 (2.2 KiB) TX bytes:2300 (2.2 KiB)
ppp0 Link encap:Point-Point Protocol
inet addr:68.68.39.250 P-t-P:172.16.20.1 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1400 Metric:1
RX packets:165 errors:2 dropped:0 overruns:0 frame:0
TX packets:68 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:7006 (6.8 KiB) TX bytes:3462 (3.3 KiB)
vlan0 Link encap:Ethernet HWaddr 00:1A:92:BC:XX:XX
UP BROADCAST RUNNING ALLMULTI MULTICAST MTU:1500 Metric:1
RX packets:28182 errors:0 dropped:0 overruns:0 frame:0
TX packets:33813 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:5006544 (4.7 MiB) TX bytes:6609774 (6.3 MiB)
vlan1 Link encap:Ethernet HWaddr 00:1A:92:BC:XX:XX
inet addr:173.183.111.3 Bcast:173.183.111.255 Mask:255.255.224.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:23653 errors:0 dropped:0 overruns:0 frame:0
TX packets:23012 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:5522012 (5.2 MiB) TX bytes:4982944 (4.7 MiB)
wds0.4915 Link encap:Ethernet HWaddr 00:1A:92:BC:XX:XX
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
wds0.4915 Link encap:Ethernet HWaddr 00:1A:92:BC:XX:XX
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
root@OpenWrt:~# cat /etc/ppp/ip-up
iptables -A FORWARD -t filter -i br0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -t filter -i ppp0 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -A POSTROUTING -o ppp0 -s 192.168.1.1/24 -d 0/0 -j MASQUERADE
iptables -A forwarding_rule -o ppp0 -j ACCEPT
iptables -A forwarding_rule -i ppp0 -j ACCEPT
iptables -t nat -A postrouting_rule -o ppp0 -j MASQUERADE
root@OpenWrt:~# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
172.16.20.1 * 255.255.255.255 UH 0 0 0 ppp0
208.85.40.20 * 255.255.255.255 UH 0 0 0 ppp0
192.168.1.0 * 255.255.255.0 U 0 0 0 br0
173.183.192.0 * 255.255.224.0 U 0 0 0 vlan1
default d173-183-192-1. 0.0.0.0 UG 0 0 0 vlan1
default 192.168.1.1 0.0.0.0 UG 0 0 0 br0
非常感谢您的任何建议,我不太擅长网络,但学习起来很敏锐;-)
答案1
您可以对 ip-up 脚本做类似的事情:
echo "route add 208.85.40.20 dev \$IFNAME" >> /etc/ppp/ip-up.local
chmod 755 /etc/ppp/ip-up.local
编辑
我看到你正在使用 openwrt;我不认为 $IFNAME 会解析为 ppp0、ppp1 等。openwrt wiki 暗示了 ip-up 脚本中的 $INTERFACE:
echo "route add 208.85.40.20 dev \$INTERFACE" >> /etc/ppp/ip-up
编辑2
您是否尝试过手动添加路线?
route add 208.85.40.20 dev ppp0
route add 208.85.40.50 dev ppp0
如果是,它会出现在您的路由表中吗?如果是,(我认为是的)那么我怀疑问题出在您的防火墙或 ppp 链路的另一端。您可以使用 tcpdump 进行验证 - 如果您看到流量离开 ppp0 接口但没有返回,那么很可能是 ppp 对等体。如果您看不到流量,请检查 iptables 设置。
tcpdump -n ip host 208.85.40.20
不安全的 iptables 故障排除:
iptables -t nat -I PREROUTING -d 208.85.40.20 -j ACCEPT
iptables -t nat -I PREROUTING -s 208.85.40.20 -j ACCEPT
iptables -I FORWARD -s 208.85.40.20 -j ACCEPT
iptables -I FORWARD -d 208.85.40.20 -j ACCEPT
iptables -t nat -I POSTROUTING -s 208.85.40.20 -j ACCEPT
iptables -t nat -I POSTROUTING -d 208.85.40.20 -j MASQUERADE
答案2
我做过类似的设置,但使用两个路由器,效果很好。我将第一个路由器设置为 192.168.199.1,将 strongVPN 路由器设置为 192.168.199.2。StrongVPN 路由器有一个指向 192.168.199.1 作为网关的静态 WAN 地址。主路由器已为它想要通过隧道传出的地址添加了路由。例如 208.85.40.20、子网 255.255.255.0、网关 192.168.199.2。我使用 /24 子网,因为我认为该公司可能有一组用于各种服务器的地址。它效果很好,可以为大部分网络流量提供全速,并为您希望通过东道国服务器路由的服务提供隧道速度。我知道这并没有明确回答你的原始问题,但这是我知道有效的另一种方法。