debian - OpenVPN + iptables: not forwarding traffic -
i trying forward traffic through vpn openvpn on vps. did on openvz virtualized server in past, cannot replicate working behaviour on new installation on different vps. changed provider because of reasons unimportant question's scope.
i can correctly connect vpn windows client, reach pages through machine's public ip instead of vps public ip.
the vps runs debian 7, 32bit. server openvpn config:
port 1194 proto udp dev tun ca /etc/openvpn/easy-rsa/keys/ca.crt # generated keys cert /etc/openvpn/easy-rsa/keys/server.crt key /etc/openvpn/easy-rsa/keys/server.key # keep secret dh /etc/openvpn/easy-rsa/keys/dh1024.pem server 10.9.8.0 255.255.255.0 # internal tun0 connection ip ifconfig-pool-persist ipp.txt keepalive 10 120 comp-lzo # compression - must turned on @ both end persist-key persist-tun push "redirect-gateway" status log/openvpn-status.log verb 3 # verbose mode client-to-client
client (windows 7) openvpn config:
client dev tun proto udp remote my-server-ip 1194 remote-random resolv-retry infinite nobind persist-key persist-tun mute-replay-warnings ca "c:\\program files (x86)\\openvpn\\config\\frankfurt\\ca.crt" cert "c:\\program files (x86)\\openvpn\\config\\frankfurt\\nick.crt" key "c:\\program files (x86)\\openvpn\\config\\frankfurt\\nick.key" comp-lzo verb 3 keepalive 10 120 route-method exe route-delay 2
ifconfig:
lo link encap:local loopback inet addr:127.0.0.1 mask:255.0.0.0 inet6 addr: ::1/128 scope:host loopback running mtu:16436 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:0 rx bytes:0 (0.0 b) tx bytes:0 (0.0 b) tun0 link encap:unspec hwaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 inet addr:10.9.8.1 p-t-p:10.9.8.2 mask:255.255.255.255 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) venet0 link encap:unspec hwaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 inet addr:127.0.0.2 p-t-p:127.0.0.2 bcast:0.0.0.0 mask:255.255.255.255 inet6 addr: .../128 scope:global inet6 addr: .../128 scope:global inet6 addr: .../128 scope:global inet6 addr: .../128 scope:global inet6 addr: .../128 scope:global broadcast pointopoint running noarp mtu:1500 metric:1 rx packets:15332 errors:0 dropped:0 overruns:0 frame:0 tx packets:7317 errors:0 dropped:56 overruns:0 carrier:0 collisions:0 txqueuelen:0 rx bytes:13666157 (13.0 mib) tx bytes:762502 (744.6 kib) venet0:0 link encap:unspec hwaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 inet addr:my-server-ip p-t-p:my-server-ip bcast:my-server-ip mask:255.255.255.255 broadcast pointopoint running noarp mtu:1500 metric:1
iptables -l: (rules port 20100 previous experiments have nothing this)
chain input (policy accept) target prot opt source destination accept udp -- anywhere anywhere udp dpt:20100 accept tcp -- anywhere anywhere tcp dpt:20100 accept tcp -- anywhere anywhere tcp dpt:20100 accept -- anywhere anywhere chain forward (policy accept) target prot opt source destination accept -- anywhere anywhere state related,established accept -- 10.9.8.0/24 anywhere accept -- anywhere anywhere state related,established accept -- anywhere anywhere state related,established chain output (policy accept) target prot opt source destination
iptables -l -t nat:
chain prerouting (policy accept) target prot opt source destination chain postrouting (policy accept) target prot opt source destination snat -- anywhere anywhere to:my-server-ip chain output (policy accept) target prot opt source destination
i checked discussions, forums , blog posts error, couldn' quite understand what's wrong config.
btw, ip_forward 1, in sysctl.conf.
with openvz platform iptables should similar this:
echo "1" > /proc/sys/net/ipv4/ip_forward iptables -a input -i tun0 -j accept iptables -a forward -i tun0 -j accept iptables -a input -i tun1 -j accept iptables -a forward -i tun1 -j accept iptables -t nat -a postrouting -o venet0 -j snat --to-source xxx.xxx.xxx.xxx
where xxx.xxx.xxx.xxx
external ip address of vps.
a detailed guide on openvpn installation can found here https://limitlessblog.co.za/2017/05/16/openvpn-server-installation-debian/
Comments
Post a Comment