Community Support Forum
 
  OpenVPN.net  •  Forum Index  •  FAQ  

It is currently Wed May 16, 2012 2:58 pm




Post new topic Reply to topic  [ 5 posts ] 
 Lans behind OpenVPN 
Author Message
 Post subject: Lans behind OpenVPN
PostPosted: Sun Apr 19, 2009 12:16 am 
I should be on the dev team.
User avatar

Joined: Fri Aug 29, 2008 5:42 pm
Posts: 652
I made a document to help people understand everything they need to know about setting up a routed VPN where there are LANs behind OpenVPN.
http://www.secure-computing.net/wiki/in ... PN/Routing

YOU MUST COMPLETELY READ THIS TO UNDERSTAND IT.

Also, dont expect it to walk you through your exact configuration, it exists to teach you about the different options you may need, not to hold your hand.

With that said, this is the place to discuss it.


Offline
 Profile  
 
 Post subject: Re: Lans behind OpenVPN
PostPosted: Fri Mar 18, 2011 5:45 pm 
OpenVpn Newbie

Joined: Wed Mar 16, 2011 1:27 pm
Posts: 8
Well thanks a LOT for this clarification. Just as usual, things become more clear when repeated twice: first time in the official HOWTO and second time here.

Regards,
Kostya


Offline
 Profile  
 
 Post subject: Re: Lans behind OpenVPN
PostPosted: Wed Mar 23, 2011 12:14 am 
OpenVpn Newbie

Joined: Tue Mar 22, 2011 10:47 pm
Posts: 1
Following instructions, I got the 1st part down
Quote:
YOU MUST COMPLETELY READ THIS ...

& I've read through this article a couple of times, and am pretty sure it's relevant -- but not directly applicable -- to my setup.

Not doing so good on the 2nd part
Quote:
... TO UNDERSTAND IT.


I've managed to completely confuse myself so far.

I have:
(1) a local LAN with one desktop & one mail-server, behind a firewall/router.
(2) a remote/hosted Server running a firewall & one web-server

My ascii-art depiction of the system is below.

I want to:
(a) Setup the Hosted Server as an OpenVPN server
(b) Ping from server <-> desktop/client over VPN
(b) access the web server @ a privateIP over an OpenVPN link from the Desktop, i.e., http://10.2.3.4
(c) 'connect/redirect' the HostedServer's port:25 over a 2nd OpenVPN link to the MailServer's port:25.
so mail sent TO 1.2.3.4:25 gets TO the MailServer on the LAN, &
mail sent FROM the MailServer on the LAN appears to originate from the HostedServer @ 1.2.3.4:25

