和6年能登半島地震により亡くなられた方々のご冥福をお祈りするとともに、被害に遭われた皆さまに対し、心よりお見舞い申し上げます。一日も早く被災地の安全が確保され、復旧が進む事を心よりお祈り申し上げます。

無線LAN環境のVirtualBoxでpingが通らない

無線LAN環境PC(Windows10)のVirtualBox(CentOS:NAT、ホストオンリーアダプター)で
pingが通らない(-“-)
yum updateもできないって事だよね(汗

CentOS Linux release 7.8.2003 (Core)
VirtualBox6.1

設定変更前

# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
    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 qlen 1000
    link/ether 08:00:27:c4:22:98 brd ff:ff:ff:ff:ff:ff
3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:06:71:5d brd ff:ff:ff:ff:ff:ff
    inet 192.168.56.101/24 brd 192.168.56.255 scope global dynamic enp0s8
       valid_lft 405sec preferred_lft 405sec
    inet6 fe80::a00:27ff:fe06:715d/64 scope link
       valid_lft forever preferred_lft forever

設定変更後

# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
    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:c4:22:98 brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic enp0s3
       valid_lft 85193sec preferred_lft 85193sec
    inet6 fe80::a00:27ff:fec4:2298/64 scope link
       valid_lft forever preferred_lft forever
3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 08:00:27:06:71:5d brd ff:ff:ff:ff:ff:ff
    inet 192.168.56.101/24 brd 192.168.56.255 scope global enp0s8
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:fe06:715d/64 scope link
       valid_lft forever preferred_lft forever

そもそも、network-scripts内にホストオンリーアダプター(enp0s8)の設定ファイルが無い!

# ls
ifcfg-enp0s3     ifdown-isdn    ifup-bnep   ifup-routes
ifcfg-lo         ifdown-post    ifup-eth    ifup-sit
ifdown           ifdown-ppp     ifup-ib     ifup-tunnel
ifdown-Team      ifdown-routes  ifup-ippp   ifup-wireless
ifdown-TeamPort  ifdown-sit     ifup-ipv6   init.ipv6-global
ifdown-bnep      ifdown-tunnel  ifup-isdn   network-functions
ifdown-eth       ifup           ifup-plip   network-functions-ipv6
ifdown-ib        ifup-Team      ifup-plusb
ifdown-ippp      ifup-TeamPort  ifup-post
ifdown-ipv6      ifup-aliases   ifup-ppp
nmcli(NetworkManager)で設定してみる!
# nmcli connection add type ethernet con-name enp0s8 ifname enp0s8
接続 'enp0s8' (077818b0-b9ec-4539-820b-1310d39feed0) が正常に追加されました。

# ls
ifcfg-enp0s3     ifdown-ipv6    ifup-aliases  ifup-ppp
ifcfg-enp0s8     ifdown-isdn    ifup-bnep     ifup-routes
ifcfg-lo         ifdown-post    ifup-eth      ifup-sit
ifdown           ifdown-ppp     ifup-ib       ifup-tunnel
ifdown-Team      ifdown-routes  ifup-ippp     ifup-wireless
ifdown-TeamPort  ifdown-sit     ifup-ipv6     init.ipv6-global
ifdown-bnep      ifdown-tunnel  ifup-isdn     network-functions
ifdown-eth       ifup           ifup-plip     network-functions-ipv6
ifdown-ib        ifup-Team      ifup-plusb
ifdown-ippp      ifup-TeamPort  ifup-post
# cat ifcfg-enp0s3
TYPE=Ethernet
BOOTPROTO=dhcp
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=enp0s3
UUID=cd64098d-6347-4e4b-bf61-21058ac91b40
DEVICE=enp0s3
ONBOOT=no
# cat ifcfg-enp0s8
TYPE=Ethernet
BOOTPROTO=dhcp
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=enp0s8
UUID=077818b0-b9ec-4539-820b-1310d39feed0
DEVICE=enp0s8
ONBOOT=yes
# nmcli connection show
名前        UUID                                  タイプ          デバイス
enp0s8      077818b0-b9ec-4539-820b-1310d39feed0  802-3-ethernet  --
有線接続 1  f9c45c48-0a4f-4dca-8c50-70d1db95310b  802-3-ethernet  enp0s8
enp0s3      cd64098d-6347-4e4b-bf61-21058ac91b40  802-3-ethernet  --
enp0s8が重複しているので「有線接続 1」消しちゃう!
# nmcli connection delete f9c45c48-0a4f-4dca-8c50-70d1db95310b

固定IPを指定しちゃう。

# nmcli connection modify enp0s8 ipv4.method manual ipv4.addresses 192.168.56.101/24

ネットワークサービス再起動!!

systemctl restart network.service

設定後

# cat ifcfg-enp0s3
TYPE=Ethernet
BOOTPROTO=dhcp
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=enp0s3
UUID=cd64098d-6347-4e4b-bf61-21058ac91b40
DEVICE=enp0s3
ONBOOT=no
# cat ifcfg-enp0s8
TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=enp0s8
UUID=077818b0-b9ec-4539-820b-1310d39feed0
DEVICE=enp0s8
ONBOOT=yes
IPADDR=192.168.56.101
PREFIX=24
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
# nmcli -p connection show enp0s8
===============================================================================
                      Connection profile details (enp0s8)
===============================================================================
connection.id:                          enp0s8
connection.uuid:                        077818b0-b9ec-4539-820b-1310d39feed0
connection.interface-name:              enp0s8
connection.type:                        802-3-ethernet
connection.autoconnect:                 yes
connection.autoconnect-priority:        0
connection.timestamp:                   1594261577
connection.read-only:                   no
connection.permissions:
connection.zone:                        --
connection.master:                      --
connection.slave-type:                  --
connection.secondaries:
connection.gateway-ping-timeout:        0
-------------------------------------------------------------------------------
802-3-ethernet.port:                    --
802-3-ethernet.speed:                   0
802-3-ethernet.duplex:                  --
802-3-ethernet.auto-negotiate:          yes
802-3-ethernet.mac-address:             --
802-3-ethernet.cloned-mac-address:      --
802-3-ethernet.mac-address-blacklist:
802-3-ethernet.mtu:                     自動
802-3-ethernet.s390-subchannels:
802-3-ethernet.s390-nettype:            --
802-3-ethernet.s390-options:
-------------------------------------------------------------------------------
ipv4.method:                            manual
ipv4.dns:
ipv4.dns-search:
ipv4.addresses:                         192.168.56.101/24
ipv4.gateway:                           --
ipv4.routes:
ipv4.route-metric:                      -1
ipv4.ignore-auto-routes:                no
ipv4.ignore-auto-dns:                   no
ipv4.dhcp-client-id:                    --
ipv4.dhcp-send-hostname:                yes
ipv4.dhcp-hostname:                     --
ipv4.never-default:                     no
ipv4.may-fail:                          yes
-------------------------------------------------------------------------------
ipv6.method:                            auto
ipv6.dns:
ipv6.dns-search:
ipv6.addresses:
ipv6.gateway:                           --
ipv6.routes:
ipv6.route-metric:                      -1
ipv6.ignore-auto-routes:                no
ipv6.ignore-auto-dns:                   no
ipv6.never-default:                     no
ipv6.may-fail:                          yes
ipv6.ip6-privacy:                       -1 (不明)
ipv6.dhcp-send-hostname:                yes
ipv6.dhcp-hostname:                     --
-------------------------------------------------------------------------------
===============================================================================
      Activate connection details (077818b0-b9ec-4539-820b-1310d39feed0)
===============================================================================
GENERAL.名前:                           enp0s8
GENERAL.UUID:                           077818b0-b9ec-4539-820b-1310d39feed0
GENERAL.デバイス:                       enp0s8
GENERAL.状態:                           アクティベート済み
GENERAL.デフォルト:                     いいえ
GENERAL.デフォルト6:                    いいえ
GENERAL.VPN:                            いいえ
GENERAL.ゾーン:                         --
GENERAL.DBUS パス:                      /org/freedesktop/NetworkManager/ActiveConnection/2
GENERAL.CON パス:                       /org/freedesktop/NetworkManager/Settings/2
GENERAL.スペックオブジェクト:           /
GENERAL.マスターパス:                   --
-------------------------------------------------------------------------------
IP4.アドレス[1]:                        192.168.56.101/24
IP4.ゲートウェイ:
-------------------------------------------------------------------------------
IP6.アドレス[1]:                        fe80::a00:27ff:fe06:715d/64
IP6.ゲートウェイ:
-------------------------------------------------------------------------------
疎通成功!!
# ping www.yahoo.co.jp
PING edge12.g.yimg.jp (182.22.25.124) 56(84) bytes of data.
64 bytes from 182.22.25.124: icmp_seq=1 ttl=56 time=21.8 ms
64 bytes from 182.22.25.124: icmp_seq=2 ttl=56 time=22.2 ms
64 bytes from 182.22.25.124: icmp_seq=3 ttl=56 time=23.3 ms