1

I have an account with an OpenVPN service, and I'd like to get that running on my EC2 instance running Ubuntu 12.04.

I have my config file in /etc/openvpn, and it connects fine when I run sudo openvpn --config matt.ovpn. However, I then lose connectivity to the EC2 machine, and I can't SSH back to it until I reboot.

Previously I have done things like sudo ip rule add from IP_ADDRESS table 10 and then sudo ip route add default via GATEWAY_IP table 10, but that's not working on EC2.

Any ideas? My private IP address right now is 10.209.29.XXX and my gateway is 10.209.29.1.

1
  • I'm forming a bridge from computers to the Internet, to provide access to items they wouldn't ordinarily have. Jul 3, 2012 at 19:12

2 Answers 2

1

Your OpenVPN configuration probably has the redirect-gateway directive, which will change the default route to point to the VPN once the VPN has started. Remove or comment out this line to prevent this from happening.

3
  • Ok, that's close! Now I just need to get default traffic to use this VPN connection. It looks like the OpenVPN provider is using the TUN device and giving me a new 10.8.0.1 IP address. Do I just change my default gateway to something else now? Jul 3, 2012 at 19:25
  • Yeah, I just did this from a "regular" (non-AWS EC2) VPS and it worked fine. So...it's an EC2 thing with their IP addresses or routing. Hmm. Jul 3, 2012 at 20:00
  • @MattCulbreth did you solve that problem? I'm also trying to initiate a vpn connection from an EC2 Dec 10, 2015 at 23:47
0

What you are trying to do ?

Most likely openvpn overwrites your routing table so you lose connectivity. There may be other script that run the time you start openvpn.

Post your openvpn configuration and log files. It is not possible to tell more without them.

EDIT Set up specific routes for the sites you want to access via openvpn.

ip ro add someip/32 via 10.8.0.5 dev tun0

If this works for you you can put this in a start script or even better in you vpn configuration file.

3
  • The last bit of the openvpn log looks like this: Jul 3, 2012 at 19:13
  • us=691717 ROUTE default_gateway=10.209.29.1 us=692220 TUN/TAP device tun0 opened us=692244 TUN/TAP TX queue length set to 100 us=692263 do_ifconfig, tt->ipv6=0, tt->did_ifconfig_ipv6_setup=0 us=692302 /sbin/ifconfig tun0 10.8.0.6 pointopoint 10.8.0.5 mtu 1500 us=928987 /sbin/route add -net WWW.XXX.YYY.1 netmask 255.255.255.255 gw 10.209.29.1 us=931566 /sbin/route add -net 0.0.0.0 netmask 128.0.0.0 gw 10.8.0.5 Jul 3, 2012 at 19:18
  • Did not work. Hmm. Using curl --interface tun0 works just fine, but adding this routing rule did not. Jul 3, 2012 at 22:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .