0

Good evening,

I have to configure different Virtualbox guest systems (ubuntu) via Host-Only Network Adapter. The host network is configured with IP "192.168.7.1".

The clients are configured like this (/etc/network/interfaces):

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
        address 192.168.7.101
        netmask 255.255.255.0
        gateway 192.168.7.1

        up ip addr add 123.45.56.11/32 dev eth0
        down ip addr del 123.45.56.11/32 dev eth0

IP forwarding is activated, port forwarding is done via

iptables -t nat -I PREROUTING -d 123.45.56.11 -j DNAT --to 192.168.7.101
iptables -t nat -I POSTROUTING -s 192.168.7.101 -j SNAT --to 123.45.56.11

With this configuration, I'm able to ping the guest from a foreign IP and to ping the foreign IP even using DNS.

The problem is the following: I want to connect the guest systems to each other. This works great, if the local IPs are used (192.168.7.100, 192.168.7.101, ...). But if I want to use a DNS system which reports the global IP address (123.45.56.11), connection is not possible. If I use "ping example.org" on Guest with local IP "192.168.7.100", I get the correct IP "123.45.56.11" but then I get a timeout. If I ping "192.168.7.101" (the local IP) however, everything works great. All foreign IPs (e.g. google.com) can be pinged without problems.

So my question is: how is it possible to connect the Guest systems to each other without using the local IPs but the IPs given by DNS?

Thanks a lot!

Mathias

1 Answers1

1

"connect the Guest systems to each other without using the local IPs but the IPs given by DNS"

Then it would not be "Host Only" mode, but "Bridged" instead. Also, DNS does not hand out IPs, but DHCP will.

user48838
  • 7,431
  • 2
  • 18
  • 14
  • Yes, that is correct. Unfortunately, I'm not allowed to use Bridged Network configuration because the network card would have different mac addresses. This is explicitly forbidden. Therefore I have to use the Host-Only method with port forwarding. – Mathias Bank Nov 08 '10 at 07:40
  • 1
    In that case, the answer to your question is that it is not possible. You can set up an internal DNS amongst the virtual machines or setup host files on each system with the respective 192.168.7.x addresses. – user48838 Nov 08 '10 at 07:58
  • Ok, I have thought of that. But that is a lot of work for different and changing domains. Is there a possibility to still use DNS and rewrite the IP address if the DNS answer is an IP of a local server? For example if I get the IP by DNS 123.45.56.11 to rewrite it on the fly to 192.168.7.101. A hook or something like this. – Mathias Bank Nov 08 '10 at 10:58
  • 1
    You can enter the 192.168.7.x systems into your "regular" DNS, if the those IP assignments are not used elsewhere across your environment. Lookups against those hostnames will then result in those IP addresses, which will not respond on the "regular" network, but will be "valid" for the "Host Only" network lookups. – user48838 Nov 08 '10 at 12:46