使用iptables(linux防火墙)我能够限制只访问VPN连接:
#Clear all previous entries
iptables -F
iptables -A INPUT -i tun+ -j ACCEPT
iptables -A OUTPUT -o tun+ -j ACCEPT
iptables -A INPUT -s 127.0.0.1 -j ACCEPT
iptables -A OUTPUT -d 127.0.0.1 -j ACCEPT
#myvpn.com
iptables -A INPUT -s myvpn.com -j ACCEPT
iptables -A OUTPUT -d myvpn.com -j ACCEPT
#DNS
#openVPN needs DNS to resolve hostnames before it connects. If you are paranoid about dnsleakge, which isn't supposed to be a problem with VPN as all connections are tunneled, you can remove this entry, and then run these iptables commands after you connect to the VPN.
iptables -A INPUT -s 8.8.4.4 -j ACCEPT
iptables -A OUTPUT -d 8.8.4.4 -j ACCEPT
iptables -A INPUT -j DROP
iptables -A OUTPUT -j DROP