Host-only adapter bridged to LAN - Possible?

Discussions related to using VirtualBox on Linux hosts.
Post Reply
bernid
Posts: 7
Joined: 27. Nov 2017, 15:18
Primary OS: Ubuntu other
VBox Version: PUEL
Guest OSses: other Linux

Host-only adapter bridged to LAN - Possible?

Post by bernid »

Hi,
I've just configured Host only adapter on Ubuntu server x86_64 and connect to guest IPFire (linux firewal/router x86_64 distribution).
I can ping from host to guest and from guest to host.

Now I would like to connect/bridge host only adapter to guest's LAN.
I initially tried to bridge green0 (guest LAN interface) to eth3 (host only adapter interface) but it doesn't work for eth3.

Code: Select all

# down green0
ip link set green0 down
# rename green0 to eth1
ip link set green0 name eth1
# create new bridge green
brctl addbr green0
# Add a real green nic and host-only adapter
brctl addif green0 eth1
brctl addif green0 eth3
# Bring nics up, set static IP address for host-only adapter
ip link set eth1 up
ifconfig eth3 192.168.56.101 netmask 255.255.255.0 up
Interfaces are recognised correctly. LAN work ok but i can't ping from host to guest anymore nor ubuntu is recognised as one of LAN client.
I am newbie in VirtualBox and Linux :)
Please advice what to do.
TIA,
michaln
Oracle Corporation
Posts: 2973
Joined: 19. Dec 2007, 15:45
Primary OS: MS Windows 7
VBox Version: PUEL
Guest OSses: Any and all
Contact:

Re: Host-only adapter bridged to LAN - Possible?

Post by michaln »

Let's just assume that it's called host-only for a reason.
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Host-only adapter bridged to LAN - Possible?

Post by socratis »

Please read the following: User Manual, ch. 6.2. Introduction to networking modes including the Overview table, which shows quickly what kind of connection is required to achieve what you want. And remember, you can always have more than one network card in your guest to cover multiple scenarios.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
bernid
Posts: 7
Joined: 27. Nov 2017, 15:18
Primary OS: Ubuntu other
VBox Version: PUEL
Guest OSses: other Linux

Re: Host-only adapter bridged to LAN - Possible?

Post by bernid »

Thank you.
So according to the manual it should be possible to have network with host and guest (host -only network). So I assume that this network can be bridged to one of the guest's network.
I am trying to do that bridging host only network to guest's Green (LAN) interface and add green0 interface for the bridge with address 192.168.2.1.
So far with no success ;) .

In the testing environment I have one machine on guest's LAN (Green0) and one machine host ubuntu (on eth3 host only network).
So I expect to see two rows in the 'Current dynamic LAN leases' list starting with: 192.168.2.XX
I set host only network 192.168.4.1 in virtualbox (without DHCP, Promissuous Mode: Deny) and prepared starting script for set the bridge on guest side:

Code: Select all

#!/bin/sh
. /etc/sysconfig/rc
. ${rc_functions}
 
case "${1}" in
	start)
		boot_mesg "Create bridge for green net..."
		# down green0
		ip link set green0 down
		# rename green0 to eth1
		ip link set green0 name eth1
		# create new bridge green0
		brctl addbr green0
		# wait 2 seconds because udev try to rename the nics
		# if the real green nic was added to fast...
		sleep 2
		# Add real green nic and the unused ones
		brctl addif green0 eth1
		brctl addif green0 eth3
		# Bring nic's up; set static ip for eth3
		ip link set eth1 up
		ifconfig eth3 192.168.4.10 netmask 255.255.255.0 up
		;;
 
	stop)
		boot_mesg "Remove bridge for green net......"
		# Bring nic's down
		ip link set eth1 down
		#ip link set eth2 down
		ip link set eth3 down
		# Bring bridge down
		ip link set green0 down
		# Delete Bridge
		brctl delbr green0
		# rename eth1 to green0
		ip link set eth1 name green0
		;;
	*)
		echo "Usage: ${0} {start|stop}"
		exit 1
		;;
esac
 
# End $rc_base/init.d/bridge 
eth3 interface is VM interface. I would like to connect VM host to IPFire's Green.
After a bridge set I have following net interfaces on guest side:

Code: Select all

