title: Amazon EC2 Ubuntu 12.04 - unable to route all traffic through OpenVPN
body: <p>I'm trying to use OpenVPN on my remote Ubuntu 12.04 web server, but as soon as OpenVPN is running, I can't connect to the internet. </p>
  
  <p>Befor starting OpenVPN, route says:</p>
  
  <pre><code>Kernel IP routing table
  Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
  default         ip-172-31-16-1. 0.0.0.0         UG    100    0        0 eth0
  172.31.16.0     *               255.255.240.0   U     0      0        0 eth0
  </code></pre>
  
  <p>and after:</p>
  
  <pre><code>Kernel IP routing table
  Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
  default         10.200.4.1      128.0.0.0       UG    0      0        0 tun0
  default         172.31.16.1     0.0.0.0         UG    100    0        0 eth0
  10.200.4.0      *               255.255.252.0   U     0      0        0 tun0
  128.0.0.0       10.200.4.1      128.0.0.0       UG    0      0        0 tun0
  172.31.16.0     *               255.255.240.0   U     0      0        0 eth0
  184.170.137.2   172.31.16.1     255.255.255.255 UGH   0      0        0 eth0
  </code></pre>
  
  <p>184.170.137.2 is the VPN. The OpenVPN HOWTO suggests to use</p>
  
  <pre><code>iptables -t nat -A POSTROUTING -s 10.200.4.0/22 -o eth0 -j MASQUERADE
  </code></pre>
  
  <p>which throws</p>
  
  <pre><code>sudo: unable to resolve host ip-172-31-26-178 
  </code></pre>
  
  <p>(172.31.26.178 is the internal IP).</p>
  
  <p>If I do the following, I can use the VPN for a single website: </p>
  
  <pre><code>route add -net {website ip} netmask 255.255.255.255 gw 10.200.4.1 dev tun0
  route del -net 0.0.0.0 netmask 128.0.0.0 dev tun0
  route del -net 128.0.0.0 netmask 128.0.0.0 dev tun0 
  </code></pre>
  
  <p>How can I change this to work for the whole web? Help is greatly appreciated.</p>