Αδυναμία Ping σε alpine linux μέσω host-only

Λοιπόν μάγκες έχω 2 ethernet δίκτυα σε ένα virtualbox vm με alpine:

Το Guest (alpine VM)

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

auto eth1
iface eth1 inet static
	address 10.0.2.3/24

eth1 η host-only κάρτα δικτύου η eth0 η nat κάρτα δικτύου στο virtualbox.

Routes:

$ ip route
default via 10.0.2.2 dev eth0 
10.0.2.0/24 dev eth0 proto kernel scope link src 10.0.2.15 
10.0.2.0/24 dev eth1 proto kernel scope link src 10.0.2.3 

Και ifconfig:

$ ifconfig -a
eth0      Link encap:Ethernet  HWaddr 08:00:27:3E:01:9E  
          inet addr:10.0.2.15  Bcast:0.0.0.0  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe3e:19e/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6471 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3378 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:4458349 (4.2 MiB)  TX bytes:266301 (260.0 KiB)

eth1      Link encap:Ethernet  HWaddr 08:00:27:82:18:08  
          inet addr:10.0.2.3  Bcast:0.0.0.0  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe82:1808/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:30 errors:0 dropped:0 overruns:0 frame:0
          TX packets:44 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1800 (1.7 KiB)  TX bytes:3464 (3.3 KiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:238 errors:0 dropped:0 overruns:0 frame:0
          TX packets:238 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:18216 (17.7 KiB)  TX bytes:18216 (17.7 KiB)


Δε έχω το ssh ανοιχτό:

$ sudo ss -tl 
State                       Recv-Q                      Send-Q                                             Local Address:Port                                             Peer Address:Port                      Process                      
LISTEN                      0                           128                                                      0.0.0.0:ssh                                                   0.0.0.0:*                                  

Στο host τρέχω:

$ ping 10.0.2.3
PING 10.0.2.3 (10.0.2.3) 56(84) bytes of data.
From 10.0.2.1 icmp_seq=1 Destination Host Unreachable
From 10.0.2.1 icmp_seq=2 Destination Host Unreachable
From 10.0.2.1 icmp_seq=3 Destination Host Unreachable
From 10.0.2.1 icmp_seq=4 Destination Host Unreachable
From 10.0.2.1 icmp_seq=5 Destination Host Unreachable
From 10.0.2.1 icmp_seq=6 Destination Host Unreachable
From 10.0.2.1 icmp_seq=8 Destination Host Unreachable
From 10.0.2.1 icmp_seq=9 Destination Host Unreachable
From 10.0.2.1 icmp_seq=10 Destination Host Unreachable
From 10.0.2.1 icmp_seq=11 Destination Host Unreachable
From 10.0.2.1 icmp_seq=14 Destination Host Unreachable
From 10.0.2.1 icmp_seq=15 Destination Host Unreachable
From 10.0.2.1 icmp_seq=16 Destination Host Unreachable
From 10.0.2.1 icmp_seq=17 Destination Host Unreachable
From 10.0.2.1 icmp_seq=18 Destination Host Unreachable
From 10.0.2.1 icmp_seq=19 Destination Host Unreachable
From 10.0.2.1 icmp_seq=20 Destination Host Unreachable
From 10.0.2.1 icmp_seq=21 Destination Host Unreachable
From 10.0.2.1 icmp_seq=22 Destination Host Unreachable
From 10.0.2.1 icmp_seq=23 Destination Host Unreachable
From 10.0.2.1 icmp_seq=24 Destination Host Unreachable
From 10.0.2.1 icmp_seq=25 Destination Host Unreachable
From 10.0.2.1 icmp_seq=26 Destination Host Unreachable
From 10.0.2.1 icmp_seq=27 Destination Host Unreachable
From 10.0.2.1 icmp_seq=28 Destination Host Unreachable
From 10.0.2.1 icmp_seq=29 Destination Host Unreachable
From 10.0.2.1 icmp_seq=30 Destination Host Unreachable
From 10.0.2.1 icmp_seq=31 Destination Host Unreachable
From 10.0.2.1 icmp_seq=32 Destination Host Unreachable
From 10.0.2.1 icmp_seq=33 Destination Host Unreachable
From 10.0.2.1 icmp_seq=34 Destination Host Unreachable
From 10.0.2.1 icmp_seq=35 Destination Host Unreachable
From 10.0.2.1 icmp_seq=36 Destination Host Unreachable
From 10.0.2.1 icmp_seq=37 Destination Host Unreachable
From 10.0.2.1 icmp_seq=38 Destination Host Unreachable
From 10.0.2.1 icmp_seq=39 Destination Host Unreachable
From 10.0.2.1 icmp_seq=40 Destination Host Unreachable
From 10.0.2.1 icmp_seq=41 Destination Host Unreachable
From 10.0.2.1 icmp_seq=45 Destination Host Unreachable
From 10.0.2.1 icmp_seq=46 Destination Host Unreachable
^C
--- 10.0.2.3 ping statistics ---
47 packets transmitted, 0 received, +40 errors, 100% packet loss, time 47048ms
pipe 4

Και ακόμα δοκίμασα:

$ nc -vz 10.0.2.3 22
nc: connect to 10.0.2.3 port 22 (tcp) failed: No route to host

Καμιά ιδέα τις πταίει;

Also asked networking - Why linux-mint host is unable to ping a alpine vm? - Server Fault

Απο το documentation του VirtualBox ( Chapter 6. Virtual Networking)

On Linux, Mac OS X and Solaris Oracle VM VirtualBox will only allow IP addresses in 192.168.56.0/21 range to be assigned to host-only adapters. For IPv6 only link-local addresses are allowed. If other ranges are desired, they can be enabled by creating /etc/vbox/networks.conf and specifying allowed ranges there. For example, to allow 10.0.0.0/8 and 192.168.0.0/16 IPv4 ranges as well as 2001::/64 range put the following lines into /etc/vbox/networks.conf:

 * 10.0.0.0/8 192.168.0.0/16
 * 2001::/64

Lines starting with the hash # are ignored. Next example allows any addresses, effectively disabling range control:

 * 0.0.0.0/0 ::/0

If the file exists, but no ranges are specified in it, no addresses will be assigned to host-only adapters. The following example effectively disables all ranges:

  # No addresses are allowed for host-only adapters

Αρα θα υποθεσω οτι ισως θα χρειαστει να αλλαξεις το /etc/vbox/network.conf για να δεις αν γινεται αυτο που χρειαζεσαι.

Λοιπόν έχω αυτά τα δίκτυα:

VBoxManage list hostonlyifs
Name:            vboxnet2
GUID:            786f6276-656e-4274-8000-0a0027000002
DHCP:            Disabled
IPAddress:       172.28.128.1
NetworkMask:     255.255.255.0
IPV6Address:     
IPV6NetworkMaskPrefixLength: 0
HardwareAddress: 0a:00:27:00:00:02
MediumType:      Ethernet
Wireless:        No
Status:          Down
VBoxNetworkName: HostInterfaceNetworking-vboxnet2

Name:            vboxnet1
GUID:            786f6276-656e-4174-8000-0a0027000001
DHCP:            Disabled
IPAddress:       192.168.10.1
NetworkMask:     255.255.255.0
IPV6Address:     fe80::800:27ff:fe00:1
IPV6NetworkMaskPrefixLength: 64
HardwareAddress: 0a:00:27:00:00:01
MediumType:      Ethernet
Wireless:        No
Status:          Up
VBoxNetworkName: HostInterfaceNetworking-vboxnet1

Name:            vboxnet0
GUID:            786f6276-656e-4074-8000-0a0027000000
DHCP:            Disabled
IPAddress:       10.0.2.1
NetworkMask:     255.255.255.0
IPV6Address:     
IPV6NetworkMaskPrefixLength: 0
HardwareAddress: 0a:00:27:00:00:00
MediumType:      Ethernet
Wireless:        No
Status:          Down

Και το VM είναι:

$ VBoxManage showvminfo 1b9199ee-f510-499c-802f-285b3f3b38b8
Name:            Alpine Webserver PHP
Groups:          /
Guest OS:        Other Linux (64-bit)
UUID:            1b9199ee-f510-499c-802f-285b3f3b38b8
Config file:     /home/pcmagas/VirtualBox VMs/Alpine Webserver PHP/Alpine Webserver PHP.vbox
Snapshot folder: /home/pcmagas/VirtualBox VMs/Alpine Webserver PHP/Snapshots
Log folder:      /home/pcmagas/VirtualBox VMs/Alpine Webserver PHP/Logs
Hardware UUID:   1b9199ee-f510-499c-802f-285b3f3b38b8
Memory size:     1722MB
Page Fusion:     off
VRAM size:       16MB
CPU exec cap:    100%
HPET:            off
Chipset:         piix3
Firmware:        BIOS
Number of CPUs:  1
PAE:             on
Long Mode:       on
Triple Fault Reset: off
APIC:            on
X2APIC:          on
CPUID Portability Level: 0
CPUID overrides: None
Boot menu mode:  message and menu
Boot Device (1): HardDisk
Boot Device (2): Not Assigned
Boot Device (3): Not Assigned
Boot Device (4): Not Assigned
ACPI:            on
IOAPIC:          on
BIOS APIC mode:  APIC
Time offset:     0ms
RTC:             UTC
Hardw. virt.ext: on
Nested Paging:   on
Large Pages:     off
VT-x VPID:       on
VT-x unr. exec.: on
Paravirt. Provider: Default
Effective Paravirt. Provider: KVM
State:           saved (since 2022-05-10T20:08:17.000000000)
Graphics Controller:         VBoxVGA
Monitor count:   1
3D Acceleration: off
2D Video Acceleration: off
Teleporter Enabled: off
Teleporter Port: 0
Teleporter Address: 
Teleporter Password: 
Tracing Enabled: off
Allow Tracing to Access VM: off
Tracing Configuration: 
Autostart Enabled: off
Autostart Delay: 0
Default Frontend: 
Storage Controller Name (0):            IDE
Storage Controller Type (0):            PIIX4
Storage Controller Instance Number (0): 0
Storage Controller Max Port Count (0):  2
Storage Controller Port Count (0):      2
Storage Controller Bootable (0):        on
IDE (0, 0): /home/pcmagas/VirtualBox VMs/Alpine Webserver PHP/Alpine Webserver PHP.vdi (UUID: 9db0d766-8e23-4092-baee-813e787a8e89)
IDE (1, 0): Empty
NIC 1:           MAC: 0800273E019E, Attachment: NAT, Cable connected: on, Trace: off (file: none), Type: 82540EM, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: deny, Bandwidth group: none
NIC 1 Settings:  MTU: 0, Socket (send: 64, receive: 64), TCP Window (send:64, receive: 64)
NIC 1 Rule(0):   name = Rule 1, protocol = tcp, host ip = , host port = 2022, guest ip = , guest port = 22
NIC 2:           MAC: 080027821808, Attachment: Host-only Interface 'vboxnet0', Cable connected: on, Trace: off (file: none), Type: 82540EM, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: allow-all, Bandwidth group: none
NIC 3:           disabled
NIC 4:           disabled
NIC 5:           disabled
NIC 6:           disabled
NIC 7:           disabled
NIC 8:           disabled
Pointing Device: USB Tablet
Keyboard Device: PS/2 Keyboard
UART 1:          disabled
UART 2:          disabled
UART 3:          disabled
UART 4:          disabled
LPT 1:           disabled
LPT 2:           disabled
Audio:           enabled (Driver: PulseAudio, Controller: AC97, Codec: STAC9700)
Audio playback:  enabled
Audio capture:   disabled
Clipboard Mode:  disabled
Drag and drop Mode: disabled
VRDE:            disabled
USB:             enabled
EHCI:            disabled
XHCI:            disabled

USB Device Filters:

<none>

Bandwidth groups:  <none>

Shared folders:  <none>

Capturing:          not active
Capture audio:      not active
Capture screens:    0
Capture file:       /home/pcmagas/VirtualBox VMs/Alpine Webserver PHP/Alpine Webserver PHP.webm
Capture dimensions: 1024x768
Capture rate:       512 kbps
Capture FPS:        25
Capture options:    ac_enabled=false

Guest:

Configured memory balloon size:      0 MB

Και τα δίκτυά του είναι:


Άρα λογικό είναι να ρυθμίζω το 10.0.2.3 στον host-only.

Ακόμα σε ένα άλλο ubuntu vm ορίζοντας την 10.0.2.2 στο ιδιο host-only network παίζει μια χαρά. Μπορώ να κάνω SSH μέσω αυτής.

Τα δυκτια vboxnet0 και vboxnet2 ειναι Down απο οτι βλεπω στο Status. Το vboxnet1 ειναι up. Ισως θα επρεπε να φερεις το vboxnet0 up για να δουμε αν μπορεις να κανεις ping στο 10.0.2.3 (εκτως εαν ενεργοποιηται μονο οταν εχει ξεκινησει το VM - εχω να πιασω virtualbox κατι μηνες).

Παρεπιπτοντως το DHCP του NAT εχει σαν gateway το 10.0.2.2 και σαν DNS server το 10.0.2.3 αν δεν κανω λαθος.

Το δίκτυο vboxnet0 είναι up επειδή εκκίνησα τα VM:

Name:            vboxnet0
GUID:            786f6276-656e-4074-8000-0a0027000000
DHCP:            Disabled
IPAddress:       10.0.2.1
NetworkMask:     255.255.255.0
IPV6Address:     fe80::800:27ff:fe00:0
IPV6NetworkMaskPrefixLength: 64
HardwareAddress: 0a:00:27:00:00:00
MediumType:      Ethernet
Wireless:        No
Status:          Up
VBoxNetworkName: HostInterfaceNetworking-vboxnet0

Ακόμα έχω τα VM:

"Ubuntu 22.04" {83a85552-98ce-415a-b8be-7ad1aba698b4}
"Alpine Webserver PHP" {1b9199ee-f510-499c-802f-285b3f3b38b8}

Στο δεύτερο έχω τα Interfaces:

$ VBoxManage showvminfo 1b9199ee-f510-499c-802f-285b3f3b38b8 | grep NIC
NIC 1:           MAC: 0800273E019E, Attachment: NAT, Cable connected: on, Trace: off (file: none), Type: 82540EM, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: deny, Bandwidth group: none
NIC 1 Settings:  MTU: 0, Socket (send: 64, receive: 64), TCP Window (send:64, receive: 64)
NIC 1 Rule(0):   name = Rule 1, protocol = tcp, host ip = , host port = 2022, guest ip = , guest port = 22
NIC 2:           MAC: 080027821808, Attachment: Host-only Interface 'vboxnet0', Cable connected: on, Trace: off (file: none), Type: 82540EM, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: allow-all, Bandwidth group: none
NIC 3:           disabled
NIC 4:           disabled
NIC 5:           disabled
NIC 6:           disabled
NIC 7:           disabled
NIC 8:           disabled

Όπως και στο πρώτο:

$ VBoxManage showvminfo 83a85552-98ce-415a-b8be-7ad1aba698b4 | grep NIC
NIC 1:           MAC: 080027EF573A, Attachment: NAT, Cable connected: on, Trace: off (file: none), Type: 82540EM, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: deny, Bandwidth group: none
NIC 1 Settings:  MTU: 0, Socket (send: 64, receive: 64), TCP Window (send:64, receive: 64)
NIC 2:           MAC: 0800273A5612, Attachment: Host-only Interface 'vboxnet0', Cable connected: on, Trace: off (file: none), Type: 82540EM, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: deny, Bandwidth group: none
NIC 3:           disabled
NIC 4:           disabled
NIC 5:           disabled
NIC 6:           disabled
NIC 7:           disabled
NIC 8:           disabled

Το δεύτερο πρακτικά είναι μια έκδοση του πρώτου σε διαφορετικό distro ώστε να εξάγω μικρότερο σε μέγεθος ova.

To ubuntu VM έχει στη HostOnly την IP 10.0.2.2 και μπορώ να το Pingάρω:

ping 10.0.2.2
PING 10.0.2.2 (10.0.2.2) 56(84) bytes of data.
64 bytes from 10.0.2.2: icmp_seq=1 ttl=64 time=1.37 ms
64 bytes from 10.0.2.2: icmp_seq=2 ttl=64 time=0.467 ms
^C
--- 10.0.2.2 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 0.467/0.922/1.378/0.456 ms

Δε στο Ubuntu VM έχω σχεδόν πανομοιότυπες ρυθμίσεις:

ping 10.0.2.2
PING 10.0.2.2 (10.0.2.2) 56(84) bytes of data.
64 bytes from 10.0.2.2: icmp_seq=1 ttl=64 time=1.37 ms
64 bytes from 10.0.2.2: icmp_seq=2 ttl=64 time=0.467 ms
^C
--- 10.0.2.2 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 0.467/0.922/1.378/0.456 ms

What the heck?! Κάτι χάνω νομίζω στα settings.

Ακόμα αποπειράθηκα στο alpine να κάνω το άλλο στην eth1 να βάλω DHCP as well:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

auto eth1
iface eth1 dhcp
# iface eth1 inet static
#       address 10.0.2.5/24

Είχα κακορυθμίσει το vboxnet0 έτσι το διόρθωσα διαγράφοιντάς το και δημιουργόντας το απο το 0.
Μετά επαναρύθμισα το alpine:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

auto eth1
iface eth1 inet static
        address 192.168.56.3/21

Και το ubuntu:

network:
  ethernets:
    enp0s3:
      dhcp4: true
    enp0s8:
      addresses:
        - 192.168.56.2/21
  version: 2

και παίζουν.

1 «Μου αρέσει»

@pc_magas
Το δεύτερο αρχείο στον Ubuntu είναι στο netplan;
Το προηγούμενο; Είναι το /etc/vbox/network.conf που αναφέρει ο @GNUTechie ;
Ποιο γραφικό περιβάλλον είναι το συγκεκριμένο του alpine PHP;

No gui, shell only.

Ακόμα το σφάλμα οφείλετε στο ότι το virtualbox θέλει standart IP address range απλά έκανα ξανά το host-only network.