Здравствуйте!
Устанавливаю окружение CentOS (host) + VirtualBox + Vagrant + (VM Ubuntu (guest) + Apache)
host
Static hostname: centos3
Icon name: computer-laptop
Chassis: laptop
Operating System: CentOS Linux 8 (Core)
CPE OS Name: cpe:/o:centos:centos:8
Kernel: Linux 4.18.0-147.8.1.el8_1.x86_64
Architecture: x86-64
firewall отключен
интерфейсы host
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: enp2s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
link/ether 50:7b:9d:d8:52:9b brd ff:ff:ff:ff:ff:ff
3: wlp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether a8:a7:95:c0:08:9f brd ff:ff:ff:ff:ff:ff
inet 192.168.0.150/24 brd 192.168.0.255 scope global noprefixroute wlp3s0
valid_lft forever preferred_lft forever
inet6 fe80::a16a:5309:70c0:761e/64 scope link noprefixroute
valid_lft forever preferred_lft forever
4: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 52:54:00:b5:74:d2 brd ff:ff:ff:ff:ff:ff
inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
valid_lft forever preferred_lft forever
5: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc fq_codel master virbr0 state DOWN group default qlen 1000
link/ether 52:54:00:b5:74:d2 brd ff:ff:ff:ff:ff:ff
6: vboxnet0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
link/ether 0a:00:27:00:00:00 brd ff:ff:ff:ff:ff:ff
inet 192.168.88.1/24 brd 192.168.88.255 scope global vboxnet0
valid_lft forever preferred_lft forever
inet6 fe80::800:27ff:fe00:0/64 scope link
valid_lft forever preferred_lft forever
Содержание Vagrantfile
config.vm.network "forwarded_port", guest: 80, host: 8881
config.vm.network "private_network", ip: "192.168.100.100"
config.vm.network "public_network", ip: "192.168.0.155", bridge: "wlp3s0"
> vagrant up
Вывод консоли
default: Adapter 1: nat
default: Adapter 2: hostonly
default: Adapter 3: bridged
default: 80 (guest) => 8881 (host) (adapter 1)
default: 22 (guest) => 2222 (host) (adapter 1)
интерфейсы guest
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: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 08:00:27:bb:14:75 brd ff:ff:ff:ff:ff:ff
inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic eth0
valid_lft 86330sec preferred_lft 86330sec
inet6 fe80::a00:27ff:febb:1475/64 scope link
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 08:00:27:ea:2e:fd brd ff:ff:ff:ff:ff:ff
inet6 fe80::a00:27ff:feea:2efd/64 scope link
valid_lft forever preferred_lft forever
4: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 08:00:27:f1:9d:87 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.155/24 brd 192.168.0.255 scope global eth2
valid_lft forever preferred_lft forever
inet6 fe80::a00:27ff:fef1:9d87/64 scope link
valid_lft forever preferred_lft forever
firewall отключен
Состояние после vagrant up:
Из guest доступен интернет и host
Из host машины доступен apache на forwarded_port ip: 192.168.0.150:8881
Из host машины доступен apache на public_network ip: 192.168.0.155
Из host машины пингуется 192.168.0.155
Проблема № 1: С других физических машин в подсети 192.168.0.ХХХ не пингуется guest на public_network ip 192.168.0.155 и не доступен apache на public_network ip: 192.168.0.155
Проблема № 2: Видно, что после поднятия vagrant up не присваивается public_network ip 192.168.100.100 на адаптер виртуальной машины.
Присваиваем вручную в терминале guest машины
> sudo ip addr add 192.168.100.100/255.255.255.0 broadcast 192.168.100.255 dev eth1
eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 08:00:27:ea:2e:fd brd ff:ff:ff:ff:ff:ff
inet 192.168.100.100/24 brd 192.168.100.255 scope global eth1
valid_lft forever preferred_lft forever
inet6 fe80::a00:27ff:feea:2efd/64 scope link
valid_lft forever preferred_lft forever
Проблема № 2 остается: с host не пингуется guest по адресу 192.168.100.100 и не доступен apache по private_network ip: 192.168.100.100
Маршруты на Host
ip r
default via 192.168.0.1 dev wlp3s0 proto static metric 600
192.168.0.0/24 dev wlp3s0 proto kernel scope link src 192.168.0.150 metric 600
192.168.1.0/24 dev vboxnet5 proto kernel scope link src 192.168.1.1
192.168.88.0/24 dev vboxnet0 proto kernel scope link src 192.168.88.1 linkdown
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 linkdown
Маршруты на Guest
default via 10.0.2.2 dev eth0 proto dhcp src 10.0.2.15 metric 100
10.0.2.0/24 dev eth0 proto kernel scope link src 10.0.2.15
10.0.2.2 dev eth0 proto dhcp scope link src 10.0.2.15 metric 100
192.168.0.0/24 dev eth2 proto kernel scope link src 192.168.0.155
192.168.100.0/24 dev eth1 proto kernel scope link src 192.168.100.100