我从一位同事那里获得了一个 VirtualBox VM,他用 vagrant 设置了它(尽管我只通过 VirtualBox 启动 VM 并以密码身份登录vagrant
)vagrant
。
在这个虚拟机中,他为我们的一个应用程序设置了一个开发环境。虚拟机的网络配置如下:
- 适配器 1:NAT
- 适配器 2:仅主机适配器(vboxnet0 - 基本设置,无 DHCP)
在这个虚拟机中,有一个通过.bashrc
( docker start mysql > /dev/null 2>&1
) 启动的 MySQL docker,这个 docker 被我们的应用程序使用。问题是,无论我想用这个 MySQL 做什么,都要花整整 10 秒钟才能连接到它(即使只有一个telnet
)。你知道问题可能出在哪里吗?我会把任何可能对我有帮助的数据加入到这个问题中。提前谢谢你。
查看我的 /etc/network/interfaces
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
auto eth1
iface eth1 inet static
address 192.168.56.101
netmask 255.255.255.0
network 192.168.56.0
broadcast 192.168.56.255
当我这样做时route -n
:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.0.2.2 0.0.0.0 UG 0 0 0 eth0
10.0.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 docker0
192.168.56.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
还有一个ifconfig
:
docker0 Link encap:Ethernet HWaddr 56:84:7a:fe:97:99
inet addr:172.17.42.1 Bcast:0.0.0.0 Mask:255.255.0.0
inet6 addr: fe80::5484:7aff:fefe:9799/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:536 (536.0 B) TX bytes:648 (648.0 B)
eth0 Link encap:Ethernet HWaddr 08:00:27:1d:ae:8b
inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe1d:ae8b/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:391 errors:0 dropped:0 overruns:0 frame:0
TX packets:406 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:39758 (39.7 KB) TX bytes:35582 (35.5 KB)
eth1 Link encap:Ethernet HWaddr 08:00:27:57:d0:a2
inet addr:192.168.56.101 Bcast:192.168.56.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe57:d0a2/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:60 errors:0 dropped:0 overruns:0 frame:0
TX packets:14 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:13376 (13.3 KB) TX bytes:1276 (1.2 KB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:22 errors:0 dropped:0 overruns:0 frame:0
TX packets:22 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1472 (1.4 KB) TX bytes:1472 (1.4 KB)
veth493bc8d Link encap:Ethernet HWaddr 7a:ac:69:9c:1a:b6
inet6 addr: fe80::78ac:69ff:fe9c:1ab6/64 Scope:Link
UP BROADCAST RUNNING MTU:1500 Metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:16 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:648 (648.0 B) TX bytes:1296 (1.2 KB)
编辑:另外,我的/etc/hosts
(******
代表我们的一些子域名):127.0.0.1 localhost
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
172.16.200.11 *********.********.fr
127.0.0.1 mysql
127.0.0.1 postgresql
127.0.0.1 *********.**********.com
127.0.0.1 *********.**********.com