OPEN VPN 建立调试失败,FTP做端口映射后,外网也不能访问进来,原因不详

Web、Mail、Ftp、DNS、Proxy、VPN、Samba、LDAP 等基础网络服务
回复
micro_cy
帖子: 104
注册时间: 2011-07-20 11:33

OPEN VPN 建立调试失败,FTP做端口映射后,外网也不能访问进来,原因不详

#1

帖子 micro_cy » 2016-02-20 14:46

先说一下我的网络拓扑:
服务器主机ETH0在VLAN8,ETH1是带的无线AP,ETH1的IP地址是192.168.68.100,通过ETH0转发上网,ETH0的网关地址是VLAN8,IP地址是172.16.8.254/24,自己的地址是172.16.8.20/24;

路由器做了端口映射:路由器出口地址是a.b.c.d,端口转发做了80,20,21,22,23,443,1194,等,

现在的实现想法有两个:一个是FTP用户从外网访问使用a.b.c.d:60021进来,访问不了,提示返回不可路由的地址,主动被动都测试了,都不行,估计和fillzilla的兼容性有关系,不知道有没有什么好办法没;
还有一个想法是,外网用户通过服务器建立的VPN拨入,获得ETH1段的某几个IP地址(这个很重要,Eth1里面,只能分配指定的IP地址,而且还不是地址段,因为有防火墙的缘故,我针对每一个可用的地址进行了防火墙设置),实现内外网互通;

网上看了很多openVPN的教程,但是似乎和我的情况都不太一样;

还有几个比较重要的疑问:为什么我建立好以后的VPN服务器,看不到监听端口1194,难道是有访问的时候才行吗?

root@cccsq-server:/etc/openvpn# netstat -anup
激活Internet连接 (服务器和已建立连接的)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
udp 0 0 0.0.0.0:5353 0.0.0.0:* 809/avahi-daemon: r
udp 0 0 172.16.8.20:36178 115.29.164.43:6060 ESTABLISHED 2250/phddns
udp 0 0 0.0.0.0:36199 0.0.0.0:* 809/avahi-daemon: r
udp 0 0 0.0.0.0:10000 0.0.0.0:* 4546/perl
udp 0 0 127.0.0.1:53 0.0.0.0:* 12143/dnsmasq
udp 0 0 192.168.68.100:53 0.0.0.0:* 12143/dnsmasq
udp 0 0 127.0.1.1:53 0.0.0.0:* 1404/dnsmasq
udp 0 0 0.0.0.0:67 0.0.0.0:* 12143/dnsmasq
udp 0 0 192.168.68.100:123 0.0.0.0:* 4690/ntpd
udp 0 0 172.16.8.20:123 0.0.0.0:* 4690/ntpd
udp 0 0 127.0.0.1:123 0.0.0.0:* 4690/ntpd
udp 0 0 0.0.0.0:123 0.0.0.0:* 4690/ntpd
udp 0 0 192.168.68.255:137 0.0.0.0:* 2238/nmbd
udp 0 0 192.168.68.100:137 0.0.0.0:* 2238/nmbd
udp 0 0 172.16.8.255:137 0.0.0.0:* 2238/nmbd
udp 0 0 172.16.8.20:137 0.0.0.0:* 2238/nmbd
udp 0 0 0.0.0.0:137 0.0.0.0:* 2238/nmbd
udp 0 0 192.168.68.255:138 0.0.0.0:* 2238/nmbd
udp 0 0 192.168.68.100:138 0.0.0.0:* 2238/nmbd
udp 0 0 172.16.8.255:138 0.0.0.0:* 2238/nmbd
udp 0 0 172.16.8.20:138 0.0.0.0:* 2238/nmbd
udp 0 0 0.0.0.0:138 0.0.0.0:* 2238/nmbd
udp 0 0 0.0.0.0:631 0.0.0.0:* 2388/cups-browsed
udp6 0 0 :::5353 :::* 809/avahi-daemon: r
udp6 0 0 fe80::204:5fff:fe04:123 :::* 4690/ntpd
udp6 0 0 fe80::204:5fff:fe04:123 :::* 4690/ntpd
udp6 0 0 ::1:123 :::* 4690/ntpd
udp6 0 0 :::123 :::* 4690/ntpd
udp6 0 0 :::58144 :::* 809/avahi-daemon: r


还有就是:UDP和TCP端口,是不是在server.conf里面可以同时开启?

还有问题是:那个ipp.txt那个文件是干什么用的?

还有问题是:网络上的一些教程关于server.conf和client.conf里面关于一些IP地址的描述不是太清楚,不知道是干什么用的?例如:

代码: 全选

# "dev tun" will create a routed IP tunnel,
# "dev tap" will create an ethernet tunnel.
# Use "dev tap0" if you are ethernet bridging
# and have precreated a tap0 virtual interface
# and bridged it with your ethernet interface.
# If you want to control access policies
# over the VPN, you must create firewall
# rules for the the TUN/TAP interface.
# On non-Windows systems, you can give
# an explicit unit number, such as tun0.
# On Windows, use "dev-node" for this.
# On most systems, the VPN will not function
# unless you partially or fully disable
# the firewall for the TUN/TAP interface.
dev tap0
;dev tun
我这种情况应该是使用tap0还是使用tun??

代码: 全选

push "redirect-gateway def1" push "dhcp-option DNS 10.8.0.1"

最后这两行指示客户端用OpenVPN作为默认的网关,并用10.8.0.1作为DNS服务器。注意10.8.0.1是OpenVPN启动时自动创建的隧道接口的IP。如果客户用别的域名解析服务,那么我们就得提防不安全的DNS服务器。为了避免这种泄露,我们建议所有OpenVPN客户端使用10.8.0.1作为DNS服务器。
这句里面,def1是什么意思?
10.8.0.1是OpenVPN启动时自动创建的隧道接口的IP,那么我怎么替换成我这种情况的192段的IP地址?

代码: 全选

# Configure server mode and supply a VPN subnet
# for OpenVPN to draw client addresses from.
# The server will take 10.8.0.1 for itself,
# the rest will be made available to clients.
# Each client will be able to reach the server
# on 10.8.0.1. Comment this line out if you are
# ethernet bridging. See the man page for more info.
server 172.16.8.20 255.255.255.0
这个写eth0的地址不知道对不对??还是要写外网的地址??

代码: 全选

# Maintain a record of client <-> virtual IP address
# associations in this file.  If OpenVPN goes down or
# is restarted, reconnecting clients can be assigned
# the same virtual IP address from the pool that was
# previously assigned.
ifconfig-pool-persist ipp.txt
这个文件是不是可以控制用户拨入后获得的IP地址池???

代码: 全选

# Configure server mode for ethernet bridging.
# You must first use your OS's bridging capability
# to bridge the TAP interface with the ethernet
# NIC interface.  Then you must manually set the
# IP/netmask on the bridge interface, here we
# assume 10.8.0.4/255.255.255.0.  Finally we
# must set aside an IP range in this subnet
# (start=10.8.0.50 end=10.8.0.100) to allocate
# to connecting clients.  Leave this line commented
# out unless you are ethernet bridging.
;server-bridge 172.16.8.20 255.255.255.0 172.16.8.120 172.16.8.150
这段我发现我没法用桥接,因为我的IP段是不一样的,我必须是eth1通过eth0访问互联网,但是eth0才是映射进来的服务器网口。

代码: 全选

# Push routes to the client to allow it
# to reach other private subnets behind
# the server.  Remember that these
# private subnets will also need
# to know to route the OpenVPN client
# address pool (10.8.0.0/255.255.255.0)
# back to the OpenVPN server.
;push "route 192.168.10.0 255.255.255.0"
;push "route 192.168.20.0 255.255.255.0"
push "route 192.168.68.0 255.255.255.0"
这样写,不知道符合我的情况不?

代码: 全选

push "redirect-gateway def1"

# Certain Windows-specific network settings
# can be pushed to clients, such as DNS
# or WINS server addresses.  CAVEAT:
# http://openvpn.net/faq.html#dhcpcaveats
# The addresses below refer to the public
# DNS servers provided by opendns.com.
;push "dhcp-option DNS 208.67.222.222"
;push "dhcp-option DNS 208.67.220.220"
push "dhcp-option DNS 192.168.68.100"
client.conf

代码: 全选

remote 222.173.11.62 1194
不知道这样写对不对??感觉不太对啊,外网转发进来是1194,没错,但是外网访问的时候端口是61194,转成内网172.16.8.20以后才是1194???


客户端用什么工具拨入比较方便啊?都是windows的系统,直接用系统的拨号建立连接的方式吗?

我在内网怎么测试我的OPEN VPN呢??
头像
oneleaf
论坛管理员
帖子: 10441
注册时间: 2005-03-27 0:06
系统: Ubuntu 12.04

Re: OPEN VPN 建立调试失败,FTP做端口映射后,外网也不能访问进来,原因不详

#2

帖子 oneleaf » 2016-02-20 22:53

ftp的外网到内网的映射比较麻烦,必须使用pasv模式,而且还需要规定pasv的端口,以及同样对这些端口做映射。仅仅映射20、21是不足够让ftp支持外网访问的。

为什么我建立好以后的VPN服务器,看不到监听端口1194,难道是有访问的时候才行吗?
openvpn的端口是在你配置中的,服务启动后,一定有监听端口。
UDP和TCP端口,是不是在server.conf里面可以同时开启?
在一个配置文件中不能,但通过配置多个不同的server来开启不同的协议。
那个ipp.txt那个文件是干什么用的?
固定客户端IP用的。
我这种情况应该是使用tap0还是使用tun??
tun
这个写eth0的地址不知道对不对??还是要写外网的地址??
不对,直接写10.8.0.1好了。
这个文件是不是可以控制用户拨入后获得的IP地址池???
不是,是固定IP用的。
这样写,不知道符合我的情况不?
符合
不知道这样写对不对??感觉不太对啊,外网转发进来是1194,没错,但是外网访问的时候端口是61194,转成内网172.16.8.20以后才是1194???
服务端和客户端的协议和端口保持一致即可。
客户端用什么工具拨入比较方便啊
openvpn有专用的windows客户端
我在内网怎么测试我的OPEN VPN呢??
一样直接用客户端连外网的IP测试。
micro_cy
帖子: 104
注册时间: 2011-07-20 11:33

Re: OPEN VPN 建立调试失败,FTP做端口映射后,外网也不能访问进来,原因不详

#3

帖子 micro_cy » 2016-02-21 22:10

代码: 全选

ftp的外网到内网的映射比较麻烦,必须使用pasv模式,而且还需要规定pasv的端口,以及同样对这些端口做映射。仅仅映射20、21是不足够让ftp支持外网访问的。
经过测试,错误始终出现在auth Tls上,我关闭了强制使用SSL,使用普通登录方式,外网直接就可以进来了,听说是因为电信网络内部也有NAT的问题导致的。关于映射除了20,21端口外,我也专门映射了2个专门用于被动连接的两个端口,而且在客户端绑定了这两个端口,使得我连接服务器的时候,使用的就是我设置的两个端口的其中一个,经过测试,还是不能正常连接,可以看到目录,但是不能获取目录列表,提示错误还是关于返回不可路由的地址导致的,猜想还是因为auth tls 导致的,无奈只能先关了SSL的强制验证,想借助open VPN 解决问题。

代码: 全选

引用:
为什么我建立好以后的VPN服务器,看不到监听端口1194,难道是有访问的时候才行吗?

openvpn的端口是在你配置中的,服务启动后,一定有监听端口。
我启动了open vpn的服务,使用netstat -anup 查看,并没有看到1194的端口,restart重启服务的时候,提示,并没有vpn在运行,证明服务确实没有启动。可能是因为我的vpn配置的有问题的原因吧

代码: 全选

引用:
UDP和TCP端口,是不是在server.conf里面可以同时开启?

在一个配置文件中不能,但通过配置多个不同的server来开启不同的协议。
配置案例默认使用的是UDP,请问,UDP较TCP而言有什么优势吗?

代码: 全选

引用:
那个ipp.txt那个文件是干什么用的?

固定客户端IP用的。
请问这个固定客户端IP的格式写法应该怎么写?

引用:
我这种情况应该是使用tap0还是使用tun??

tun

代码: 全选

引用:
这个写eth0的地址不知道对不对??还是要写外网的地址??

不对,直接写10.8.0.1好了。
如果使用TUN的方式,是要开启桥接模式的,似乎是有点麻烦,还有就是使用一个查看内核是否支持tun/tap的命令,提示说不支持,但是我看了内核的配置,默认是支持的,很矛盾,到底支持不支持?我查看了相关的资料,如果使用tun的方式,给eth0做一个子网,eth0.1,客户端所获得的地址和eth0.1应该是同一个段的,eth0的段地址已经没有空余的给VPN的客户端分配了,不明白这个10.8.0.1的地址是哪里来的,是否指的就是eth0.1?我的服务器上并没有这个地址段,如果VPN客户端新的网关地址,那么为什么我不能使用ETH1的192段的地址。

代码: 全选

引用:
这个文件是不是可以控制用户拨入后获得的IP地址池???

不是,是固定IP用的。
固定IP?到底是怎么固定的情况呢?

代码: 全选

引用:
不知道这样写对不对??感觉不太对啊,外网转发进来是1194,没错,但是外网访问的时候端口是61194,转成内网172.16.8.20以后才是1194???

服务端和客户端的协议和端口保持一致即可。
保持一致的话,肯定是不行的,我的路由器设置的转发就是从61194进来的,没有做1194的转发,所以说,一致的话,肯定是不对的。remote 意思是返回路由吧?好像和外网进来没有什么关系,所以你说的似乎也是对的。

感谢详细的逐条解释。
micro_cy
帖子: 104
注册时间: 2011-07-20 11:33

Re: OPEN VPN 建立调试失败,FTP做端口映射后,外网也不能访问进来,原因不详

#4

帖子 micro_cy » 2016-02-22 10:12

这个openVPN把我弄的很崩溃,ifconfig里面根本就没有tun的设备,准备用cisco的VPN,架设估计能简单不少。
头像
oneleaf
论坛管理员
帖子: 10441
注册时间: 2005-03-27 0:06
系统: Ubuntu 12.04

Re: OPEN VPN 建立调试失败,FTP做端口映射后,外网也不能访问进来,原因不详

#5

帖子 oneleaf » 2016-02-22 14:54

openvpn是最简单的一种vpn了,是你把问题复杂化了。

有个简单的指南:

http://wiki.ubuntu.org.cn/Vps#.E5.AE.89 ... 85_OpenVPN
micro_cy
帖子: 104
注册时间: 2011-07-20 11:33

Re: OPEN VPN 建立调试失败,FTP做端口映射后,外网也不能访问进来,原因不详

#6

帖子 micro_cy » 2016-02-24 15:48

