2
I have created with Vagrant a brand new VM running Ubuntu 12.04 Since I need to access the VM always at the same IP address I have assigned to it a MAC address and set my DHCP in order to assign the same IP to the machine with that MAC.
My VagrantFile looks like
Vagrant::Config.run do |config|
config.vm.box = "ubuntu-vm"
config.vm.box_url = "http://files.vagrantup.com/precise32.box"
config.vm.network :bridged, :bridge => "BGigabit Ethernet", :mac => "080027234567"
end
The VM is correctly created and the same IP assigned every time I boot it up. However, the Gateway is not properly configured.
Here my ifconfig
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:436 errors:0 dropped:0 overruns:0 frame:0
TX packets:360 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:46526 (46.5 KB) TX bytes:41271 (41.2 KB)
eth1 Link encap:Ethernet HWaddr 08:00:27:23:45:67
inet addr:142.17.1.10 Bcast:142.17.3.255 Mask:255.255.252.0
inet6 addr: fe80::a00:27ff:fe12:3456/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:910 errors:0 dropped:6 overruns:0 frame:0
TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:72559 (72.5 KB) TX bytes:1604 (1.6 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: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)
and here my routes
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 10.0.2.2 0.0.0.0 UG 0 0 0 eth0
default 10.0.2.2 0.0.0.0 UG 100 0 0 eth0
10.0.2.0 * 255.255.255.0 U 0 0 0 eth0
142.17.0.0 * 255.255.252.0 U 0 0 0 eth1
The eth1 gateway should be 142.17.0.1. Shouldn't the correct address be fetched from the DHCP?
Do I have to specify some extra params in my Vagrantfile to make it work?
THANKS.
You can only have one default gateway per system (not per interface). Your current gateway is set to 10.0.2.2 (probably the Vagrant master) over eth0 (Vagrant's management interface) – CyberJacob – 2013-11-07T08:29:17.913
I see, the first issue is why eth1 has 142.17.0.0 instead 142.17.0.1 that is the gateway in my DHCP?
Moreover, how can I set the last route as default? – Sig – 2013-11-07T08:33:26.617
You don't have a gateway set on eth1. 142.17.0.0 is the network address (covers 142.17.0.1 to 142.17.0.254) which is routed directly to eth1 without using a gateway. – CyberJacob – 2013-11-07T08:38:07.920
Thanks for you help. So, you mean everything seems fine to you. Correct? – Sig – 2013-11-07T08:59:53.197
Yes, it does. can you ping 8.8.8.8? – CyberJacob – 2013-11-07T19:13:55.863
From inside the VM I can ping it however I'm not able to ping any other machine in the network
--- 142.17.1.4 ping statistics --- 24 packets transmitted, 0 received, 100% packet loss, time 23096ms
– Sig – 2013-11-08T03:45:30.363