我有VPN客户端的计算机上运行的VNC服务器,端口5900,将连接到我的VPN服务器(ppp),它可以通过互联网用户访问。 VPN服务器是CentOS 6.8 x64。
但是,当前的VPN客户端ISP(而不是VPN服务器)不允许来自外部/互联网的传入连接。 换句话说,他们已经和防火墙做了一些事情。 目前,我的VPN客户端能够:
我的VPN服务器能够: – 从VPN和互联网接收和传输
在VPN Server中,这是Centos 6.8,这些是iptables,我的VPN客户端可以通过VPN服务器访问Internet:
-A POSTROUTING -o eth0 -j MASQUERADE -A INPUT -p tcp -m tcp --dport 5900 -j ACCEPT -A FORWARD -d 210.48.222.2/32 -i eth0 -o ppp+ -p tcp -m tcp --dport 5900 -j ACCEPT -A FORWARD -i ppp+ -o eth0 -j ACCEPT -A FORWARD -i eth0 -o ppp+ -j ACCEPT
这些是CentOS中的ifconfig
eth0 Link encap:Ethernet HWaddr 04:01:4C:C5:81:02 inet addr:128.199.210.115 Bcast:128.199.255.255 Mask:255.255.192.0 inet6 addr: 2400:6180:0:d0::45c:c001/64 Scope:Global inet6 addr: fe80::601:4cff:fec5:8701/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:163888 errors:0 dropped:0 overruns:0 frame:0 TX packets:171866 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:178131279 (169.8 MiB) TX bytes:179452807 (171.1 MiB) eth1 Link encap:Ethernet HWaddr 04:01:4C:C5:67:01 inet addr:10.130.133.116 Bcast:10.130.255.255 Mask:255.255.0.0 inet6 addr: fe80::601:4cff:fec5:8702/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:9 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 b) TX bytes:566 (566.0 b) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:24797 errors:0 dropped:0 overruns:0 frame:0 TX packets:24797 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:2914752 (2.7 MiB) TX bytes:2914752 (2.7 MiB) ppp0 Link encap:Point-to-Point Protocol inet addr:128.199.210.115 PtP:210.48.222.2 Mask:255.255.255.255 UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1396 Metric:1 RX packets:33106 errors:0 dropped:0 overruns:0 frame:0 TX packets:43985 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:3 RX bytes:3997842 (3.8 MiB) TX bytes:39318955 (37.4 MiB) tun0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 -00 inet addr:10.50.0.1 PtP:10.50.0.2 Mask:255.255.255.255 UP POINTOPOINT RUNNING NOARP 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:100 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
我已经回顾了iptables:如何将目的地端口80的数据包从eth0转发到eth1? ,它从eth0到eth1工作,并尝试从eth0应用到ppp +,但它不起作用。 或者,也许我需要添加更多的iptables。
对于VPN,我已经按照文章中的步骤https://www.photonvps.com/billing/knowledgebase.php?action=displayarticle&id=58是作品(VPN客户端能够连接到VPN服务器)
但是,我仍然无法连接到我的VPN客户端的VNC(端口5900)从互联网/其他ISP没有连接VPN服务器。 iptables中是否有错误或缺失?
这些是我的计划:
My PC (not the VPN user) > Remotely Access to > CentOS + VPN Server > Client (connected to the CentOS VPN)
它没问题,问题解决了,它的工作正常(使服务器通过VPN阻止ISP的公共访问)我只需要在/ etc / sysconfig / iptables中添加这些:
-A PREROUTING -p tcp -m tcp --dport 5900 -j DNAT --to-destination 210.48.222.2:5900 -A POSTROUTING -o ppp+ -j MASQUERADE