I'm pretty certain I've badly screwed up some combination of routing and firewall rules :-(

I'm hoping to get some guidance as to how to fix what I've done to get it all working.

Here's more info --

ASCII art:
Code:
Hosted Server:
|---------------------------|
| Server (Linux):           |
|        eth0 = 1.2.3.4/24 -|---> (Internet)
|                  |        |
|    Apache -- (listen)     |
|                  |        |
|        tap0 = 10.2.3.4/24 |
|---------------------------|


Office LAN:
|-----------------------------------|
| Router/Firewall (FreeBSD):        |
|   tun0 (pppoe/dsl)= 5.6.7.201/29 -|---> (Internet)
|         |                         |
|       pf firewall                 |
|         |                         |
|   sis0: 10.30.8.1/24 -------|     |
|-----------------------------------|
                              |
                              |---------------------------------------|
                              |                                       |
|--------------------------------|      |--------------------------------|
| Desktop (Linux):            |  |      | MailServer (Linux):         |  |
|   eth0   = 10.30.8.101/24 --|  |      |   eth0   = 10.30.8.110/24 --|  |
|   eth0:1 = 10.101.0.101/24     |      |   eth0:1 = 10.110.0.110/24     |
|--------------------------------|      |--------------------------------|


The pre-OpenVPN routing tables are:

@ HostedServer:
Code:
netstat -nr
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
1.2.3.0         0.0.0.0         255.255.255.0   U         0 0          0 eth0
10.2.3.0        0.0.0.0         255.255.255.0   U         0 0          0 tap0
127.0.0.0       0.0.0.0         255.0.0.0       U         0 0          0 lo
0.0.0.0         1.2.3.1         0.0.0.0         UG        0 0          0 eth0


@ OfficeLAN's Router/Firewall:
Code:
netstat -nr
Kernel IP routing table
Destination        Gateway            Flags    Refs      Use  Netif Expire
default            152.166.181.133    UGS         0  1797052   tun0
5.6.7.201          152.166.181.133    UGS         0        0   tun0
5.6.7.202          152.166.181.133    UGS         0        0   tun0
5.6.7.203          152.166.181.133    UGS         0        0   tun0
5.6.7.204          152.166.181.133    UGS         0        0   tun0
5.6.7.205          152.166.181.133    UGS         0        0   tun0
127.0.0.1          127.0.0.1          UH          0     1094    lo0
152.166.181.133    5.6.7.206          UH          6        0   tun0
10.30.8/24         link#1             UC          0        0   sis0
10.30.8.1          00:00:24:c8:34:77  UHLW        1      716    lo0


As a first step, I've installed OpenVPN server on the HostedServer & the Desktop.

The configs are:

Code:
/etc/openvpn/tls-server.conf
-------------------------------------------------
local       1.2.3.4
dev         tun1
proto       udp
port        12345
mode        server
daemon
server      10.10.10.0 255.255.255.0
topology   subnet
push "route 10.2.3.0 255.255.255.0 10.10.10.1"
client-to-client
management  127.0.0.1 1195
tls-server
dh          /etc/openvpn/dh2048.pem
ca          /etc/openvpn/ca.crt
cert        /etc/openvpn/server.openvpn.dc.loc.crt
key         /etc/openvpn/server.openvpn.dc.loc.key
tls-auth    /etc/openvpn/shared.ta.key 1
auth        RSA-SHA512
cipher      AES-256-CBC
keepalive   15 45
comp-lzo
ping-timer-rem
persist-tun
persist-key
max-clients 10
client-config-dir ccd
script-security 2 system
verb   5
status      /etc/openvpn/openvpn-status.log
ifconfig-pool-persist /etc/openvpn/ipp.txt
-------------------------------------------------


Code:
/etc/openvpn/ccd/desktop.client.openvpn.dc.loc
-------------------------------------------------
ifconfig-push 10.10.10.2 255.255.255.0
iroute        10.101.0.0 255.255.255.0
-------------------------------------------------


Code:
/etc/openvpn/tls-desktop.client.conf
-------------------------------------------------
dev        tun
proto      udp
port       12345
mode       p2p
remote     1.2.3.4 12345 udp
topology   subnet
pull
remote-cert-tls server
tls-client
ca         /etc/openvpn/ca.crt
cert       /etc/openvpn/desktop.client.openvpn.dc.loc.crt
key        /etc/openvpn/desktop.client.openvpn.dc.loc.key
tls-auth   /etc/openvpn/shared.ta.key 0
auth       RSA-SHA512
cipher     AES-256-CBC
comp-lzo
persist-tun
persist-key
script-security 2 system
verb   5
status     /etc/openvpn/openvpn-status.log
-------------------------------------------------


with this config, I can bring up the openvpn connection, see the interfaces, and
ping from server to the desktop's VPN endpoint.

i can NOT ping from the desktop to the server's VPN endpoint, or beyond it to the webserver.

@ HostedServer
Code:
ifconfig tun1
tun1     Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 
          inet addr:10.10.10.1  P-t-P:10.10.10.1  Mask:255.255.255.0
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
netstat -rn | egrep -i "tun|tap"
10.10.10.0      0.0.0.0         255.255.255.0   U         0 0          0 tun1
10.2.3.0        0.0.0.0         255.255.255.0   U         0 0          0 tap0

ping -c 1 10.10.10.2
PING 10.10.10.2 (10.10.10.2) 56(84) bytes of data.
64 bytes from 10.10.10.2: icmp_req=1 ttl=64 time=17.9 ms
ping -c 1 10.2.3.4
PING 10.2.3.4 (10.2.3.4) 56(84) bytes of data.
64 bytes from 10.2.3.4: icmp_req=1 ttl=64 time=0.050 ms


@ Desktop
Code:
ifconfig tun0
tun0     Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 
          inet addr:10.10.10.2  P-t-P:10.10.10.2  Mask:255.255.255.0
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
netstat -rn | grep -i tun
10.10.10.0      0.0.0.0         255.255.255.0   U         0 0          0 tun0
10.2.3.0        10.10.10.1      255.255.255.0   UG        0 0          0 tun0

ping -c 1 10.101.0.101
PING 10.101.0.101 (10.101.0.101) 56(84) bytes of data.
64 bytes from 10.101.0.101: icmp_req=1 ttl=64 time=0.041 ms
ping -c 1 10.10.10.1
PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data.
(just sits)


Offline
 Profile  
 
 Post subject: Re: Lans behind OpenVPN
PostPosted: Mon Dec 05, 2011 7:02 am 
OpenVpn Newbie

Joined: Thu Dec 01, 2011 2:55 pm
Posts: 1
Thank you for this illustration! It helps. I have one more request. Can you tell me how to configure this same illustrated setup with a slightly major alteration?

I wish to have the same ability to communicate from LAN to LAN to LAN in your single server and two client setup example here, however, I wish for all traffic from all LANs to be routed out only over the server gateway from a routed and not bridged network perspective. Also would like the DNS server used by the server gateway to serve all client stations in addition to the gateway. This will be for a dd-wrt setup if that is important to the solution.

Thanks in advance.


Offline
 Profile  
 
 Post subject: Re: Lans behind OpenVPN
PostPosted: Mon Apr 23, 2012 7:24 am 
I should be on the dev team.
User avatar

Joined: Fri Aug 29, 2008 5:42 pm
Posts: 652
DonJuane wrote:
Thank you for this illustration! It helps. I have one more request. Can you tell me how to configure this same illustrated setup with a slightly major alteration?

I wish to have the same ability to communicate from LAN to LAN to LAN in your single server and two client setup example here, however, I wish for all traffic from all LANs to be routed out only over the server gateway from a routed and not bridged network perspective. Also would like the DNS server used by the server gateway to serve all client stations in addition to the gateway. This will be for a dd-wrt setup if that is important to the solution.

Thanks in advance.


you would first get the lan routing working with the above document. then you would start using redirect gateway def1 on the clients (and enable nat on the server for the vpn/lan subnets). then when your clients route over the vpn, you would setup your lans to route using those clients for their default gateway (which is already normal since you said it would run on the routers).
The above document is only for routing to the lans, but the rest is not too hard. I have been meaning to make a little writeup on routing internet over vpn, but i havnt gotten around to it


Offline
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 


 Who is online 

Users browsing this forum: No registered users and 0 guests


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 post attachments in this forum

Jump to:  


phpBB SEO
[ Time : 0.062s | 11 Queries | GZIP : On ]

 
Index  |  FAQ


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group