Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

## SERVER
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
server 10.8.0.0 255.255.255.0
ifconfig-pool-persist ipp.txt
keepalive 10 120
comp-lzo
persist-key
persist-tun
status openvpn-status.log
log-append  /var/log/openvpn.log
verb 3
;push "redirect-gateway def1"

## CLIENT
client
dev tun
proto udp
remote vpn.example.com 1194
resolv-retry infinite
nobind
persist-key
persist-tun
ca ca.crt
cert openvpn.crt
key openvpn.key
comp-lzo
verb 3
share|improve this question
    
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

1 Answer 1

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!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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