Netzwerkproblem in VirtualBox mit Host only Adapter *gelöst*

Einrichten des lokalen Netzes, Verbindung zu anderen Computern und Diensten.
Antworten
Benutzeravatar
weedy
Beiträge: 585
Registriert: 02.11.2002 21:47:49
Lizenz eigener Beiträge: GNU General Public License
Kontaktdaten:

Netzwerkproblem in VirtualBox mit Host only Adapter *gelöst*

Beitrag von weedy » 04.11.2020 21:02:18

Hi,

ich habe ein Debian Buster innerhalb einer Virtualbox Vm mit Host only Adapter
'vboxnet0', definiert als 192.168.56.1/24

Es gibt im Host ein Interface

vboxnet0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.56.1 netmask 255.255.255.0 broadcast 192.168.56.255
ether 0a:00:27:00:00:00 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 7002 bytes 444792 (434.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

Die Addressvergabe innerhalb der VM erfolgt mit dem Virtualbox eigenen dhcp server.

Der Vbox DHCP Server kann aber keine vernünftigen Routing Informatinoen mitliefern, so dass

# route -n

nur sowas liefert:

Kernel-IP-Routentabelle
Ziel Router Genmask Flags Metric Ref Use Iface
192.168.56.0 0.0.0.0 255.255.255.0 U 0 0 0 enp0s3


Damit komme ich nicht in das Internet (in /etc/resolf.conf steht 'nameserver 8.8.8.8').

Um in das Internet zu kommen, habe ich im Gast definiert unter

/etc/network/interfaces.d/enp0s3 :

auto enp0s3

iface enp0s3 inet dhcp
post-up route add 192.168.56.1 dev enp0s3
post-up route add default gw 192.168.56.1

Mit 'ifdown enp0s3; ifup enp0s3' komme ich daher zielsicher in das Internet.

# ifdown enp0s3; ifup enp0s3
Killed old client process
Internet Systems Consortium DHCP Client 4.4.1
Copyright 2004-2018 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/enp0s3/08:00:27:23:52:09
Sending on LPF/enp0s3/08:00:27:23:52:09
Sending on Socket/fallback
DHCPRELEASE of 192.168.56.148 on enp0s3 to 192.168.56.100 port 67
Internet Systems Consortium DHCP Client 4.4.1
Copyright 2004-2018 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/enp0s3/08:00:27:23:52:09
Sending on LPF/enp0s3/08:00:27:23:52:09
Sending on Socket/fallback
DHCPDISCOVER on enp0s3 to 255.255.255.255 port 67 interval 6
DHCPDISCOVER on enp0s3 to 255.255.255.255 port 67 interval 19
DHCPOFFER of 192.168.56.148 from 192.168.56.100
DHCPREQUEST for 192.168.56.148 on enp0s3 to 255.255.255.255 port 67
DHCPACK of 192.168.56.148 from 192.168.56.100
bound to 192.168.56.148 -- renewal in 553 seconds.

# route -n
Kernel-IP-Routentabelle
Ziel Router Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.56.1 0.0.0.0 UG 0 0 0 enp0s3
192.168.56.0 0.0.0.0 255.255.255.0 U 0 0 0 enp0s3
192.168.56.1 0.0.0.0 255.255.255.255 UH 0 0 0 enp0s3

Soweit sogut.

Wenn ich nun aber den virtuellen Rechner neu starte, sieht die routing tabelle exakt so aus nd Internet funktioniert erstmal.

Nach einer weile aber wiederholt sich die DHCP addressvergabe und die routingtabelle sieht wieder aus, wie vorher:

192.168.56.0 0.0.0.0 255.255.255.0 U 0 0 0 enp0s3

Und das internet ist weg.

Was kann ich tun, um das zu fixen?

Gruß
Zuletzt geändert von weedy am 05.11.2020 23:52:00, insgesamt 1-mal geändert.

Benutzeravatar
weedy
Beiträge: 585
Registriert: 02.11.2002 21:47:49
Lizenz eigener Beiträge: GNU General Public License
Kontaktdaten:

Re: Netzwerkproblem in VirtualBox mit Host only Adapter

Beitrag von weedy » 05.11.2020 23:51:48

Problem gelöst:

/etc/network/interfaces.d/enp0s3 :

auto enp0s3
iface enp0s3 inet dhcp

/etc/dhcp/dhclient.conf :

supersede routers 192.168.56.1 ;

und fertig ist der Salat.

Gruß

AxelMD
Beiträge: 1386
Registriert: 15.03.2009 08:02:11

Re: Netzwerkproblem in VirtualBox mit Host only Adapter *gelöst*

Beitrag von AxelMD » 13.12.2020 12:00:25

Hallo weedy,

gibt es da keine einfachere Lösung?

https://www.virtualbox.org/manual/UserM ... hostonlyif

https://www.virtualbox.org/manual/UserM ... k_hostonly

https://wiki.debian.org/SystemdNetworkd

https://code-maven.com/virtualbox-host- ... te-machine

https://cs4118.github.io/dev-guides/vbox-ssh.html

https://cs4118.github.io/dev-guides/hos ... twork.html <---- Lösung

https://www.thomas-krenn.com/de/wiki/Ne ... networking

https://dev.to/yassineselllami/how-to-s ... chine-1kii

https://nocksoft.de/tutorials/virtualbo ... ly_Adapter



Wie bist Du auf deine Lösung gekommen?

Zur Zeit sieht es bei mir so aus:

Code: Alles auswählen

ssh axel@192.168.56.1
axel@192.168.56.1's password: 
Welches Passwort habe ich einzugeben?

Mein Passwort ist mir bekannt, mit dem Netzwerk Adapter 1 kann ich eine Verbindung aufbauen.

Code: Alles auswählen

ssh axel@192.168.178.60
axel@192.168.178.60 password:
Den Host-Only Adapter 2 möchte ich nutzen um auf meine Debian 10 VM (dem Guest) zugreifen zu können.

Code: Alles auswählen

ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 08:00:27:fee:06:86 brd ff:ff:ff:ff:ff:ff
    inet 192.168.178.60/24 brd 192.168.178.255 scope global dynamic enp0s3
       valid_lft 863526sec preferred_lft 863526sec
    inet6 fe80::a00:27ff:feeff:686/64 scope link 
       valid_lft forever preferred_lft forever
3: enp0s8: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 08:00:27:33:9e:2b brd ff:ff:ff:ff:ff:ff
Der Adapter 2 ist enp0s8.
Wie aktiviere ich diesen?



MfG
AxelMD


Lösung, Debian 10 Buster:


https://cs4118.github.io/dev-guides/hos ... twork.html
Troubleshooting Common Issues
My VM does not have an IP address for the host-only network interface

Depending on the operating system of the VM, the new network interface may not be automatically enabled. To fix this, we should first find the name of the host-only network interface in your VM using

[guest]$ ip addr

This lists all the interfaces and corresponding IP addresses. Find the interface that does not have an IP address and note its name (by default this should be enp0s8).

Now edit the network configuration file /etc/network/interfaces and add the host-only interface to enable it. Open the file as sudo, and append the following lines to the end (change enp0s8 if your interface name is different):

allow-hotplug enp0s8
iface enp0s8 inet dhcp

Reboot your VM and try finding your IP address again.
Jetzt kann ich mich über das Hausnetzwerk (Adapter1, Netzwerkbrücke) und mit dem (Adapter2) only Host Adpater in die Debian 10 VM einloggen.

AxelMD
Beiträge: 1386
Registriert: 15.03.2009 08:02:11

Re: Netzwerkproblem in VirtualBox mit Host only Adapter *gelöst*

Beitrag von AxelMD » 30.03.2024 08:08:07

Virtualbox 7.0.14 Host-only Adapter

Lösung, Debian 12 Bookworm


https://condor.depaul.edu/glancast/443c ... setup.html

Antworten