0

On windows 10 I have a ubuntu VirtualBox running and I have two ethernet interfaces on the windows host:

  • "Ethernet"
  • "WLAN"

I now want to connect these two real ethernet devices on the host with two virtual interfaces on the ubuntu guest. In order to do so I define two bridge adapters on the VirtualBox configuration to connect to "Ethernet" (Adapter2) and "WLAN" (Adapter3):

enter image description here enter image description here

Inside the VirtualBox guest I define the network configuration in the file /etc/netplan/01-network-manager-all.yaml as follows:

# Let NetworkManager manage all devices on this system
network:
  version: 2
  ethernets:
    enp0s8:
      link-local: []
      dhcp4: yes
    enp0s9:
      link-local: []
      dhcp4: no
      addresses:
        - 192.168.200.100/24
      gateway4: 192.168.200.220

The output of ip addr show then shows this (incorrect/invalid) configuration:

2: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN group default qlen 1000
    link/ether 08:00:27:64:6a:fb brd ff:ff:ff:ff:ff:ff
    inet 192.168.200.243/24 brd 192.168.200.255 scope global dynamic enp0s8
       valid_lft 43151sec preferred_lft 43151sec
3: enp0s9: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:ee:d0:c4 brd ff:ff:ff:ff:ff:ff
    inet 192.168.200.100/24 brd 192.168.200.255 scope global enp0s9
       valid_lft forever preferred_lft forever

QUESTIONS:

  1. How to find out which adapter on the VirtualBox setting corresponds to which interface in the ubuntu host? Does Adapter2 correspond to enp0s8 or to enp0s9? How to find out?
  2. How to "fix" the setting for the interface that is connected to the windows "WLAN" adaptor so the guest ubuntu does actually connect to the windows "WLAN" adaptor and to the outside internet? Because I cannot ping 8.8.8.8, i.e. the ubuntu guest system does not seem to have outside internet connection. Also strange is that the two interfaces in the ubuntu guest are in the same subnet 192.168.200. That does not look right and might be the problem that the ubuntu guest is unable to access the outside internet via the windows "WLAN" adaptor. How to fix this?
  3. I might have a third ethernet adaptor that connects to cable internet
  4. I am not an expert in networkings. For example, I do not really know what a "gateway" means when defined for an adapter in the network settings.
  5. I want to apologize if I forgot something, if I have followup questions. As mentioned earlier, I am not an expert in networks. Ideally the answer will contain some general explanations on how this works.
4
  • Does this answer your question? How to define the network settings inside a ubuntu virtual machine inside VirtualBox?
    – Toto
    Commented Jun 15 at 7:46
  • No, the other question does not answer my question. The other question is about handling the configuration, i.e. that the config is stored in some file, and the kernel reads that configuration and shows it with the command ip addr show. The question here is about HOW to set up a configuration of the network of a VM. These are two completely different questions in my view ...
    – Alex
    Commented Jun 17 at 7:18
  • Practically you should break it up, and ask a new question referncing this as a follow up question. Its a little unfair to people answering if they need to chase a moving target
    – Journeyman Geek
    Commented Jun 19 at 7:24
  • Yes I agree. When I have more knowledge on the topic I will be able to break it up
    – Alex
    Commented Jun 19 at 8:10

2 Answers 2

1
+300

How to find out which adapter on the VirtualBox setting corresponds to which interface in the ubuntu host? Does Adapter2 correspond to enp0s8 or to enp0s9? How to find out?

Compare by MAC address. It is assigned by VirtualBox, so you can see it under ▶ Advanced in the VM's adapter settings and compare against the output of ip -br link.

In fact you can directly use the MAC address as a match condition in your Netplan or systemd-networkd configuration, avoiding interface names entirely (or assigning custom names). The default configuration on Ubuntu Desktop would use NetworkManager, but from your earlier posts it seems that you've decided to use Netplan, so you could configure it like:

