Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the eth0 ip because oft IP conflict #2915

Closed
benboit opened this issue Jan 30, 2014 · 10 comments
Closed

Change the eth0 ip because oft IP conflict #2915

benboit opened this issue Jan 30, 2014 · 10 comments

Comments

@benboit
Copy link

@benboit benboit commented Jan 30, 2014

Hi, we are using the 10.0.0.0 net at work for our Servers. Server within that net are not reachable from a vagrant virtualbox. Even adding a public_network interface using DHCP only works if i explicitly set the interface eth1 in the ping Command. My solution now was to add a Route for the destination IP, but this is a annoying workaround. Is it possible to set a different eth0 IP in the vagrantfile or could this be implemented?

@kikitux

This comment has been minimized.

Copy link
Contributor

@kikitux kikitux commented Jan 31, 2014

hello

you usually end having eth0 on the NAT network in virtualbox, then on
eth1/eth2 you can have other networks.

if I read your email and I understand it correctly, you have a network in
eth1 that have router/gw, and is not working because the route packages
goes over eth0?

can you paste here the output of

ifconfig -a
route -n

and tellme your host and guest os?

On Fri, Jan 31, 2014 at 8:13 AM, Benjamin Boit notifications@github.comwrote:

Hi, we are using the 10.0.0.0 net at work for our Servers. Server within
that net are not reachable from a vagrant virtualbox. Even adding a
public_network interface using DHCP only works if i explicitly set the
interface eth1 in the ping Command. My solution now was to add a Route for
the destination IP, but this is a annoying workaround. Is it possible to
set a different eth0 IP in the vagrantfile or could this be implemented?

Reply to this email directly or view it on GitHubhttps://github.com//issues/2915
.

@benboit

This comment has been minimized.

Copy link
Author

@benboit benboit commented Feb 3, 2014

ifconfig -a

eth0 Link encap:Ethernet HWaddr 08:00:27:47:e9:26
inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe47:e926/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:9082 errors:0 dropped:0 overruns:0 frame:0
TX packets:5210 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:4929114 (4.7 MiB) TX bytes:453716 (443.0 KiB)

eth1 Link encap:Ethernet HWaddr 08:00:27:5e:8d:96
inet addr:192.168.250.150 Bcast:192.168.250.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:598516 errors:0 dropped:0 overruns:0 frame:0
TX packets:545839 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:216251796 (206.2 MiB) TX bytes:103186591 (98.4 MiB)

eth2 Link encap:Ethernet HWaddr 08:00:27:f5:dc:de
inet addr:10.0.3.214 Bcast:10.0.3.255 Mask:255.255.252.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:45358 errors:0 dropped:0 overruns:0 frame:0
TX packets:446 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:4896975 (4.6 MiB) TX bytes:29802 (29.1 KiB)

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:12 errors:0 dropped:0 overruns:0 frame:0
TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1052 (1.0 KiB) TX bytes:1052 (1.0 KiB)

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.0.0 0.0.0.0 255.255.252.0 U 0 0 0 eth2
10.0.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.250.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1

route add -host 10.0.2.114 dev eth2

fixes it, but only for 10.0.2.114 .... (dont want to add each internal server there)

eth2 is used to connect to the interal net (dhcp), eth1 has a static ip to use for etc/hosts (dont know how to update on vagrant up, plugins for that are not working .... )

@benboit

This comment has been minimized.

Copy link
Author

@benboit benboit commented Feb 3, 2014

Host OS is Ubuntu (mint) and guest if Debian Wheezy.

@mitchellh

This comment has been minimized.

Copy link
Member

@mitchellh mitchellh commented Feb 3, 2014

eth0 in Vagrant for now is always NAT. The NAT IP is determined by VirtualBox settings that Vagrant doesn't touch. You can change the NAT IP range by configuring VirtualBox itself.

@mitchellh mitchellh closed this Feb 3, 2014
@killerwolf

This comment has been minimized.

Copy link

@killerwolf killerwolf commented Jul 9, 2015

on a multi-vm vagrant env, this ip is always the same, so how to get a different one, because some services relies on the default ethernet interface.

@mckelvin

This comment has been minimized.

Copy link

@mckelvin mckelvin commented Oct 10, 2015

According to https://www.virtualbox.org/manual/ch09.html#changenat ,

If, for any reason, the NAT network needs to be changed, this can be achieved with the following command:
VBoxManage modifyvm "VM name" --natnet1 "192.168/16"

This can be fixed by modifying your Vagrantfile:

  config.vm.provider "virtualbox" do |vb|
    [...]
    vb.customize ['modifyvm', :id, '--natnet1', '192.168.222.0/24']
    [...]
  end

ALSO SEE:

@mirzawaqasahmed

This comment has been minimized.

Copy link

@mirzawaqasahmed mirzawaqasahmed commented Oct 29, 2015

All,
I am getting a similar problem as "killerwolf" on a multi-vm vagrant env where eth0 of all VMs are getting the same ip. How can this be fixed.

@oliver-dungey

This comment has been minimized.

Copy link

@oliver-dungey oliver-dungey commented Dec 8, 2015

Thanks @mckelvin - my Vagrantfile was booting 7 VM's that refused to talk to each other and your snippit allowed me to move off the 10.0.2 subnet. This in turn avoided some IP clash somewhere on my work network. The clue was running a port scan on my vagrant provisioned salt-master - the results came back with a load of listening ports not appropriate to the VM i.e. some other machine somewhere. For reference on CentOS you can do this as follows:

sudo yum install nmap
sudo nmap -sT -O 192.168.0.100

In the above example my salt-master is 192.168.0.100 so I called nmap from a minion to see what ports it was exposing and couldn't see a listener on 4506 or any familiar services.

@ThorstenS-linux

This comment has been minimized.

Copy link

@ThorstenS-linux ThorstenS-linux commented Nov 24, 2016

thanks @mckelvin - nice trick
I defined a NAT network for every single VM in my multi-machine Vagrantfile. works now. 👍

vb.customize ['modifyvm', :id, '--natnet1', '192.168.222.0/24']
…
vb.customize ['modifyvm', :id, '--natnet1', '192.168.n.0/24']
@hashibot

This comment has been minimized.

Copy link

@hashibot hashibot bot commented Apr 3, 2020

I'm going to lock this issue because it has been closed for 30 days . This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@hashibot hashibot bot locked and limited conversation to collaborators Apr 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
8 participants
You can’t perform that action at this time.