Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save minanagehsalalma/5b4c7f2f9e6abe388f1850bef30e9470 to your computer and use it in GitHub Desktop.

Select an option

Save minanagehsalalma/5b4c7f2f9e6abe388f1850bef30e9470 to your computer and use it in GitHub Desktop.
Share a Windows SOCKS5 proxy with an Ubuntu VMware guest using VMnet8 port forwarding (Tuxler VPN)

Share a Windows-Only SOCKS Proxy with an Ubuntu VMware Guest

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.

Tested layout

  • 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.


1. Confirm the SOCKS proxy works on Windows

Open PowerShell and run:

curl.exe --proxy socks5h://127.0.0.1:23321 https://api.ipify.org

The 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.org

If both commands return the same address, the local SOCKS proxy may not be active.


2. Keep the Ubuntu VM on VMware NAT

In the VM settings:

  1. Open Network Adapter.
  2. Select NAT: Used to share the host's IP address.
  3. Enable Connected.
  4. Enable Connect at power on.

Do not use Bridged mode for this setup.


3. Forward the local SOCKS port to VMware's NAT interface

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 all

The 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.

Compact one-liner

$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 all

4. Test the forwarded proxy from Ubuntu

Replace VMNET8_HOST_IP with the address printed by PowerShell:

curl --proxy socks5h://VMNET8_HOST_IP:23322 https://api.ipify.org
echo

Example format:

curl --proxy socks5h://192.168.xxx.1:23322 https://api.ipify.org
echo

The result should match the IP returned by this Windows command:

curl.exe --proxy socks5h://127.0.0.1:23321 https://api.ipify.org

Use socks5h rather than socks5 when possible so DNS lookups are also performed through the proxy.


5. Use the proxy in Ubuntu

Current terminal session

export ALL_PROXY="socks5h://VMNET8_HOST_IP:23322"
export all_proxy="$ALL_PROXY"

Test it:

curl https://api.ipify.org
echo

Remove the variables later with:

unset ALL_PROXY all_proxy

Chromium

chromium --proxy-server="socks5://VMNET8_HOST_IP:23322"

Google Chrome

google-chrome --proxy-server="socks5://VMNET8_HOST_IP:23322"

Firefox

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

6. Confirm which traffic is proxied

Direct traffic:

env -u ALL_PROXY -u all_proxy curl https://api.ipify.org
echo

Proxied traffic:

curl --proxy socks5h://VMNET8_HOST_IP:23322 https://api.ipify.org
echo

The two addresses should normally differ.


Stop or disable the setup quickly

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

Quick one-liner

$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

Confirm the forwarding rule is gone:

netsh interface portproxy show all

Inside Ubuntu, clear proxy environment variables from the current shell:

unset ALL_PROXY all_proxy HTTP_PROXY HTTPS_PROXY http_proxy https_proxy

Also:

  • 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.

7. Remove the forwarding rule

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-NetFirewallRule

Check that it has been removed:

netsh interface portproxy show all

Troubleshooting

Connection refused from Ubuntu

Confirm that the local SOCKS proxy is listening on Windows:

Get-NetTCPConnection -LocalPort 23321 -State Listen

You can also check with:

netstat -ano | findstr :23321

Then confirm the forwarded port is listening:

Get-NetTCPConnection -LocalPort 23322 -State Listen

The Windows proxy works, but Ubuntu cannot connect

Check:

netsh interface portproxy show all
Get-Service iphlpsvc
Get-NetFirewallRule -DisplayName 'SOCKS proxy for VMware'

The IP Helper service should be running.

The VMnet8 IP changed

VMware can change the address assigned to VMnet8. Re-run the PowerShell setup script so the forwarding rule uses the current address.

Browser works, but terminal traffic does not

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.

UDP does not work

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.


Security notes

  • Bind the forwarding rule only to the VMnet8 address, not to 0.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.

Important limitation

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment