-1

I need to query specific IP addresses 127.0.0.1-127.0.0.10 in the VirtualBox virtual machine (windows 10 installed) from the host.

Example:

Host IP: 192.168.1.1

Virtual machine IP: 192.168.1.2

The point is that when I make a query to the local address, e.g. 127.0.0.5 on the host, the service located on the virtual machine from the local address 127.0.0.5 is supposed to respond to me. If I ask at the address 127.0.0.4 of the host, I should get a response from the address 127.0.0.4 on the virtual machine.

E.t.c

Communication is to take place on port 161 (SNMP).

Is this even possible?

3
  • 1
    Why not assign multiple internal ipaddresses to your guests, and access them through those addresses? You can accomplish this by adding multiple virtual network cards to a vm.
    – LPChip
    Commented Oct 20, 2023 at 13:33
  • Thank you @LPChip. Your comment helped me solve the problem!
    – Volkir
    Commented Oct 20, 2023 at 15:38
  • I've added an answer for you, so you can mark the question solved. :) Glad I could help.
    – LPChip
    Commented Oct 20, 2023 at 19:06

3 Answers 3

5

IMHO NO.

Check RFC 5735 (especially last sentence)

127.0.0.0/8 - This block is assigned for use as the Internet host loopback address. A datagram sent by a higher-level protocol to an address anywhere within this block loops back inside the host. This is ordinarily implemented using only 127.0.0.1/32 for loopback. As described in [RFC1122], Section 3.2.1.3, addresses within the entire 127.0.0.0/8 block do not legitimately appear on any network anywhere.

And why you want localhost IP, you can use the "normal" IP, assigned to VM. Or add virtual IP to the NIC, or add another virtual NIC.

2

You cannot do that. The block 127.0.0.0/8 is reservedfor the local host and is not accessible outside of that host (see RFC3330, RFC5735, RFC6890).

If you really need to access a service on, say, 127.0.0.10 then the only way to access this from outside a host is to create a packet forwarder on that machine that listens on its public IP address (192.168.1.2 in your example) and forwards the packets to 128.0.0.10. Tools like socat can do this for you.

For example (only lightly tested):

sudo socat UDP4-RECVFROM:161,fork,reuseaddr UDP4-SENDTO:127.0.0.5:161,reuseaddr

However, what would be far better is to modify the configuration for the service that's listening only on a local port and have it listen on its public IP address.

0

Instead of using the loopback address 127.0.0.x (which means, redirect traffic back to the same machine), you can add more than one network cards in a virtual machine. Each network card can be given a static ip in the OS or use DHCP to get multiple leases.

Use their LAN ip addresses 192.168.1.x and connect to that.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .