OpenVPN Router to Router

Post new topic   Reply to topic    DD-WRT Forum Index -> Advanced Networking
Author Message
Grender
DD-WRT Novice


Joined: 25 Jun 2012
Posts: 3

PostPosted: Mon Jun 25, 2012 10:36    Post subject: OpenVPN Router to Router Reply with quote
I'm setting up 2 Buffalo WZR-HP-G300NH2 routers running DD-WRT (Brainslayer 18777) and want them to be linked via OpenVPN.

Using the Wiki, I've setup one router as a server and the other as a client and the OpenVPN connection works.

Each router is a DHCP and the internet gateway for it's own network.

What I want to do now is to setup the routers so that:

1) Each machine on both the client and server networks can see all other machines on both network.

2) Stop DHCP from one router assigning addresses to PCs on the other network. (I've read this could happen).

3) Make sure each router is always the gateway and DNS provider for each of it's network.

So, 2 separate networks that are linked via OpenVPN to allow each machine to be accessible to each other.

The client DHCP address range is: 192.168.150.x
The server network address range is: 192.168.200.x
The OpenVPN network address range is: 192.168.250.x

I've used the GUI for the configuration. What I think I'm missing is additional config lines such as:

push "route 192.168.200.0 255.255.255.0"

Could someone tell me what config lines I'd need? I know there's a lot of information about this but I can't figure out what I'd need to put in as a lot presume you are using the config file, not the GUI.

I've attached the settings of the server router.

Also, would I need to add hosts file entries on the machines to be able to access the machines by name?

Thanks
Sponsor
haggismn
DD-WRT User


Joined: 08 Dec 2011
Posts: 78

PostPosted: Mon Jun 25, 2012 13:58    Post subject: Reply with quote
Is the client router using the server router as the gateway? Whatever the case you need to use "topology subnet" to have full mesh vpn in tun mode. I don't see this option available in the gui, so do it manually. echo out the config in the administration>commands page. You need to have the following added something like so on the server;

Code:

server 192.168.250.0 255.255.255.0
ifconfig 192.168.250.1 255.255.255.0
topology subnet
client-config-dir /tmp/etc/ccd


Then for the ccd files, echo "iroute 192.168.200.0 255.255.255.0" > /tmp/etc/ccd/CLIENTNAME

If you arent using redirect-gateway for the client, then the ccd file also needs something like
push-reset
push "topology subnet"
push "route 192.168.250.0 255.255.255.0"

You will also need to set up the server to add a route to that subnet on the tun interface. You can use the config route command, client-connect/disconnect script, or a routing protocol with bird. All 3 work fine on dd-wrt.

Finally, also make sure that the tun interface on the client has no mention of an iptables MASQEURADE or SNAT command, so that hosts on the client router have use their own ip address to talk to the server router.

I don't have experience of it, but you can alternatively just use tap mode without much of the above. The problem is that I think you'll need to block port 67/68 to prevent dhcp requests traversing the vpn. Using tun mode is reportedly a good bit faster.

If you need more help, read the man page

Yes you need to change the hosts files another way. I suggest using mini_httpd and using route-up (client) and client-connect (server) scripts to wget the hosts files from each other on connection and using addn-hosts option on dnsmasq, followed by killall -HUP dnsmasq to reinit and read the hosts file. Alternatively just echo out the host names and IPs into the hosts file if they aren't going to change any time soon.

Good luck.
Grender
DD-WRT Novice


Joined: 25 Jun 2012
Posts: 3

PostPosted: Wed Jun 27, 2012 14:40    Post subject: Reply with quote
Thanks for the reply. I'll have to do a lot more reading to understand most of what you have posted!

The server router isn't going to be the gateway, I want each router to be it's own gateway, DHCP server etc. but then be able to browse each network at both locations.

Sounds simpler than it actually is!
Grender
DD-WRT Novice


Joined: 25 Jun 2012
Posts: 3

PostPosted: Thu Jul 05, 2012 13:30    Post subject: Reply with quote
I finally got the VPN connection between the two routers working.

This post helped a great deal.

For anyone else doing this via the GUI then this is what I did.

On the server router:

1. Under Settings/Advanced Routing I added a Static Route with the following settings.

Destination LAN: 192.168.150.0 <- client lan subnet
Subnet Mask: 255.255.255.0
Gateway: 192.168.250.2 <- client router VPN address
Interface: ANY

2. Under Services/VPN/OpenVPN Server/Daemon I added the following commands.

In Additional Config:
push "route 192.168.250.0 255.255.255.0"
push "route 192.168.200.0 255.255.255.0"
route 192.168.150.0 255.255.255.0 192.168.250.2

In CCD-Dir DEFAULT File:
iroute 192.168.150.0 255.255.255.0


On the client router:
1. Under Settings/Advanced Routing I added a Static Route with the following settings.

Destination LAN: 192.168.200.0 <- server lan subnet
Subnet Mask: 255.255.255.0
Gateway: 192.168.250.1 <- server router VPN address
Interface: ANY

I also changed the Protocol from TCP to UDP on both the server and client.

And that's it, it all worked!

I didn't require any commands for the firewall.

I'm going to experiment with what I added, see if any of the commands are redundant.

I also added entries into the PCs hosts file to allow access by name, though I might try and setup that on the router as haggismn suggested.
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Advanced Networking All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum