Ubuntu – No internet access when connected to the OpenVPN server on AWS EC2 Ubuntu

networkingopenvpn

After I connect my Linux machines to my Ubuntu 16.04 VPN server on AWS ec2 instance, I loose internet connection but can ping VPN server.

server conf:

port 1194
proto udp
dev tun
ca ca.crt
cert server.crt
key server.key
dh dh2048.pem
topology subnet
server 10.8.0.0 255.255.255.0
ifconfig-pool-persist ipp.txt
client-config-dir ccd
route 10.8.0.0 255.255.255.252
push "redirect-gateway def1 bypass-dhcp"
push "dhcp-option DNS 8.8.8.8"
client-to-client
keepalive 10 120
tls-auth ta.key 0 # This file is secret
key-direction 0
cipher AES-128-CBC   # AES
auth SHA256
comp-lzo
user nobody
group nogroup
persist-key
persist-tun
status openvpn-status.log
verb 3

client config:

client
dev tun
proto udp
remote myserver 1194
resolv-retry infinite
nobind
user nobody
group nogroup
persist-key
persist-tun
remote-cert-tls server
cipher AES-128-CBC
auth SHA256
key-direction 1
comp-lzo
verb 3
Cerificates...

ccd/client:

ifconfig-push 10.8.0.26 255.255.255.0

route -n when connected to vpn:

route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.8.0.1        128.0.0.0       UG    0      0        0 tun0
0.0.0.0         172.29.25.1     0.0.0.0         UG    100    0        0 eth0
10.8.0.0        0.0.0.0         255.255.255.0   U     0      0        0 tun0
vpnserverIP   172.29.25.1     255.255.255.255 UGH   0      0        0 eth0
128.0.0.0       10.8.0.1        128.0.0.0       UG    0      0        0 tun0
172.29.25.0     0.0.0.0         255.255.255.0   U     100    0        0 eth0

ifconfig tun0:

tun0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST>  mtu 1500
    inet 10.8.0.26  netmask 255.255.255.0  destination 10.8.0.26
    inet6 fe80::c922:ab77:1b0c:5095  prefixlen 64  scopeid 0x20<link>
    unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 100  (UNSPEC)
    RX packets 0  bytes 0 (0.0 B)
    RX errors 0  dropped 0  overruns 0  frame 0
    TX packets 1039  bytes 129116 (126.0 KiB)
    TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Best Answer

  • Finaly found a solution when settings my pi as a wifi router, i knew there was firewall problem, so this lines solved traffic issues:

    -A POSTROUTING -s 10.8.0.0/16 -o eth0 -j MASQUERADE -A FORWARD -i eth0 -o tun0 -m state --state RELATED,ESTABLISHED -j ACCEPT -A FORWARD -i tun0 -o eth0 -j ACCEPT

    if using ufw transfer this rules accordingly!