ethernets:
  first:
    match: {macaddress: "08:00:27:64:6a:fb"}
    set-name: "ether"   # Optional
    addresses: ...
    gateway: ...        # If needed
  second:
    match: {macaddress: "08:00:27:ee:d0:c4"}
    set-name: "wifi"   # Optional
    dhcp4: yes

(Avoid using ethXXX as custom names.)

With NetworkManager, the same thing can be achieved by setting ethernet.mac-address on the connection profiles.

How to "fix" the setting for the interface that is connected to the windows "WLAN" adaptor so the guest ubuntu does actually connect to the windows "WLAN" adaptor and to the outside internet? Because I cannot ping 8.8.8.8, i.e. the ubuntu guest system does not seem to have outside internet connection.

Don't skip steps. Fix issue #1 first – i.e. determine which interface goes where – without that, any static IP or gateway configuration you've got is meaningless and trying to fix it is moot.

Once you have the interfaces sorted out and are sure that each has the config that it should (e.g. the static 192.168.200.100 is actually on the interface that belongs to 192.168.200, and so on), then it should generally just work.

If it still doesn't work after that, then look at your routing table using ip route, specifically at the default routes. These routes directly correspond to gateways you specify for each interface, and the 'default' route with lowest metric is what Linux will use to get Internet access.

The command ip route get 8.8.8.8 fibmatch is a simple way to verify the kernel's choice of the default route – if it returns the wrong interface, then that interface probably should not have a gateway specified.

For example, if the "static" interface has no Internet access (e.g. the Internet access goes through the "DHCP" interface), then you should remove the 'gateway' parameter from the "static" interface so that it does not generate a default route through it.

