This guide shows how to make a SOCKS5 proxy running on the Windows host available to an Ubuntu virtual machine using VMware NAT.
It is useful when:
- The Windows application exposes a local SOCKS5 proxy such as
127.0.0.1:23321. - The Ubuntu guest cannot connect to the Windows host's loopback address.
- You only need selected applications in Ubuntu to use the proxy.
This does not create a full-device VPN inside Ubuntu. Only applications configured to use the SOCKS proxy will be routed through it.
- Host: Windows
- Guest: Ubuntu
- Hypervisor: VMware Workstation or Player
- VMware networking mode: NAT (
VMnet8) - Host-side SOCKS proxy:
127.0.0.1:23321 - Forwarded VMware-facing port:
23322
Change the ports below if your local proxy uses different values.
Open PowerShell and run:
curl.exe --proxy socks5h://127.0.0.1:23321 https://api.ipify.orgThe result should be the proxy exit IP rather than the host's ordinary public IP.
To compare it with the direct connection:
curl.exe https://api.ipify.orgIf both commands return the same address, the local SOCKS proxy may not be active.
In the VM settings:
- Open Network Adapter.
- Select NAT: Used to share the host's IP address.
- Enable Connected.
- Enable Connect at power on.
Do not use Bridged mode for this setup.
Run the following in PowerShell as Administrator:
$vmwareInterface = 'VMware Network Adapter VMnet8'
$localSocksPort = 23321
$forwardedPort = 23322
$vmwareHostIp = (
Get-NetIPAddress `
-InterfaceAlias $vmwareInterface `
-AddressFamily IPv4 `
-ErrorAction Stop |
Where-Object {
$_.AddressState -eq 'Preferred' -and
$_.IPAddress -notlike '169.254.*'
} |
Select-Object -First 1 -ExpandProperty IPAddress
)
if (-not $vmwareHostIp) {
throw 'Could not find the IPv4 address assigned to VMnet8.'
}
Set-Service iphlpsvc -StartupType Automatic
Start-Service iphlpsvc
netsh interface portproxy delete v4tov4 `
listenaddress=$vmwareHostIp `
listenport=$forwardedPort `
protocol=tcp 2>$null | Out-Null
netsh interface portproxy add v4tov4 `
listenaddress=$vmwareHostIp `
listenport=$forwardedPort `
connectaddress=127.0.0.1 `
connectport=$localSocksPort `
protocol=tcp
Get-NetFirewallRule `
-DisplayName 'SOCKS proxy for VMware' `
-ErrorAction SilentlyContinue |
Remove-NetFirewallRule
New-NetFirewallRule `
-DisplayName 'SOCKS proxy for VMware' `
-Direction Inbound `
-Action Allow `
-Protocol TCP `
-LocalAddress $vmwareHostIp `
-LocalPort $forwardedPort `
-RemoteAddress LocalSubnet `
-Profile Any | Out-Null
Write-Host ""
Write-Host "Ubuntu SOCKS proxy: socks5h://${vmwareHostIp}:$forwardedPort"
Write-Host ""
netsh interface portproxy show allThe script prints an address similar to:
Ubuntu SOCKS proxy: socks5h://192.168.xxx.1:23322
Use the address shown on your own system. Do not copy the example address literally.
$if='VMware Network Adapter VMnet8';$src=23321;$dst=23322;$ip=(Get-NetIPAddress -InterfaceAlias $if -AddressFamily IPv4 -ErrorAction Stop|Where-Object {$_.AddressState -eq 'Preferred' -and $_.IPAddress -notlike '169.254.*'}|Select-Object -First 1 -ExpandProperty IPAddress);if(!$ip){throw 'VMnet8 IPv4 address not found'};Set-Service iphlpsvc -StartupType Automatic;Start-Service iphlpsvc;netsh interface portproxy delete v4tov4 listenaddress=$ip listenport=$dst protocol=tcp 2>$null|Out-Null;netsh interface portproxy add v4tov4 listenaddress=$ip listenport=$dst connectaddress=127.0.0.1 connectport=$src protocol=tcp;Get-NetFirewallRule -DisplayName 'SOCKS proxy for VMware' -ErrorAction SilentlyContinue|Remove-NetFirewallRule;New-NetFirewallRule -DisplayName 'SOCKS proxy for VMware' -Direction Inbound -Action Allow -Protocol TCP -LocalAddress $ip -LocalPort $dst -RemoteAddress LocalSubnet -Profile Any|Out-Null;Write-Host "Ubuntu SOCKS proxy: socks5h://${ip}:$dst";netsh interface portproxy show allReplace VMNET8_HOST_IP with the address printed by PowerShell:
curl --proxy socks5h://VMNET8_HOST_IP:23322 https://api.ipify.org
echoExample format:
curl --proxy socks5h://192.168.xxx.1:23322 https://api.ipify.org
echoThe result should match the IP returned by this Windows command:
curl.exe --proxy socks5h://127.0.0.1:23321 https://api.ipify.orgUse socks5h rather than socks5 when possible so DNS lookups are also performed through the proxy.
export ALL_PROXY="socks5h://VMNET8_HOST_IP:23322"
export all_proxy="$ALL_PROXY"Test it:
curl https://api.ipify.org
echoRemove the variables later with:
unset ALL_PROXY all_proxychromium --proxy-server="socks5://VMNET8_HOST_IP:23322"google-chrome --proxy-server="socks5://VMNET8_HOST_IP:23322"Open:
Settings → Network Settings → Settings
Set:
Manual proxy configuration
SOCKS Host: VMNET8_HOST_IP
Port: 23322
SOCKS v5: enabled
Proxy DNS when using SOCKS v5: enabled
Direct traffic:
env -u ALL_PROXY -u all_proxy curl https://api.ipify.org
echoProxied traffic:
curl --proxy socks5h://VMNET8_HOST_IP:23322 https://api.ipify.org
echoThe two addresses should normally differ.
To remove the Windows port-forwarding rule and its firewall rule, open PowerShell as Administrator and run:
$ip = (
Get-NetIPAddress `
-InterfaceAlias 'VMware Network Adapter VMnet8' `
-AddressFamily IPv4 |
Where-Object {
$_.AddressState -eq 'Preferred' -and
$_.IPAddress -notlike '169.254.*'
} |
Select-Object -First 1 -ExpandProperty IPAddress
)
netsh interface portproxy delete v4tov4 `
listenaddress=$ip `
listenport=23322 `
protocol=tcp
Get-NetFirewallRule `
-DisplayName 'SOCKS proxy for VMware' `
-ErrorAction SilentlyContinue |
Remove-NetFirewallRule$ip=(Get-NetIPAddress -InterfaceAlias 'VMware Network Adapter VMnet8' -AddressFamily IPv4|Where-Object {$_.AddressState -eq 'Preferred' -and $_.IPAddress -notlike '169.254.*'}|Select-Object -First 1 -ExpandProperty IPAddress);netsh interface portproxy delete v4tov4 listenaddress=$ip listenport=23322 protocol=tcp;Get-NetFirewallRule -DisplayName 'SOCKS proxy for VMware' -ErrorAction SilentlyContinue|Remove-NetFirewallRuleConfirm the forwarding rule is gone:
netsh interface portproxy show allInside Ubuntu, clear proxy environment variables from the current shell:
unset ALL_PROXY all_proxy HTTP_PROXY HTTPS_PROXY http_proxy https_proxyAlso:
- Close browser instances launched with
--proxy-server. - Remove any manual SOCKS settings from Firefox or other applications.
- Closing the Windows proxy application stops traffic temporarily, but the Windows forwarding rule remains until you remove it with the command above.
Run PowerShell as Administrator:
$vmwareInterface = 'VMware Network Adapter VMnet8'
$forwardedPort = 23322
$vmwareHostIp = (
Get-NetIPAddress `
-InterfaceAlias $vmwareInterface `
-AddressFamily IPv4 |
Where-Object {
$_.AddressState -eq 'Preferred' -and
$_.IPAddress -notlike '169.254.*'
} |
Select-Object -First 1 -ExpandProperty IPAddress
)
netsh interface portproxy delete v4tov4 `
listenaddress=$vmwareHostIp `
listenport=$forwardedPort `
protocol=tcp
Get-NetFirewallRule `
-DisplayName 'SOCKS proxy for VMware' `
-ErrorAction SilentlyContinue |
Remove-NetFirewallRuleCheck that it has been removed:
netsh interface portproxy show allConfirm that the local SOCKS proxy is listening on Windows:
Get-NetTCPConnection -LocalPort 23321 -State ListenYou can also check with:
netstat -ano | findstr :23321Then confirm the forwarded port is listening:
Get-NetTCPConnection -LocalPort 23322 -State ListenCheck:
netsh interface portproxy show all
Get-Service iphlpsvc
Get-NetFirewallRule -DisplayName 'SOCKS proxy for VMware'The IP Helper service should be running.
VMware can change the address assigned to VMnet8. Re-run the PowerShell setup script so the forwarding rule uses the current address.
A browser may have its own proxy configuration. Terminal applications will not automatically inherit it.
Set:
export ALL_PROXY="socks5h://VMNET8_HOST_IP:23322"Some programs do not support SOCKS proxies directly and may require a wrapper such as proxychains4.
Windows netsh interface portproxy forwards TCP only. It does not forward UDP. SOCKS-based applications that require UDP may therefore fail or fall back to a direct connection.
- Bind the forwarding rule only to the
VMnet8address, not to0.0.0.0. - Restrict the firewall rule to
LocalSubnet. - Do not expose an unauthenticated SOCKS proxy to public or untrusted networks.
- Remove the forwarding and firewall rules when they are no longer needed.
- Treat the proxy exit IP as sensitive if it is tied to an account, subscription, or private endpoint.
- Verify DNS behavior with an appropriate leak-testing service before relying on the setup for privacy-sensitive work.
This setup makes a host-side SOCKS proxy reachable from the Ubuntu guest. It does not transparently route the entire Ubuntu operating system.
Only applications that explicitly use:
socks5h://VMNET8_HOST_IP:23322
will be proxied.