刚才在Debian上配置openvpn客户端(以下称为A主机),发现连接LUG-vpn后,本地地址就无法从外网访问了。
因此,我将openvpn自动添加的0.0.0.0/1路由规则修改为了默认规则
ip route delete 0.0.0.0/1
route add default gw 10.7.0.1 tun0
此时发现,外网地址已经可以从公网访问,但却无法从vpn内部的网关访问。即:某主机B直接接入公网,可以连接A主机的公网地址;但若某主机C连接了vpn,则无法连接A主机的公网地址(当然,通过LUG-vpn的内网地址10.7.0.24是可以访问的)。
请问这是什么原因引起的呢?
附1 ip route:
default via 10.7.0.1 dev tun0
default via 222.195.93.254 dev eth0
10.7.0.0/16 dev tun0 proto kernel scope link src 10.7.0.24
128.0.0.0/1 via 10.7.0.1 dev tun0
192.168.13.0/24 dev eth1 proto kernel scope link src 192.168.13.3
202.141.176.99 via 222.195.93.254 dev eth0
222.195.92.0/23 dev eth0 proto kernel scope link src 222.195.92.141
附2 ifconfig tun0:
tun0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:10.7.0.24 P-t-P:10.7.0.24 Mask:255.255.0.0
inet6 addr: 2001:da8:d800:f001:176:99:1:16/64 Scope:Global
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:2571569 errors:0 dropped:0 overruns:0 frame:0
TX packets:1001570 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:2515353771 (2.3 GiB) TX bytes:175492710 (167.3 MiB)
附3 uname -a:
Linux 1415-linux 3.2.0-4-amd64 #1 SMP Debian 3.2.57-3+deb7u2 x86_64 GNU/Linux
附4 openvpn --version:
OpenVPN 2.2.1 x86_64-linux-gnu [SSL] [LZO2] [EPOLL] [PKCS11] [eurephia] [MH] [PF_INET6] [IPv6 payload 20110424-2 (2.2RC2)] built on Jun 18 2013
Originally developed by James Yonan
Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sa...@openvpn.net>
$ ./configure --build=x86_64-linux-gnu --prefix=/usr --includedir=${prefix}/include --mandir=${prefix}/share/man --infodir=${prefix}/share/info --sysconfdir=/etc --localstatedir=/var --libexecdir=${prefix}/lib/openvpn --disable-maintainer-mode --disable-dependency-tracking CFLAGS=-g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security CPPFLAGS=-D_FORTIFY_SOURCE=2 CXXFLAGS=-g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security FFLAGS=-g -O2 LDFLAGS=-fPIE -pie -Wl,-z,relro -Wl,-z,now --enable-password-save --host=x86_64-linux-gnu --build=x86_64-linux-gnu --prefix=/usr --mandir=${prefix}/share/man --with-ifconfig-path=/sbin/ifconfig --with-route-path=/sbin/route
Compile time defines: ENABLE_CLIENT_SERVER ENABLE_DEBUG ENABLE_EUREPHIA ENABLE_FRAGMENT ENABLE_HTTP_PROXY ENABLE_MANAGEMENT ENABLE_MULTIHOME ENABLE_PASSWORD_SAVE ENABLE_PORT_SHARE ENABLE_SOCKS USE_CRYPTO USE_LIBDL USE_LZO USE_PF_INET6 USE_PKCS11 USE_SSL
参考boj的这篇文章:
https://boj.blog.ustc.edu.cn/index.php/2014/02/port-mapping-fallacies/
你拨了vpn之后相当于你链接了两个isp,配置路由需要借助fwmark来“修正”路由。
Cheng
(sent from a mobile device)
--
-- 来自USTC LUG
请使用gmail订阅,不要灌水。
更多信息more info:http://groups.google.com/group/ustc_lug?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups "USTC_LUG" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ustc_lug+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
开启 2014年6月14日 at 上午1:21:44, Bojie Li (boj...@gmail.com) 写:
开启 2014年6月14日 at 上午12:46:42, Allan Lu (al...@ream.at) 写:
我很好奇windows是用什么办法实现的?如果把A主机换成Windows系统(我测试的是Server 2012 R2),连接openvpn后,无需任何配置,从公网、VPN内网均可连接A主机的公网地址,并且不区分协议(目前TCP/UDP/ICMP测试都没问题)。
--
boj怎么学的,太博学了。。。
Zhuoyun Wei <wzyb...@gmail.com>编写:
2014-06-14 1:52 GMT+08:00 Yifan Gao <ylgao...@gmail.com>:我很好奇windows是用什么办法实现的?如果把A主机换成Windows系统(我测试的是Server 2012 R2),连接openvpn后,无需任何配置,从公网、VPN内网均可连接A主机的公网地址,并且不区分协议(目前TCP/UDP/ICMP测试都没问题)。Windows 正是用基于连接的第一种方案实现的,连接从哪个口进,回复的数据包就会从哪个口出。这种方案也是看起来最和谐的。Windows 没有策略路由更没有 iptables NAT,如果系统不内置,就凭一张基于目的 IP 的路由表,用户怎么实现这个功能?
开启 2014年6月15日 at 上午1:16:51, Bojie Li (boj...@gmail.com) 写:
开启 2014年6月15日 at 上午1:48:04, Bojie Li (boj...@gmail.com) 写: