我有一个公共IP地址托pipe的Linux服务器。 我想将其configuration为VPN服务器。 然后,我想隐藏所有的VPN服务,所以如果我打开一个套接字,那么默认情况下,它可以通过VPN访问,不能通过互联网访问。
可能吗?
iptables是有用的!
例如,在eth0接口上运行openvpn,使用1194 tcp端口,并且您的vpn接口是“tun0”
#Flush you input tables iptables -F INPUT #Allow connection to openvpn iptables -i eth0 -p tcp --dport 1194 -j ACCEPT #Allow connction through you vpn interface iptables -i tun0 -j ACCEPT # set you default INPUT policy to DROP iptables -P INPUT DROP
所以,你可以设置你的filter(规则3)与你vpn地址,或其他vpn接口(ipsec0,gre,水龙头等)
将服务连接到VPN的接口/ IP。 为了让ssh只听VPN-ip,更改“sshd_config”:
#Listen 0.0.0.0 Listen 10.62.63.1
与apache等一样..
你也可以防火墙的公共IP,只允许在VPN上。
当然,只要适当地设置iptables规则即可。