Guest OS: CentOS6 Host OS: MacOS Catalina
・ Set below. Allocation: Host-only adapter ・ Confirmation of name Name: vboxnet0
Check the network with ʻip a` on centos. In the case of my setting, I confirmed that eth2 was added by the setting of ①, but the IP address was not set in eth2. It is unknown why it was eth2 instead of eth1. ..
> ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN ------abridgement--------- 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 inet 10.0.2.15/24 brd 10.0.2.255 scope global eth0 inet6 fe80::a00:27ff:fe84:eb71/64 scope link 3: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 ↑ No IP address listed
Set manually. (1) Add the configuration file for eth2 under / etc / sysconfig / network-scripts /. I have / etc / sysconfig / network-scripts / ifcfg-eth0 but not / etc / sysconfig / network-scripts / ifcfg-eth2, so I copied the ifcfg-eth0 file.
> cd /etc/sysconfig/network-scripts/ > ls ifcfg-eth0 ifdown-ippp ifup-aliases ifup-ppp ifdown-ipv6 ifup-bnep ifup-routes ifdown-isdn ifup-eth ifup-sit ifdown-post ifup-ippp ifup-tunnel ifdown-ppp ifup-ipv6 ifup-wireless ifcfg-lo ifdown-routes ifup-isdn init.ipv6-global ifdown ifdown-sit ifup-plip net.hotplug ifdown-bnep ifdown-tunnel ifup-plusb network-functions ifdown-eth ifup ifup-post network-functions-ipv6 ↑ ifcfg-There is no eth2 file. > cp ifcfg-eth0 ifcfg-eth2
⑵ Check the network status of mac. Check the network address of the name (vboxnet0) set in the virtualbox network with ifconfig from the terminal. Derived from the IP address and subnet mask. If the IP address is 192.168.56.1/24, 192.168.56.0 will be the network address.
(3) Change the ifcfg-eth2 file that you copied earlier to the correct contents. As it is, it is exactly the same as the ifcfg-eth0 file!
DEVICE=eth0 HWADDR=＊＊＊＊＊＊＊＊＊＊＊＊ TYPE=Ethernet UUID=＊＊＊＊＊＊＊＊＊＊＊＊ ONBOOT=yes NM_CONTROLLED=yes BOOTPROTO=dhcp
↓ Change to the following
DEVICE=eth2 # HWADDR=＊＊＊＊＊＊＊＊＊＊＊＊ Comment out TYPE=Ethernet # UUID=＊＊＊＊＊＊＊＊＊＊＊＊ Comment out ONBOOT=yes NM_CONTROLLED=ye BOOTPROTO=none ← changed from dhcp IPADDR=192.168.56.2 ← added PREFIX=24 ← added
・ DEVICE is specified as eth2 (Here, eth2 was newly added in ʻip a
earlier, so match it) If eth1 etc. is output by ʻip a, enter the output device name
-Change BOOTPROTO from dhcp to none so that the IP address is not automatically assigned.
-Add an address that can be assigned to the network address confirmed in (2) to IPADDR. Since I was using 192.168.56.1 on my mac, I set it to 192.168.56.2.
PREFIX is set to the same value as confirmed in ⑵.
service network restart
・ About host-only adapter I increased the NIC by adding a host-only adapter in virualbox. The host-only adapter is set to connect only the host OS (MacOS) and guest OS (CentOS6), and cannot be connected to the outside. ・ This connection method The NIC on the host OS side (192.168.56.1 in this example) and the NIC on the guest OS side (192.168.56.2 in this example) were connected.