I'm running raspbian on my raspberry pi model B and I have a VPN account with Private Internet Access. I've used their openvpn settings to connect (I'm using the same ones on my ubuntu laptop and everything works ok), but I can't ping anything.

I'm using the following command to connect

sudo /usr/sbin/openvpn --status /var/run/openvpn.Switzerland.status 10 --cd /etc/openvpn --config /etc/openvpn/Switzerland.conf

My config file in /etc/openvpn/Switzerland.conf looks like:

dev tun
proto udp
remote swiss.privateinternetaccess.com 1194
resolv-retry infinite
ca ca.crt
remote-cert-tls server
auth-user-pass login.conf
verb 1
reneg-sec 0
crl-verify crl.pem

The output I get is:

Sat Sep 19 14:55:25 2015 OpenVPN 2.2.1 arm-linux-gnueabihf [SSL] [LZO2] [EPOLL] [PKCS11] [eurephia] [MH] [PF_INET6] [IPv6 payload 20110424-2 (2.2RC2)] built on Dec  1 2014
Sat Sep 19 14:55:25 2015 WARNING: file 'login.conf' is group or others accessible
Sat Sep 19 14:55:25 2015 NOTE: OpenVPN 2.1 requires '--script-security 2' or higher to call user-defined scripts or executables
Sat Sep 19 14:55:25 2015 LZO compression initialized
Sat Sep 19 14:55:25 2015 RESOLVE: NOTE: swiss.privateinternetaccess.com resolves to 4 addresses
Sat Sep 19 14:55:25 2015 UDPv4 link local: [undef]
Sat Sep 19 14:55:25 2015 UDPv4 link remote: [AF_INET]
Sat Sep 19 14:55:25 2015 WARNING: this configuration may cache passwords in memory -- use the auth-nocache option to prevent this
Sat Sep 19 14:55:26 2015 [Private_Internet_Access] Peer Connection Initiated with [AF_INET]
Sat Sep 19 14:55:28 2015 TUN/TAP device tun0 opened
Sat Sep 19 14:55:28 2015 do_ifconfig, tt->ipv6=0, tt->did_ifconfig_ipv6_setup=0
Sat Sep 19 14:55:28 2015 /sbin/ifconfig tun0 pointopoint mtu 1500
Sat Sep 19 14:55:28 2015 Initialization Sequence Completed

It appears to connect, but the if I try to ping google.com or nslookup google.com in another terminal it fails. Any suggestions on anything I could have done wrong or change to get this working?

4 Answers 4


I was having the same issue as the owner of the question. As per JorgeHortelano 's answer, this thread, and this thread, I figured out how to correct my version of the issue.

First, I created a shell script names firewall.sh in /etc/init.d with the following code:

sudo iptables -t nat -A POSTROUTING -s -o eth0 -j MASQUERADE //These are the commands that fixed it for me
sudo su -c "echo 1 > /proc/sys/net/ipv4/ip_forward"

Then, I enabled the above script to be run at startup using these commands:

sudo chmod 755 /etc/init.d/firewall.sh
sudo chmod +x /etc/init.d/firewall.sh

and optionally (if it still doesn't execute on startup):

sudo update-rc.d firewall.sh defaults

Hope this helps someone if they were having the same issue I was. Please keep in mind that I am very new to linux operating systems (~24 hrs.) and what I do may not be considered "good practice."


I'm not an expert but I also had similar problems so will try and share. What happens if you run "sudo curl --interface tun0 freegeoip.net/json/"

This should force the command via the tun0 interface (your vpn tunnel).

If this returns according to the right country (eg. Switzrland in your case) then the VPN tunnel is working, and you probably have a routing issue so need to look at IPTABLES configuration.

But if it helps, this is the config I had for my vpn client on Rpi.

dev tun
proto udp

route-method exe
route-delay 2
resolv-retry infinite


auth-user-pass mypassword.txt
ca myca.crt
tls-auth ta.key 1

verb 3

tun-mtu 1350

Long time ago I have folloed up this good article to create a VPN in my raspbery pi (that I am just using now, therefore seems a good article).

Can be lot of things, but I first focus on:

  • Enable packet forwarding echo 1 > /proc/sys/net/ipv4/ip_forward.
  • Firewall issue: set forward policy as accept by default. For this, edit /etc/default/ufw and set DEFAULT_FORWARD_POLICY="ACCEPT".
  • DNS issue. In the openvpn server (server.conf), comment out push "dhcp-option DNS" but select a correct ip

As you can see, some of the proposed solutions are not related to the openvpn configuration itself, but are mandatory. Still I would recomend to take a look on the previous link. It has a real good explanation of how to solve your issue.


My thoughts would be incorrect iptables, or dns server. You may wish to try as your dns server. And be sure your iptables are configured correctly. This tutorial has iptables that worked well for me https://www.google.com/amp/s/sys.jonaharagon.com/2016/05/12/setting-up-an-openvpn-server-on-a-raspberry-pi-2-part-12/amp/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.