# VMWare (2 subnets)

## Bender007

Hey

i have following problem. I want to access a webserver through my linux gentoo server...

I have a gentoo box 192.168.0.1 with a installed vmware server 192.168.0.10 and clients log in through openvpn 192.168.10.0 i want to access the webserver which is installed on 192.168.0.10 from openvpn 192.168.10.1... is it possible to set up the apache2 to "redirect" from 192.168.0.10 to 192.168.10.0. The thing is i can't connect to 192.168.0.10 because when i am connect with VPN i am in another net range.

I could use bridge mode on vmware server but on the vmware and gentoo box running a samba server. 

i hope someone could help me... Can the apache2 redirect me to the vmware box in another net range? The connection from 192.168.0.1 to 192.168.0.10 is no problem i can access the data etc. ... For example if i want to access the data on 192.168.0.10 from 192.168.10.0 i can make a samba share on the gentoo box(192.168.0.1 to 192.168.0.10) to reach it from openpn because samba is listing on both addresses ... but can Apache2 ?

thx benderLast edited by Bender007 on Thu Apr 10, 2008 6:35 pm; edited 1 time in total

----------

## elgato319

 *Bender007 wrote:*   

> The thing is i can't connect to 192.168.0.10 because when i am connect with VPN i am in another net range.
> 
> 

 

I'm not quite sure what you mean. Can you (192.168.10.1) ping the webserver(192.168.0.10) via openvpn?

Maybe this can be solved via a route to the 192.168.0.0 network

----------

## Dagger

If I get you right you want to access VM server 192.168.0.10 from openvpn (192.168.10.0) subnet.

are you going to run a (second) web server on your gentoo box (192.168.0.1) for openvpn users (192.168.10.0) ?

If yes you could use squid

if not (if you want openvpn users to have access to VM web server (192.168.0.10) and NOT gentoo (192.168.0.1) server I would suggest iptables

You need a few basic rules like

```

########################################################

IPTABLES="/sbin/iptables"

VPN_IF="tun0"

LAN_IF="eth0"

VM_IP="192.168.0.10"

VPN_NET="192.168.10.0/24"

VPN_SRV="192.168.10.1"

########################################################

#PREROUTING

$IPTABLES -t nat -A PREROUTING -i $VPN_IF -s $VPN_NET -d $VPN_SRV -p tcp --dport 80 -j DNAT --to-destination $VM_IP:80

#FORWARD

$IPTABLES -A FORWARD -i $VPN_IF -o $LAN_IF -s $VPN_NET $VM_IP -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT

$IPTABLES -A FORWARD -i $LAN_IF -o $VPN_IF -s $VM_IP -d $VPN_NET -m state --state ESTABLISHED,RELATED -j ACCEPT

#POSTROUTING

$IPTABLES -t nat -A POSTROUTING -o $LAN_IF -s $VM_IP -d $VPN_NET -p tcp --sport 80 -j SNAT --to-source $VPN_SRV:80

```

that way every time you will try to access your VPN server (192.168.10.1) from VPN it will connect you with apache on you VM

also you might want to set up a local dns on your gentoo box (bind, dnsmasq) listening on 192.168.10.1 (vpn server ip) just for VPN users and add all dns names handled by your apache.

that way you can type (for example) http://vmserver in your openvpn client browser and it will redirect you to specific VHOST of your VM apache server.

you will need this line in your openvpn config to make it work than

```

push "dhcp-option DNS 192.168.10.1"

```

----------

## Bender007

mhh thanks for your posts. When i connected with openvpn to my Gentoo Box i have created a routing rule to ping to 192.168.0.0. I can conncet to my gentoo box from 192.168.10.0 to 192.168.0.0. i don't know if i can use a routing rule to conncet to 192.168.0.10 because the pc from i connect to my server is in this range (192.168.0.0) i think it could make problems... thank you dagger but wow i have a lot to do for a simple redirect^^... dagger have i to configure all stuff like iptables and dns or dns or iptables? for a simple redirect its to complicated  :Sad:  ... what else can i do?

----------

## nobspangle

sounds like you need to add a route to your server on 192.168.0.10 so that it can reach the 192.168.10.0 subnet used by your openvpn

----------

## Bender007

mhh only a route this is cool because installing dns or complex apache configuration is a littlebit extreme  :Very Happy:  ... i'am not really a routing pro can you tell me how the routing parameter for openvpn? 

thanks a lot bender

----------

## Dagger

lol everything depends how much you want to "share" with VPN users. The best rule is... DONT TRUST ANYONE  :Very Happy: 

the setup i provided would be quite a flexible solution for a bigger group of vpn users. If you prefer your VPN users to have DIRECT access to your 192.168.0.10 (VM IP) that adding

```

push "route 192.168.0.10 255.255.255.255"

```

to your openvon.conf will solve your problem.

But you need to remember if you won't use DNS you have to modify your windows host file (c:\windows\system32\drivers\etc\hosts) to add your vm hostname (unless you want to play with 192.168.0.10 all the time)

```

192.168.0.10    myVPNvm # <- out your name here

```

regards

----------

## sf_alpha

Have you enabled ip_forward ?

echo 1 > /proc/sys/net/ip_forward

change net.ipv4.ip_forward = 1 in /etc/sysctl.conf

---

If you OpenVPN client machine is also on 192.168.0.x network (which physically not the same network of you gentoo box).

You have problems because your server have 192.168.0.x and your home network is 192.168.0.x, is the same.

But solution is easy, you can change you network of vmware and your server to other network not 192.168.0.x.

Be sure that you have enabled ip_forward above.

More advance setup can done with DHCP server and bridged OpenVPN tap to your network. You can even access share directly without entering IP address  :Very Happy: . But I think you should try change network first.

----------

## Bender007

yes i have enabled IP_forward.

i tried the solution with push ... but it didn't worked for me.

i can't ping 192.168.0.10 from 192.168.10.2

Ok i have a gentoo box 192.168.0.1 with a vmware server 192.168.0.10

And OpenVPN      TAP0  192.168.10.1 clients 192.168.10.2-10

i need to connect to the vmware server from my local lan 192.168.0.0.

But i want also connect to my VMware server through openVPN. from 192.168.10.2 to 192.168.0.10  

What i have to do?  bridge the Vmware or something like this. 

The Problem is that i need to connect to my vmware server from 192.168.0.0 and from 192.168.10.0

There is no web server on my gentoo box its a email messaging software called Tobit David. 

I Want to reach from my home LAN 192.168.0.0 and from VPN LAN 192.168.10.0. 

Anyone idea?

----------

