10

I have this config:

config.vm.network "public_network", ip: "192.168.56.101", :mac => "0022334455DA"

And after vagrant up ifconfig prints:

 eth0      Link encap:Ethernet  HWaddr 08:00:27:12:96:98
           inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
           inet6 addr: fe80::a00:27ff:fe12:9698/64 Scope:Link
           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
           RX packets:1141 errors:0 dropped:0 overruns:0 frame:0
           TX packets:861 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:1000
           RX bytes:115407 (115.4 KB)  TX bytes:98490 (98.4 KB)

 eth1      Link encap:Ethernet  HWaddr 00:22:33:44:55:da
           inet addr:192.168.56.101  Bcast:192.168.56.255  Mask:255.255.255.0
           inet6 addr: fe80::222:33ff:fe44:55da/64 Scope:Link
           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
           RX packets:319 errors:0 dropped:0 overruns:0 frame:0
           TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:1000
           RX bytes:19236 (19.2 KB)  TX bytes:648 (648.0 B)

 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:16436  Metric:1
           RX packets:0 errors:0 dropped:0 overruns:0 frame:0
           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:0
           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

But I still can't access the server at 192.168.56.101 on my machine or any other on my network. When the config was private_server I could access the address from my machine.

ip route show

default via 10.0.2.2 dev eth0
default via 10.0.2.2 dev eth0  metric 100
10.0.2.0/24 dev eth0  proto kernel  scope link  src 10.0.2.15
192.168.56.0/24 dev eth1  proto kernel  scope link  src 192.168.56.101

When the vm is running, VB network config shows two connections:

Adapter 1
Attached to: NAT

Adapter 2
Attached to: Bridged Adapter
Name: Intel Ethernet Connection

So I guess eth0 is NAT and eth1 is a bridged connection? the Intel Ethernet Connection is my ethernet cable connected to the router.

Also when I open network and sharing center, it tells me there is an unidentified network with 2 connections: VirtualBox Host-Only Network and VirtualBox Host-Only Network #2. Which is confusing as I actually set Vagrant to use a public network.

localhost
  • 203
  • 1
  • 3
  • 6
  • Did you ever figure out a solution? I'm experiencing the same problem. – Mr. T Feb 15 '14 at 06:34
  • @Mr.T, yeah, I just used the correct network: config.vm.network :public_network, ip: "192.168.1.12", mac: "001122334455" – localhost Feb 16 '14 at 00:27
  • For those who have a similar problem but with the Homestead flavor of Vagrant, here is what I found: https://superuser.com/a/1214376/74576 – Ryan Nov 03 '17 at 14:46

2 Answers2

9

Using ifconfig, I found that the netmask assigned to the guest machine differed from the host's bridged interface, so I had to specify it manually. Once I did that, the VM was accessible outside of the host system. Here's my Vagrantfile entry:

config.vm.network :public_network, ip: '172.16.35.51', :netmask => '255.255.0.0', :bridge => 'eth0'
Alan
  • 541
  • 1
  • 6
  • 20
0

If I had to guess from this little amount of information, I would point to the routing table... the 10.0.2.15 eth0 nic is transferring considerably more data.

Daniel Widrick
  • 3,488
  • 2
  • 13
  • 27
  • How can I get more info? – localhost Sep 16 '13 at 16:34
  • `ip route show` from the vm would be a good start... then we need to know what these networks attach to: "10.0.2.15 is nat'd through the visualization software which is shared through the host which sits behing a router/modem and 192.168.56.101 is a bridged adapter connected to the router/modem" etc. – Daniel Widrick Sep 16 '13 at 16:48
  • updated question – localhost Sep 17 '13 at 16:14