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

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.

share|improve this question
    
I'm forming a bridge from computers to the Internet, to provide access to items they wouldn't ordinarily have. –  Matt Culbreth Jul 3 '12 at 19:12

2 Answers 2

up vote 1 down vote accepted

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.

share|improve this answer
    
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? –  Matt Culbreth Jul 3 '12 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. –  Matt Culbreth Jul 3 '12 at 20:00

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.

share|improve this answer
    
The last bit of the openvpn log looks like this: –  Matt Culbreth Jul 3 '12 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 –  Matt Culbreth Jul 3 '12 at 19:18
    
Did not work. Hmm. Using curl --interface tun0 works just fine, but adding this routing rule did not. –  Matt Culbreth Jul 3 '12 at 22:23

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.