Connection timed out when accessing Vagrant virtual environment from non-host machine

Asked 1 years ago, Updated 1 years ago, 99 views

You want to access virtual machines that you have built in Vagrant from outside of the host machine's PC.
One of the three virtual machines is accessible, but the other two are somehow not.

The current situation is

  • Both machines have config.vm.network "public_network", ip:'192.168.1.100'
    in Vgarnat file. Yes. (ip is changing the third octet or later)
  • bridge: 'en0: Wi-Fi (AirPort)' etc. are omitted, but they don't.
  • Trying to keep connected machines, but two virtual machines are Connection timed out. (Only two machines that cannot connect are always connected.)
  • All are successfully accessed from the host machine.(==>default: Fixed port collision for 22=> Now on port 2200 vagrant box or not, but port collision on ssh has been avoided.)
  • config.vm.boot_timeout=2000.

Below is an excerpt of what is enabled in the vagrant file for machines that cannot connect.

Vagrant.configure("2") do | config |
    config.vm.box="geerlingguy/centos7"
    config.vm.network "forwarded_port", guest:9000, host:9000
    config.vm.network "public_network", ip: '192.168.39.14'
    config.vm.synced_folder "./shared", "/home/vagrant/guest_folder"
    config.vm.boot_timeout=2000

Vagrant.configure("2") do | config |
    config.vm.box="bento/centos-7.3"
      config.vm.network "forwarded_port", guest:4200, host:4200
      config.vm.network "public_network", ip: '192.168.33.11'
      config.vm.synced_folder"./host_folder", "/home/vagrant/guest_folder", type: 'virtualbox', create: true
      config.vm.boot_timeout=2000

I would appreciate it if you could let me know

Note: ifconfig Results
Machine Cannot Connect 1

emp0s3:flags=4163<UP,BROADCAST,RUNNING,MULTICAST>mtu1500
        inet10.0.2.15 netmask 255.255.255.0 broadcast 10.0.2.255
        inet6fe80::a 00:27ff:fe8d:7713 prefixlen64 scopeid0x20<link>
        ether08:00:27:8d:77:13 txqueuelen1000 (Ethernet)
        RX packets 1381 bytes 15697 (153.0 KiB)
        RX errors 0 dropped 0 overruns 0 frame 0
        TX packets 1084 bytes 167110 (163.1 KiB)
        TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

enp0s8 —flags=4163<UP, BROADCAST, RUNNING, MULTICAST>mtu 1500
        inet 192.168.39.14 netmask 255.255.255.0 broadcast 192.168.39.255
        inet6fe80::a 00:27ff: fedb:3e14 prefixlen64 scopeid0x20<link>
        ether08:00:27:db:3e:14 txqueuelen1000 (Ethernet)
        RX packets 564 bytes 46035 (44.9 KiB)
        RX errors 0 dropped 0 overruns 0 frame 0
        TX packets 348 bytes 28476 (27.8 KiB)
        TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo —flags=73<UP, LOOPBACK, RUNNING>mtu65536
        inet 127.0.0.1 netmask 255.0.0.0
        intet6::1 prefixlen 128 scopeid 0x10<host>
        loop txqueuelen 1000 (Local Loopback)
        RX packets 8 bytes 656 (656.0 B)
        RX errors 0 dropped 0 overruns 0 frame 0
        TX packets 8 bytes 656 (656.0 B)
        TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0`

Machine Cannot Connect 2

emp0s3:flags=4163<UP,BROADCAST,RUNNING,MULTICAST>mtu1500
        inet10.0.2.15 netmask 255.255.255.0 broadcast 10.0.2.255
        inet6fe80::7a1f:ee33:b18d:644f prefixlen64 scopeid0x20<link>
        ether08:00:27:37:f8:46 txqueuelen1000 (Ethernet)
        RX packets 1099 bytes 135780 (132.5 KiB)
        RX errors 0 dropped 0 overruns 0 frame 0
        TX packets 907 bytes 153118 (149.5 KiB)
        TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

enp0s8 —flags=4163<UP, BROADCAST, RUNNING, MULTICAST>mtu 1500
        inet 192.168.33.11 netmask 255.255.255.0 broadcast 192.168.33.255
        inet6fe80::a 00:27ff:fef9:94b5 prefixlen64 scopeid0x20<link>
        ether08:00:27:f9:94:b5txqueuelen1000 (Ethernet)
        RX packets 65 bytes 4638 (4.5 KiB)
        RX errors 0 dropped 0 overruns 0 frame 0
        TX packets 93 bytes 11125 (10.8 KiB)
        TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo —flags=73<UP, LOOPBACK, RUNNING>mtu65536
        inet 127.0.0.1 netmask 255.0.0.0
        intet6::1 prefixlen 128 scopeid 0x10<host>
        loop txqueuelen 1000 (Local Loopback)
        RX packets 76 bytes 6552 (6.3 KiB)
        RX errors 0 dropped 0 overruns 0 frame 0
        TX packets 76 bytes 6552 (6.3 KiB)
        TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

virbr0:flags=4099<UP,BROADCAST,MULTICAST>mtu1500
        inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
        ether52:54:00:50:73:70 txqueuelen1000 (Ethernet)
        RX packets 0 bytes 0 (0.0 B)
        RX errors 0 dropped 0 overruns 0 frame 0
        TX packets 0 bytes 0 (0.0 B)
        TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

Host machine ipconfig results
(I didn't know if it was okay to take it out, so I just deleted the Wireless LAN adapter Wi-Fi 2: result.)

Windows IP Configuration


Ethernet Adapter Ethernet:

   Media state............................................................................................................................................................
   Connection-Specific DNS Suffix........:

Ethernet Adapter VirtualBox Host-Only Network #5:

   Connection-Specific DNS Suffix........:
   Link-local IPv6 address........:fe80::7c07:8697:baa:c3eb%15
   IPv4 address . . . . . : 192.168.56.1
   Subnet mask . . . . . : 255.255.255.0
   Default gateway...........:

Ethernet Adapter VirtualBox Host-Only Network #6:

   Connection-Specific DNS Suffix........:
   Link-local IPv6 address........:fe80::686c:7b75:6415:4898%13
   IPv4 address . . . . . : 192.168.33.1
   Subnet mask . . . . . : 255.255.255.0
   Default gateway...........:

Wireless LAN adapter Local Area Connection*1:

   Media state............................................................................................................................................................
   Connection-Specific DNS Suffix........:

Wireless LAN adapter Local Area Connection*2:

   Media state............................................................................................................................................................
   Connection-Specific DNS Suffix........:

I think the information on the nmcli device was also important, so I will post it just in case.
Machine Cannot Connect 1

DEVICE TYPE STATE CONNECTION
enp0s3 ethernet connected enp0s3
enp0s8 ethernet connected system enp0s8
loopback unmanaged --

Machine Cannot Connect 2

DEVICE TYPE STATE CONNECTION
enp0s3 ethernet connected enp0s3
enp0s8 ethernet connected system enp0s8
virbr0 bridge connected virbr0
loopback unmanaged --
virbr0-nic tun unmanaged --

network vagrant

2022-09-30 19:43

1 Answers

Does a network by a bridge register guest machines with the network to which the host machine belongs?So I made the third octet of IP equal to the IP of the host machine!


2022-09-30 19:43

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.