I did setup an OpenVPN server, which works fine and the IP of the server shows instead of my machine's IP.
I am using this VPN to connect to EC2 instance, and restricting access to only instances within the same VPC, for all ports including HTTP, HTTPS & SSH.
To do so, in the inbound rules I set to only accept connection from the VPC CIDR. However whenever I try to open that server, it doesn't work and I get site can't be reached.
PS: The server used to work fine, before I restrict the access from AWS Cloud Firewall.
iptables -t nat -I POSTROUTING -o eth0 -j MASQUERADEor with-s the-vpn-cidr/prefix, e.g. if the addresses inside your VPN are 10.10.10.0/24 it would be-s 10.10.10.0/24. – MLu Oct 08 '18 at 00:56-s ...altogether, it should work too. – MLu Oct 08 '18 at 00:57tcpdump -i tun0 -n host 172.31.16.185on the VPN gateway and verify that you see the packets coming in from the tunnel. Then runtcpdump -i eth0 -n host 172.31.16.185to verify that they are coming out from the VPN GW instance NAT'ed and destined to the target box. – MLu Oct 08 '18 at 01:06server 192.168.142.128 255.255.255.192– MLu Oct 08 '18 at 01:28iptables -t nat -I POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE. Delete the old rule withiptables -t nat -D POSTROUTING -s 10.10.10.0/24 -o eth0 -j MASQUERADEfirst. – MLu Oct 08 '18 at 01:33-D, not**-D**. – MLu Oct 08 '18 at 01:36tcpdump -i tun0 -non the vpn server show when you try to SSH from the client to the target server? Any traffic at all? – MLu Oct 08 '18 at 01:41tcpdump -i tun0 -n net 172.31.0.0/16– MLu Oct 08 '18 at 01:43