Wed Feb 24 14:32:26 2016 NOTE: --user option is not implemented on Windows
Wed Feb 24 14:32:26 2016 NOTE: --group option is not implemented on Windows
Wed Feb 24 14:32:26 2016 OpenVPN 2.1.3 i686-pc-mingw32 [SSL] [LZO2] [PKCS11] built on Aug 20 2010
Wed Feb 24 14:32:26 2016 NOTE: OpenVPN 2.1 requires '--script-security 2' or higher to call user-defined scripts or executables
Wed Feb 24 14:32:26 2016 LZO compression initialized
Wed Feb 24 14:32:26 2016 Control Channel MTU parms [ L:1542 D:138 EF:38 EB:0 ET:0 EL:0 ]
Wed Feb 24 14:32:26 2016 Socket Buffers: R=[8192->8192] S=[8192->8192]
Wed Feb 24 14:32:26 2016 Data Channel MTU parms [ L:1542 D:1450 EF:42 EB:135 ET:0 EL:0 AF:3/1 ]
Wed Feb 24 14:32:26 2016 Local Options hash (VER=V4): '41690919'
Wed Feb 24 14:32:26 2016 Expected Remote Options hash (VER=V4): '530fdded'
Wed Feb 24 14:32:26 2016 UDPv4 link local: [undef]
Wed Feb 24 14:32:26 2016 UDPv4 link remote: 172.16.8.20:1194
Wed Feb 24 14:32:26 2016 read UDPv4: Connection reset by peer (WSAECONNRESET) (code=10054)
Wed Feb 24 14:32:28 2016 read UDPv4: Connection reset by peer (WSAECONNRESET) (code=10054)
Wed Feb 24 14:32:32 2016 read UDPv4: Connection reset by peer (WSAECONNRESET) (code=10054)
Wed Feb 24 14:32:32 2016 TCP/UDP: Closing socket
Wed Feb 24 14:32:32 2016 SIGTERM[hard,] received, process exiting

这是什么原因??
micro_cy
帖子: 104
注册时间: 2011-07-20 11:33

Re: OPEN VPN 建立调试失败,FTP做端口映射后,外网也不能访问进来,原因不详

#7

帖子 micro_cy » 2016-02-24 16:03

这么多VPN,哪种适合首页描述的这种情况呢?
头像
oneleaf
论坛管理员
帖子: 10441
注册时间: 2005-03-27 0:06
系统: Ubuntu 12.04

Re: OPEN VPN 建立调试失败,FTP做端口映射后,外网也不能访问进来,原因不详

#8

帖子 oneleaf » 2016-02-24 17:02

read UDPv4: Connection reset by peer
看看应该是UDP协议问题,你试试TCP吧。

就openvpn好了。
micro_cy
帖子: 104
注册时间: 2011-07-20 11:33

Re: OPEN VPN 建立调试失败,FTP做端口映射后,外网也不能访问进来,原因不详

#9

帖子 micro_cy » 2016-02-24 17:20

Wed Feb 24 17:20:47 2016 OpenVPN 2.2.2 Win32-MSVC++ [SSL] [LZO2] [PKCS11] built on Dec 15 2011
Wed Feb 24 17:20:47 2016 NOTE: OpenVPN 2.1 requires '--script-security 2' or higher to call user-defined scripts or executables
Wed Feb 24 17:20:48 2016 Control Channel Authentication: using 'ta.key' as a OpenVPN static key file
Wed Feb 24 17:20:48 2016 Outgoing Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication
Wed Feb 24 17:20:48 2016 Incoming Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication
Wed Feb 24 17:20:48 2016 LZO compression initialized
Wed Feb 24 17:20:48 2016 Control Channel MTU parms [ L:1558 D:166 EF:66 EB:0 ET:0 EL:0 ]
Wed Feb 24 17:20:48 2016 Socket Buffers: R=[8192->8192] S=[8192->8192]
Wed Feb 24 17:20:48 2016 Data Channel MTU parms [ L:1558 D:1450 EF:58 EB:135 ET:0 EL:0 AF:3/1 ]
Wed Feb 24 17:20:48 2016 Local Options hash (VER=V4): '272f1b58'
Wed Feb 24 17:20:48 2016 Expected Remote Options hash (VER=V4): 'a2e63101'
Wed Feb 24 17:20:48 2016 UDPv4 link local: [undef]
Wed Feb 24 17:20:48 2016 UDPv4 link remote: 172.16.8.20:1194
Wed Feb 24 17:20:48 2016 read UDPv4: Connection reset by peer (WSAECONNRESET) (code=10054)
Wed Feb 24 17:20:50 2016 read UDPv4: Connection reset by peer (WSAECONNRESET) (code=10054)
Wed Feb 24 17:20:55 2016 read UDPv4: Connection reset by peer (WSAECONNRESET) (code=10054)
Wed Feb 24 17:21:03 2016 read UDPv4: Connection reset by peer (WSAECONNRESET) (code=10054)
Wed Feb 24 17:21:19 2016 read UDPv4: Connection reset by peer (WSAECONNRESET) (code=10054)
Wed Feb 24 17:21:24 2016 TCP/UDP: Closing socket
Wed Feb 24 17:21:24 2016 SIGTERM[hard,] received, process exiting
micro_cy
帖子: 104
注册时间: 2011-07-20 11:33

