Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am using VM Player 4.0.2 running Ubuntu 11.10 guest OS on WinXP host, with NAT network connection configuration.

I have an application running on Win XP that communicates with a device manager service using TCP sockets at server address 127.0.0.1:4401. I would like the device service to run on a VM Guest OS (Ubuntu) and still be able to communicate with the application on host OS.

I am able to reach localhost of host OS using the IP address (192.168.1.100) of host NIC. But if i use 127.0.0.1 it does not work. It appears that the packets are consumed by the loopback lo of the guest OS.

Win host setup:

    Windows IP Configuration

    Ethernet adapter VMware Network Adapter VMnet8:

            Connection-specific DNS Suffix  . :
            IP Address. . . . . . . . . . . . : 192.168.59.1
            Subnet Mask . . . . . . . . . . . : 255.255.255.0
            Default Gateway . . . . . . . . . :

    Ethernet adapter VMware Network Adapter VMnet1:

            Connection-specific DNS Suffix  . :
            IP Address. . . . . . . . . . . . : 192.168.48.1
            Subnet Mask . . . . . . . . . . . : 255.255.255.0
            Default Gateway . . . . . . . . . :

    Ethernet adapter LoopBack:

            Connection-specific DNS Suffix  . :
            IP Address. . . . . . . . . . . . : 192.168.1.121
            Subnet Mask . . . . . . . . . . . : 255.255.255.0
            Default Gateway . . . . . . . . . : 192.168.1.2

    Ethernet adapter EtherLAN:

            Connection-specific DNS Suffix  . :
            IP Address. . . . . . . . . . . . : 192.168.1.100
            Subnet Mask . . . . . . . . . . . : 255.255.255.0
            Default Gateway . . . . . . . . . : 192.168.1.1

Ubuntu guest OS setup:

    eth0      Link encap:Ethernet  HWaddr 00:0c:29:5f:4f:c1  
              inet addr:192.168.59.129  Bcast:192.168.59.255  Mask:255.255.255.0
              inet6 addr: fe80::20c:29ff:fe5f:4fc1/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:6108 errors:0 dropped:0 overruns:0 frame:0
              TX packets:4745 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:6638533 (6.6 MB)  TX bytes:371359 (371.3 KB)
              Interrupt:19 Base address:0x2024 

    lo        Link encap:Local Loopback  
              inet addr:127.0.0.1  Mask:255.0.0.0
              inet6 addr: ::1/128 Scope:Host
              UP LOOPBACK RUNNING  MTU:16436  Metric:1
              RX packets:42 errors:0 dropped:0 overruns:0 frame:0
              TX packets:42 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0 
              RX bytes:2916 (2.9 KB)  TX bytes:2916 (2.9 KB)

Can anyone tell me if this is possible and what is the recommended way to set it up?

I have openssh-server installed on VM and listening

    rootuser@ubuntu:~$ sudo netstat -tap | grep sshd
    tcp        0      0 *:ssh                   *:*                     LISTEN      3469/sshd       
share|improve this question
    
I don't know if this is possible, I suspect not without modifying kernel or networking stack, but why do you want this? The loopback address is by definition not supposed to refer to another machine - it has its own IP address. –  user55325 Mar 16 '12 at 7:52
    
I have got a working Win client app and device drivers and I wanted to test the device driver & service on linux. Although localhost (like loopback) is specific it can be accessed by VM. So I am wondering if we can use NAT or some other technique to reach loopback on host OS. I could not find any such solutions on the net and wanted to check with the experts for easy workaround / configuration. –  Mano Mar 16 '12 at 8:12

1 Answer 1

You can consider a virtual machine to be the same as a physical machine. The loopback range 127.x.x.x is not routed in any way, and so can only be accessed from the machine they are configured on. This is a part and a guarantee of the IP specification, and accessing a 127.x.x.x address from a device other than the one it is configured on would require an implementation of IP that was very broken, and so not something you will find readily.

As we can consider a virtual machine to be the same as a physical machine, then it follows that it is separate from the host, and therefore cannot access a 127.0.0.1 address on its host.

Your options are to change the configuration of the service so that it listens on a routable IP address, such as its interface interface address.

Another option would be to use port forwarding over ssh. So if the service was listening on 127.0.0.1:4401 on a device with IP address 192.168.1.100 you could create a port forward to it from another device by using the command:

ssh -L4401:127.0.0.1:4401 192.168.1.100

So this would open an ssh session to 192.168.1.100 and in the process create a local port 127.0.0.1:4401 on the machine initiating the connection. Any traffic to and from 127.0.0.1:4401 on the local machine would go over the ssh tunnel to 127.0.0.1:4401 on the remote machine.

share|improve this answer
    
Thanks for the answer. I tried to use SSH port forwarding but i get connection refused on the guest OS. Even telnet to 192.168.1.100:22 failed. I have ssh running and listening (see edited question). Does this mean host Win XP is not allowing the port 22 connection? How do I solve this? –  Mano Mar 16 '12 at 20:06
    
Perhaps you have /etc/hosts.deny defined? If it is listening, but refused, then something other than ssh is dropping it like a firewall or host restrictions. –  Paul Mar 17 '12 at 12:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.