[Solved] Redirect-gateway Reroutes Everything to the Servers
Posted: Mon Jul 18, 2011 12:59 am
Hello, I successfully installed an set up openvpn on my VPS (openvz). However, I am having great difficulties with routing all traffic through the server with my clients. When I do so I am able to connect to the server just fine. I can even ssh to the server through the tunnel. However, when I try to ping or connect to ANY IP address it sends the request straight to my openvpn server. Even if the IP is invalid, I will get a reply. However, the reply is from my server. Trying to ssh to 12.435.4.45? It will ssh to my server. So I ask, what am I doing wrong with my configuration? Thank you very much! (OpenVz VPS = no masquerade for iptables)
iptables...
OpenVPN (server)
iptables...
Code: Select all
iptables -F
iptables -P INPUT ACCEPT
# OpenVPN redirect gateway routing...
iptables -A INPUT -i tun+ -j ACCEPT
iptables -A FORWARD -i tun+ -o venet0 -j ACCEPT
# End OpenVPN
#trust loopback connections
iptables -A INPUT -i lo -j ACCEPT
#trust established connections
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
# allow icmp
iptables -A INPUT -p icmp -m icmp -j ACCEPT
export WAN=venet0
iptables -I INPUT 1 -i lo -j ACCEPT
# SSH
iptables -A INPUT -p TCP --dport 443 -i ${WAN} -j ACCEPT
# OpenVPN (uses the default http port to bypass most firewalls)
iptables -A INPUT -p UDP --dport 80 -i ${WAN} -j ACCEPT
iptables -A INPUT -p all -j REJECT
# OpenVPN (can't use masquerade because of openvz)
iptables -t nat -A POSTROUTING -s 10.8.1.0/24 -j SNAT --to 63.141.254.19
Code: Select all
port 80
proto udp
dev tun
ca /etc/openvpn/keys/ca.crt
cert /etc/openvpn/keys/daft.crt
key /etc/openvpn/keys/daft.key
dh /etc/openvpn/keys/dh2048.pem
ifconfig-pool-persist ipp.txt
server 10.8.1.0 255.255.255.0
push "route 10.8.1.0 255.255.255.0"
push "dhcp-option DNS 4.2.2.2"
push "dhcp-option DNS 4.2.2.3"
keepalive 10 120
client-to-client
comp-lzo
ping-timer-rem
persist-key
persist-tun
status /var/log/openvpn.log
verb 3