Virtualbox SOCKS proxy

socks-proxyvirtualbox

I'm using ssh to establish a SOCKS proxy within a Virtualbox guest machine (Debian). I've confirmed that it works within the guest system, but when I try to use it in my host system (Windows) via Firefox, it gives an error:

Firefox is configured to use a proxy server that is refusing
connections.

I tried NAT and port-forwarded the appropriate port. Then I tried using a bridged adapter and used the guest machine's IP rather than 127.0.0.1. Neither method worked.

Best Answer

Because the service is not accessible when the virtual nic is in either bridged mode, or is in NAT mode with a correctly configured forward rule, the issue is likely to be with the guest server, or the service itself.

Many services are not configured to accept remote connections by default, and open network ports for listening on the loop back network interface only. To determine what interface your service is bound to, use this command:

Linux:

# netstat -ntlup | grep portnumber

windows:

netstat -abno | FINDSTR LISTENING

and make note of the IP address the port/process is bound to.

 # netstat -ntlup | grep 53
tcp        0      0 127.0.1.1:53            0.0.0.0:*               LISTEN      835/dnsmasq     
udp        0      0 127.0.1.1:53           0.0.0.0:*                           835/dnsmasq     

shows the dnsmasq service running on the loopback interface (127.0.x.y), and can only be accessed by processes running on the localhost.

# netstat -ntlup | grep 445
tcp        0      0 0.0.0.0:445             0.0.0.0:*               LISTEN      566/smbd        
tcp6       0      0 :::445                  :::*                    LISTEN      566/smbd   

However shows the service listening on ALL interfaces (0.0.0.0).

finally,

# netstat -ntlup | grep 138
    udp        0      0 10.0.2.255:138          0.0.0.0:*                           960/nmbd        
    udp        0      0 10.0.2.15:138           0.0.0.0:*                           960/nmbd     

shows the service listening on eth0 (host IP), and any broadcasts received on eth0 (host network broadcast address ending in .255) since Samba protocols use IP broadcasts.

Each service has its own means of enabling remote connections. this is somthing that must be configured in the service itself (no OS level control), because when the service opens the port for listening, it specifies the details of what interface to bind to. Usually (in linux) it involves specifying the interface binding in the services main configuration file, and restarting the service. In Windows, you are more likely to find a checkbox saying "allow remote connections" or some such, but you usually still have to restart the service for the change to take effect.

Related Question