1

I've been looking for a solution to my problem but I'm not sure if I'm asking the right questions or whether this is possible at all.

I've got a linksys router running openwrt. When some of my co-workers and I are doing a business trip, I take that router with me. At the venues where we have to work, I can plug my router'S WAN port on the local network of the venue and me and co-workers plug our computer to my openwrt router.

This works very well. But sometimes we need to access company computer through vpn and in this case everybody has to do his/her own vpn connection. I would rather make the vpn connection on my openwrt router and share that to my co-workers. Making a vpn connection on the vpn is not a problem, sharing it has been more difficult.

I don't want to route all of the traffic through VPN, I just want people behind my NAT to access the companies's network as if they did the vpn connection themselves. I also configured my openvpn config file so that the whole traffic does not get routed through the VPN (because this is very slow), I just want to access companies network.

On my computer:

$ openvpn myconfig.vpn
...
/sbin/ip link set dev tun0 up mtu 1500
/sbin/ip addr add dev tun0 192.168.30.2/24 broadcast 192.168.30.255
/sbin/ip route add <company's IP>/32 via 192.168.25.1
/sbin/ip route add 192.168.0.0/24 via 192.168.30.1
Initialization Sequence Completed

192.168.25.1 is my default gateway. The company's network is 192.168.0.0/24.

On my notebook I installed the isc-dhcp-server. I added

iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
iptables --append FORWARD --in-interface in0 -j ACCEPT

where in0 is the network interface other computers would connect to. in0 is configured to 192.168.15.1/24.

I created a VirtualBox VM in bridged mode to in0 and started the VM. It gets an IP (192.168.15.100) from my dhcp server and I can access the internet from the VM without a problem. Inside my notebook I can do ping 192.168.0.9 which is a computer on my company's network. If I do the same on the VM, ping blocks.

That's where I don't know how to proceed. I've found a lot of threads where people want to route all their traffic through vpn. I on the other hand, I don't want to do that, I just want to access 192.169.0.9 from my VM. What I want is that when a request to an IP in 192.168.0.0/24 comes in through in0, I want to route it to the vpn tunnel and not to my gateway 192.168.25.1. Is this even possible and if so how?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.