- Add network (
vmnet3
) to VMware Fusionsudo vi /Library/Preferences/VMware\ Fusion/networking
answer VNET_1_HOSTONLY_SUBNET 172.16.92.0 answer VNET_1_VIRTUAL_ADAPTER yes answer VNET_1_VIRTUAL_ADAPTER_ADDR 172.16.92.1 +answer VNET_3_DHCP yes +answer VNET_3_DHCP_PARAM_DNS_ADDR 172.16.12.1 +answer VNET_3_DHCP_PARAM_ROUTERS 172.16.12.1 +answer VNET_3_HOSTONLY_NETMASK 255.255.255.0 +answer VNET_3_HOSTONLY_SUBNET 172.16.12.0 +answer VNET_3_NAT yes +answer VNET_3_VIRTUAL_ADAPTER yes +answer VNET_3_VIRTUAL_ADAPTER_ADDR 172.16.12.1 answer VNET_8_DHCP yes answer VNET_8_DHCP_CFG_HASH 233D9DA58316AF2F99389DF3E1C86B1A08F9D28A answer VNET_8_HOSTONLY_NETMASK 255.255.255.0
sudo /Applications/VMware\ Fusion.app/Contents/Library/vmnet-cli --configure
sudo /Applications/VMware\ Fusion.app/Contents/Library/vmnet-cli --start
- Setup
dnsmasq
as DNS server onvmnet3
brew install dnsmasq
mkdir -p /usr/local/var/dnsmasq
- In
/usr/local/etc/dnsmasq.conf
add:# Interface interface=vmnet3 except-interface=lo0 listen-address=172.16.12.1 # DNS server # Never forward plain names (without a dot or domain part) domain-needed # Never forward addresses in the non-routed address spaces. bogus-priv # Never poll /etc/resolv.conf for changes no-poll
sudo brew services start dnsmasq
- Enable ip forwarding and NAT
- In
/etc/sysctl.config
add:net.inet.ip.forwarding=1
sudo sysctl net.inet.ip.forwarding=1
- In
/etc/pf.conf
underrdr-anchor “com.apple/*”
add:nat on en1 proto {tcp, udp} from 172.16.12.0/24 to any -> (en1) rdr on vmnet3 inet proto tcp from any to any port 80 -> 127.0.0.1 port 8888 rdr on vmnet3 inet proto tcp from any to any port 443 -> 127.0.0.1 port 8888 pass from {lo0, 172.16.12.0/24} to any keep state
sudo pfctl -ef /etc/pf.conf
- In
Last active
April 3, 2023 06:59
-
-
Save norio-nomura/d85aa86fab8aa56a2f1a4e02909955ca to your computer and use it in GitHub Desktop.
Setup transparent proxy with VMware Fusion
This setting implicitly expects some Proxy Server to be listening on 127.0.0.1:8888
.
When I wrote this, I would have used Charles Proxy.
Checking the Proxy server logs may reveal the cause.
Thanks @norio-nomura, I have a proxy server listening to the port I specified.
I'll check proxy logs.
BTW sudo /Applications/VMware\ Fusion.app/Contents/Library/vmnet-cli --start
works when VM is turned on.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey @norio-nomura,
Thanks for your effort writing this gist, I get this error when I change my VM network to vmnet3.
Appreciate any thoughts on how to resolve it.