Friday, 15 September 2017

macos - How to configure Mac to route external IP requests to different interfaces?

I am currently setting up a Mac at home. It has a static IP of 10.0.1.254.


This Mac has a VPN connection to my workplace via tunnelblick (192.168.1.x and 192.168.2.x). This Mac can also run a few of my VM's (192.168.170.x).


While on another laptop (also a Mac) on the same network (10.0.1.x), I want to be able to connect to my workplace and to VM via this Mac.


On my laptop, I first tried to setup a routing rule:


sudo route -v add 192.168.170.163 10.0.1.254

On the Mac, I tried to enable IP forwarding, and even bridging:


sudo sysctl -w net.inet.ip.forwarding=1
sudo sysctl -w net.inet6.ip6.forwarding=1
sudo sysctl -w net.link.ether.inet.proxyall=1
sudo ifconfig bridge0 create
sudo ifconfig bridge0 addm en0
sudo ifconfig bridge0 addm vmnet2
sudo ifconfig bridge0 up

However, when I tried to access the URL http://192.168.170.163:80/ from my laptop, I don't seem to be routed to the VM on the Mac.


The tunnelblick experiment was worse, as I can't add it to the bridged network.


I could workaround with the VMware Fusion's nat.conf, or port forwarding via SSH, but prefer to avoid those as I want to preserve the IP address I am accessing via, and avoid too much configuration in /etc/hosts.


Is there something wrong with my concept/understanding? Is this not a problem that is solved via bridged network and IP forwarding?


Update:


I have performed a workaround:
1. My Mac (10.0.1.254) hosts a Windows 2003 Std Edition Server VM (10.0.1.253) with Routing Service enabled.
2. The Routing Service Windows VM has two network interfaces, 10.0.1.253 and 192.168.170.253.
3. My other VMs (192.168.170.253) configure the default gateway as 192.168.170.253.
4. My laptop on the network 10.0.1.x performs static routing for from 192.168.170.x to 10.0.1.253.

No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...