Re: OPEN VPN 建立调试失败,FTP做端口映射后,外网也不能访问进来,原因不详

#10

帖子 micro_cy » 2016-02-24 17:30

Wed Feb 24 17:33:25 2016 OpenVPN 2.2.2 Win32-MSVC++ [SSL] [LZO2] [PKCS11] built on Dec 15 2011
Wed Feb 24 17:33:25 2016 NOTE: OpenVPN 2.1 requires '--script-security 2' or higher to call user-defined scripts or executables
Wed Feb 24 17:33:25 2016 Control Channel Authentication: using 'ta.key' as a OpenVPN static key file
Wed Feb 24 17:33:25 2016 Outgoing Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication
Wed Feb 24 17:33:25 2016 Incoming Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication
Wed Feb 24 17:33:25 2016 LZO compression initialized
Wed Feb 24 17:33:25 2016 Control Channel MTU parms [ L:1560 D:168 EF:68 EB:0 ET:0 EL:0 ]
Wed Feb 24 17:33:25 2016 Socket Buffers: R=[8192->8192] S=[8192->8192]
Wed Feb 24 17:33:25 2016 Data Channel MTU parms [ L:1560 D:1450 EF:60 EB:135 ET:0 EL:0 AF:3/1 ]
Wed Feb 24 17:33:25 2016 Local Options hash (VER=V4): '0bdd0804'
Wed Feb 24 17:33:25 2016 Expected Remote Options hash (VER=V4): 'a642654b'
Wed Feb 24 17:33:25 2016 Attempting to establish TCP connection with 172.16.8.20:1194
Wed Feb 24 17:33:26 2016 TCP: connect to 172.16.8.20:1194 failed, will try again in 5 seconds: Connection refused (WSAECONNREFUSED)
Wed Feb 24 17:33:32 2016 TCP: connect to 172.16.8.20:1194 failed, will try again in 5 seconds: Connection refused (WSAECONNREFUSED)
头像
oneleaf
论坛管理员
帖子: 10441
注册时间: 2005-03-27 0:06
系统: Ubuntu 12.04

Re: OPEN VPN 建立调试失败,FTP做端口映射后,外网也不能访问进来,原因不详

#11

帖子 oneleaf » 2016-02-24 23:00

到外网 telnet 下你公网的IP和端口,应该是你的端口映射或防火墙出了问题。
micro_cy
帖子: 104
注册时间: 2011-07-20 11:33

Re: OPEN VPN 建立调试失败,FTP做端口映射后,外网也不能访问进来,原因不详

#12

帖子 micro_cy » 2016-02-25 14:08

因为升级了2次内核,,3.13,升级到3.16,3.16升级到4.2,导致tun模块驱动加载的有问题,准备重新编译一下内核,猜测可能和这个tun加载有关系。
回复