Configure OpenVPN like Hamachi (not tunnel to Internet)

Need help configuring your VPN? Just post here and you'll get that help.

Moderators: TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech

Forum rules
Please use the [oconf] BB tag for openvpn Configurations. See viewtopic.php?f=30&t=21589 for an example.
Post Reply
beagle72
OpenVpn Newbie
Posts: 2
Joined: Sat Sep 22, 2012 11:51 pm

Configure OpenVPN like Hamachi (not tunnel to Internet)

Post by beagle72 » Sun Sep 23, 2012 12:00 am

Hi,

I hope I can explain this clearly. I currently have a VPS running OpenVPN. I am not an expert at this but I configured it following various online tutorials, and it works. I can connect to the VPN from various devices. Network services are tunneled through the VPS to the Internet. Cool.

I have been playing with Hamachi. Installing the Hamachi client on various machines, they can see each other as a virtual LAN. Share files, intranet services, etc. But each machine is using its own outgoing Internet connection -- services to the Internet are not being tunneled from Hamachi.

I want to setup something like this using OpenVPN. In other words, for multiple devices running the OpenVPN client connected the OpenVPN server to be connected as a virtual LAN but NOT route Internet activity by tunneling through the server. For one thing, that is too slow. When I am on my home broadband I don't want or need to tunnel through the VPN to the Internet, but I do want to be on a virtual LAN with other machines connected to my server from other locations.

Any clues or advice how to configure OpenVPN in this way? Ideally I'd like to be able to switch between both scenarios as needed (with and without tunneling to Internet).

thanks!

User avatar
maikcat
Forum Team
Posts: 4200
Joined: Wed Jan 12, 2011 9:23 am
Location: Athens,Greece
Contact:

Re: Configure OpenVPN like Hamachi (not tunnel to Internet)

Post by maikcat » Mon Sep 24, 2012 6:51 am

hi there,

this is a very simple setup,
DONT use redirect-gateway statement and use client-to-client inside server config...

for this to work you need server directive.

Michael.
Amiga 500 , Zx +2 owner
Long live Dino Dini (Kick off 2 Creator)

Inflammable means flammable? (Dr Nick Riviera,Simsons Season13)

"objects in mirror are losing"

nchall
OpenVpn Newbie
Posts: 8
Joined: Tue Jul 10, 2012 3:50 am

Re: Configure OpenVPN like Hamachi (not tunnel to Internet)

Post by nchall » Fri Oct 19, 2012 4:52 am

I am trying to accomplish this same thing: use OpenVPN instead of Hamachi on all my devices to be assigned a private ip 10.8.x.x whether the device is on the lan or wan. To do this I am using dyndns.org to give the router running the OpenVPN server a static ip.

My problem is that I am able to connect to the VPN server when I am outside the lan, but when I am inside the lan I get an error saying the expected ip is different. It is looking for the dyndns.org external ip, and not the ip that the router running the OpenVPN server has on the lan. So 192.168.1.1 instead of the public wan ip that the dyndns.org service is forwarding to.

When I put "float" which is what is suggested in the log into the client config I am not able to access the internet from the lan.

Clearly I have some issues. Any help would be appreciated.

Thanks.

User avatar
Mimiko
Forum Team
Posts: 1564
Joined: Wed Sep 22, 2010 3:18 am

Re: Configure OpenVPN like Hamachi (not tunnel to Internet)

Post by Mimiko » Mon Oct 22, 2012 10:50 am

If you really need to use OpenVPN connection when clients are in the lan, then masquerade the port used to connect on the lan's router, ie. if a connection attempt to router's external ip is from internal, then masquerade that packet.

nchall
OpenVpn Newbie
Posts: 8
Joined: Tue Jul 10, 2012 3:50 am

Re: Configure OpenVPN like Hamachi (not tunnel to Internet)

Post by nchall » Mon Oct 22, 2012 5:43 pm

Would you mind giving a little more information on how to do that? I'm not familiar with the term. Thank you.

User avatar
Mimiko
Forum Team
Posts: 1564
Joined: Wed Sep 22, 2010 3:18 am

Re: Configure OpenVPN like Hamachi (not tunnel to Internet)

Post by Mimiko » Tue Oct 23, 2012 7:36 am

That might be:

Code: Select all

iptables -t nat -A PREROUTING -i eth0<lan interface> -p <udp or tcp> --dport <VPN port> -j DNAT --to-destination <lan's ip>

nchall
OpenVpn Newbie
Posts: 8
Joined: Tue Jul 10, 2012 3:50 am

Re: Configure OpenVPN like Hamachi (not tunnel to Internet)

Post by nchall » Sat Oct 27, 2012 1:34 am

Thanks. I will try and make sense of that. One other question though:

If the computer running the OpenVPN client is on the wan and the computer I want to connect to is behind the router running the OpenVPN server on the lan, how do they connect? Seems like the computer running the client on the LAN gets a private IP that is separate from the one on the LAN.

Thanks.

User avatar
Mimiko
Forum Team
Posts: 1564
Joined: Wed Sep 22, 2010 3:18 am

Re: Configure OpenVPN like Hamachi (not tunnel to Internet)

Post by Mimiko » Mon Nov 05, 2012 7:43 am

The client and server may communicate directly by theirs tunnels assigned ip.

nchall
OpenVpn Newbie
Posts: 8
Joined: Tue Jul 10, 2012 3:50 am

Re: Configure OpenVPN like Hamachi (not tunnel to Internet)

Post by nchall » Mon Nov 05, 2012 4:39 pm

But won't the one behind the LAN not get a private IP in this scenario?

Say OpenVPN is assigning 10.8.x.x to the one on the WAN and the router is assigning 192.168.x.x to the one on the LAN. These wouldn't be able to talk, I imagine.

nchall
OpenVpn Newbie
Posts: 8
Joined: Tue Jul 10, 2012 3:50 am

Re: Configure OpenVPN like Hamachi (not tunnel to Internet)

Post by nchall » Tue May 28, 2013 4:42 pm

Never received a reply to this. Will running OpenVPN behind the LAN still cause the same problem? Thanks.

Post Reply