More specifically, when an interface is connected to just a single subnet (and doesn't go anywhere further), then it has no need for a gateway, as gateways (routers) do not handle local communications – the only purpose of a gateway (default or otherwise) is to provide a path beyond the local subnet.

(In-between, an interface that only leads to a limited set of networks – more than just a single subnet, but less than full Internet access – would still not need a default gateway; it would instead have gateways for more-specific routes.)

Also strange is that the two interfaces in the ubuntu guest are in the same subnet 192.168.200. That does not look right and might be the problem that the ubuntu guest is unable to access the outside internet via the windows "WLAN" adaptor. How to fix this?

Well, one of them is in the subnet because you've defined it statically via Netplan, so the other must have received its address via DHCP. This most likely means that the two interfaces need to be swapped around – the one that got an 192.168.200 address from DHCP is probably the one that should've had the static configuration, and vice versa.

8
  • For using WIFI this seems to work, but when using cable internet I am unable to ping the outside. Config of the third adapter: third: match: {macaddress: "08:00:27:e8:49:64"} set-name: "cable" dhcp4: yes
    – Alex
    Commented Jun 19 at 5:43
  • That was not part of your original question as stated in the main post. Have you checked your routing table yet? Which interface does your default route go through? Commented Jun 19 at 5:49
  • I do not understand what the routing table tells me.: default via 192.168.200.220 dev cas10 proto static default via 10.62.64.70 dev cable proto dhcp src 10.62.64.182 metric 100 10.62.64.0/23 dev cable proto kernel scope link src 10.62.64.182 10.62.64.70 dev cable proto dhcp scope link src 10.62.64.182 metric 100 172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 192.168.200.0/24 dev cas10 proto kernel scope link src 192.168.200.100
    – Alex
    Commented Jun 19 at 5:51
  • It tells you that you have two default routes, and it tells you that your primary default route goes through cas10 – which as you said earlier has no internet access, and which I said should not have a gateway defined for that reason. Remove the gateway configuration for cas10 if you want the 'cable' interface to be used for Internet. Commented Jun 19 at 5:57
  • I just followed your answer in which you do define a gateway for that cas10 adapter. It seems your answer is incorrect/incomplete. I'd appreciate if you could add that gateway explanation to your answer. I am very new to networking,
    – Alex
    Commented Jun 19 at 6:02
0

This felt too long for a comment, add details if this doesn't asnwer your questions..

Your windows 10 machine has 2 NICs

Ethernet WLAN

Your windows 10 machine has a linux virtual host

you've bridged Ethernet to Adapter2 you've bridged WLAN to Adapter3

you've employed this network config

# Let NetworkManager manage all devices on this system
network:
  version: 2
  ethernets:
    enp0s8:
      link-local: []
      dhcp4: yes
    enp0s9:
      link-local: []
      dhcp4: no
      addresses:
        - 192.168.200.100/24
      gateway4: 192.168.200.220

youre eth8 is 192.168.200.243

youre eth9 is 192.168.200.100 gw 192.168.200.220

The bounty lists 2 questions. The question lists 5 questions:

  1. How to find out which adapter on the VirtualBox setting corresponds to which interface in the ubuntu host? Does Adapter2 correspond to enp0s8 or to enp0s9? How to find out?

enp0s8 has mac address 08:00:27:64:6a:fb enp0s9 has mac address 08:00:27:ee:d0:c4

if you go back to the virtual box network adapter settings page and click the advanced arrow, there will be a mac address there. you can then correlate which one is enp0s8 and which is enp0s9.

2.How to "fix" the setting for the interface that is connected to the windows "WLAN" adaptor so the guest ubuntu does actually connect to the windows "WLAN" adaptor and to the outside internet? Because I cannot ping 8.8.8.8, i.e. the ubuntu guest system does not seem to have outside internet connection. Also strange is that the two interfaces in the ubuntu guest are in the same subnet 192.168.200. That does not look right and might be the problem that the ubuntu guest is unable to access the outside internet via the windows "WLAN" adaptor. How to fix this?

The 2 ubuntu interfaces are in the same .200 subnet because you are using bridged mode, which will treat those virtual interfaces like they are plugged in at the same network level as your windows 10 host, which i assume is also in the .200 subnet. if not, you may not want bridge mode.

If what you are trying to convey is that the enp0s8 adapter on your linux virtual guest is the one you want working to use the internet, i think you're doing it wrong

  1. I might have a third ethernet adaptor that connects to cable internet.

Is your intention to make your virtual guest reachable from other computers on your network, or just to be able to use the internet from your virtual machine. what internet connection do you want your virtual machine to use to get to the internet, does it need to use 1, 2, 3, more?

4 I am not an expert in networkings. For example, I do not really know what a "gateway" means when defined for an adapter in the network settings.

a network card is a physical object that lets devices converse on a connected network. they have a physical address called a mac address that makes them unique. its hex and looks like this 08:00:27:64:6a:fb.

when a network card in a computer is plugged into a networking device, like a router, that networking device can converse at a higher networking layer and assign virtual addresses to each machine, these are IP Addresses. they look like this 192.168.1.1.

ip addresses are logically grouped into smaller groups called networks. All networks have a default gateway,and a number of hosts. its how the machines in the network know which device to ask to continue making requests to machines farther away from itself

for example the 192.168.200.1/24 network contains all the ips from 200.0 to 200.254. typically the router handing out DHCP ips to devices would be .1 and devices would list 192.168.200.1 as their gateway.

machines all have 1 default gateway, or default networking device.

from your config shown, i can make the assumption that your router is 192.168.200.20 (if its not then remove this gateway config from your network config, it will send traffic from this virtual machine to this host)

which assigned 192.168.200.243 to the network adapter you enabled dhcp on you assigned 102.168.200.100 yourself to the other one and said its gateway is .220

If the goal is right now to have the bridged configuration work, go on your linux machine and type netstat -rn

This will list the default gateway address. Make sure these settings are correct.

If you can reach the internet from the host but cannot ping, check the filters that may be on your network adapter at the windows level.

You must log in to answer this question.

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