I want to connect to the virtual machine from another machine in the Vagrant bridge local.

Asked 1 years ago, Updated 1 years ago, 312 views

You have enabled the following for vagrantfile:I don't wear the host part with anyone else.

config.vm.network "public_network", ip: "192.168.33.100"

Connect to the guest machine and ifconfig results.

 [vagrant@localhost~]$ ifconfig
enp0s3 —flags=4163<UP, BROADCAST, RUNNING, MULTICAST>mtu 1500
        inet10.0.2.15 netmask 255.255.255.0 broadcast 10.0.2.255
        inet6fe80::907d:2b24:c79d:29a9 prefixlen64 scopeid0x20<link>
        ether08:00:27:37:f8:46 txqueuelen1000 (Ethernet)
        RX packets 958 bytes 117229 (114.4 KiB)
        RX errors 0 dropped 0 overruns 0 frame 0
        TX packets 690 bytes 128780 (125.7 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.100 netmask 255.255.255.0 broadcast 192.168.33.255
        inet6fe80::a 00:27ff:fe82:b4 prefixlen64 scopeid0x20<link>
        ether08:00:27:82:00:b4txqueuelen1000 (Ethernet)
        RX packets 27 bytes 4020 (3.9 KiB)
        RX errors 0 dropped 0 overruns 0 frame 0
        TX packets 17 bytes 1354 (1.3 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 txqueuelen1 (Local Loopback)
        RX packets 84 bytes 7232 (7.0 KiB)
        RX errors 0 dropped 0 overruns 0 frame 0
        TX packets 84 bytes 7232 (7.0 KiB)
        TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

I checked the above and tried ssh [email protected] from another machine, but it timed out.What is the cause?

ssh vagrant

2022-09-30 21:51

1 Answers

Vagrant Virtual EnvironmentConnection timed out when accessing from a non-host machine
I had to match the third octet of the host's IP address with the third octet of the fixed ip written in the vagrantfile when I posted it myself and forgot all about it.
Therefore, since the third octet of the host's IP was 1, the problem was solved by rewriting the vagrantfile below and reloading it.

config.vm.network "public_network", ip: "192.168.1.100"


2022-09-30 21:51

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.