[root@ipfire ~]# ifconfig -a
blue0     Link encap:Ethernet  HWaddr 08:00:27:46:16:66
          inet addr:192.168.3.1  Bcast:192.168.3.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:152 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:9120 (8.9 Kb)  TX bytes:0 (0.0 b)

eth1      Link encap:Ethernet  HWaddr 08:00:27:0E:E5:4C
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:22589 errors:0 dropped:0 overruns:0 frame:0
          TX packets:24896 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:2867668 (2.7 Mb)  TX bytes:20516405 (19.5 Mb)

eth3      Link encap:Ethernet  HWaddr 08:00:27:31:95:0E
          inet addr:192.168.4.10  Bcast:192.168.4.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:295 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5648 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:21838 (21.3 Kb)  TX bytes:364449 (355.9 Kb)

green0    Link encap:Ethernet  HWaddr 08:00:27:0E:E5:4C
          inet addr:192.168.2.1  Bcast:192.168.2.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:22734 errors:0 dropped:0 overruns:0 frame:0
          TX packets:19224 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:2561668 (2.4 Mb)  TX bytes:17695930 (16.8 Mb)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:456 errors:0 dropped:0 overruns:0 frame:0
          TX packets:456 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:110939 (108.3 Kb)  TX bytes:110939 (108.3 Kb)

red0      Link encap:Ethernet  HWaddr 08:00:27:C2:52:B3
          inet addr:192.168.0.29  Bcast:192.168.0.255  Mask:255.255.255.0
          UP BROADCAST RUNNING  MTU:1500  Metric:1
          RX packets:14512 errors:0 dropped:0 overruns:0 frame:0
          TX packets:15535 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:16379670 (15.6 Mb)  TX bytes:1239112 (1.1 Mb)

[root@ipfire ~]#
The bridge seems to works OK:

Code: Select all

[root@ipfire ~]# brctl show
bridge name     bridge id               STP enabled     interfaces
green0          8000.0800270ee54c       no              eth1
                                                        eth3
I see a mac address of virtualbox host '0a:00:27:00:00:00' from eth3 which I want to bridge to GREEN:

Code: Select all

[root@ipfire ~]# brctl showmacs green0
port no mac addr                is local?       ageing timer
  1     08:00:27:0e:e5:4c       yes                0.00
  2     08:00:27:31:95:0e       yes                0.00
  2     0a:00:27:00:00:00       no               103.76
  1     6c:62:6d:2c:fc:9f       no                 0.00
[root@ipfire ~]#
However on the Current dynamic leases list I see only one row from eth1/green0:
192.168.2.10 6c:62:6d:2c:fc:9f
and no virtualbox host (with mac: 0a:00:27:00:00:00).
Command 'arp' on guest side gives me:

Code: Select all

[root@ipfire ~]# arp
Address                  HWtype  HWaddress           Flags Mask            Iface
gateway                  ether   40:61:86:4a:c2:d6   C                     red0
192.168.4.1                      (incomplete)                              eth3
home.localdomain         ether   6c:62:6d:2c:fc:9f   C                     green0
As you can see above 192.168.4.1 (mac: 0a:00:27:00:00:00) - virtualbox host has a status 'incomplete'.
How could i diagnose and fix this?
I will be grateful for any guidance.
TIA
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Host-only adapter bridged to LAN - Possible?

Post by socratis »

bernid wrote:So I assume that this network can be bridged to one of the guest's network.
Why would you assume that? The name is a clear giveaway: Host Only. I told you to look at the networking options so that you have a clearer picture of what is available at your disposal and what you can do with each mode. Maybe HostOnly is not the option you should be looking at.

After that point, I lost you. I don't know anything about Green, Purple or Beige. I don't use IPFire and I assume that this is the case for the majority of the people around these forums. We're dealing mostly with VirtualBox, not specidfic applications and their usage patterns. So, if you want to explain the situation in pure networking terms, I'm all ears. But I'm not going to try IPFire or any other program and try to learn its peculiarities. I hope you understand...
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
bernid
Posts: 7
Joined: 27. Nov 2017, 15:18
Primary OS: Ubuntu other
VBox Version: PUEL
Guest OSses: other Linux

Re: Host-only adapter bridged to LAN - Possible?

Post by bernid »

Thanks,
So, if you want to explain the situation in pure networking terms, I'm all ears.
That was my intention to treat the issue in pure networking and linux terms.
Names of network interfaces are only examples.
I am new in linux and set the network bridge for the first time. :oops:
Post Reply