I have setup an OpenVPN server I want to connect to from my Mac at home. It was fairly painless and both the client and server are setup properly. The client can connect to the server just fine.

I am trying to route ALL my Internet traffic through the VPN when I'm connected to it. I did my homework and found that I need to use push "redirect-gateway def1" on the server. When I do so, I get "No route to host" when I curl any URL from the client. My SSH session with the server stays alive, however.

Here are my server and client config. What am I missing?

port 1194
proto udp
dev tun
ca /etc/openvpn/keys/ca.crt
cert /etc/openvpn/keys/server.crt
key /etc/openvpn/keys/server.key  # This file should be kept secret
dh /etc/openvpn/keys/dh1024.pem
ifconfig-pool-persist ipp.txt
keepalive 10 120
status openvpn-status.log
log-append  /var/log/openvpn.log
verb 3
;push "redirect-gateway def1"

dev tun
proto udp
remote vpn.example.com 1194
resolv-retry infinite
ca ca.crt
cert openvpn.crt
key openvpn.key
verb 3
  • is that ';' in the actual config? that i think would deactivate the line push "redirect-gateway def1" Also the last time i messed with openvpn, the 'def1' was not needed. Also you may need to push a DNS entry as well, i forget the syntax for this however. – Jimsmithkka Aug 22 '10 at 5:04

A friend just helped me with this.

Running the following 2 commands on the server worked:

echo  1 > /proc/sys/net/ipv4/ip_forward
iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE

I hope it helps someone!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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