Configuration of the /etc/network/interfaces and /etc/dhcp/dhcpd.conf by Vagrantfile?

200 views
Skip to first unread message

_nobody_ _nobody_

unread,
Jan 30, 2018, 11:34:09 PM1/30/18
to Vagrant

Hello to everyone,


I have an interesting question here: Can I provide by Vagrantfile the configuration of /etc/network/interfaces, namely, can I add in the etc/network/interfaces the following:


# The USB-Ethernet interface 2
allow-hotplug eth2
iface eth2 inet dhcp


The another question is: can I define by Vagrantfile the following dhcpd.conf file?
/etc/dhcp/dhcpd.conf : /etc/dhcp/dhcpd.conf

I have set it like this:


## cat /etc/dhcp/dhcpd.conf
##
## DHCP Server Configuration file.
##   see /usr/share/doc/dhcp-server/dhcpd.conf.example
##   see dhcpd.conf(5) man page
##

default-lease-time 600;
max-lease-time 18000;

subnet 192.168.15.0 netmask 255.255.255.0 {
##   interface enp0s25;
   range dynamic-bootp 192.168.15.100 192.168.15.200;
   option broadcast-address 192.168.15.255;
   next-server 192.168.15.2;
   option subnet-mask 255.255.255.0;
}

host bbb {
   hardware ethernet D0:5F:B8:FF:F8:69;
   fixed-address 192.168.15.20;
   filename "bbb-image";
}

host pdu {
   hardware ethernet 88:b6:27:01:62:43;
   fixed-address 192.168.15.21;
   filename "pdu-image";
}


Or I can import the files, written in some other languages (.xml, .json, .jinja2 or something else)?


Any examples of the shelf for these cases?


Thank you,
Zoran (I use this account, since my primary account is on other three Open Source mailing lists)


Alvaro Miranda Aguilera

unread,
Jan 31, 2018, 4:01:12 AM1/31/18
to vagra...@googlegroups.com
hello

can we step back a bit?

What do you need to happen, then we can check on how we can make that to happen.


By default vagrant provides one interface as Nat

on top of that you can add private (in a isolated network) or public (bridged to some interface)

you can choose dhcp (default) or some fixed ip

That cover most of the use cases

if you need anything more complex you can use:

config.vm.network "public_network", auto_config: false

and Vagrant won't configure the interface and you can use a shell script if you like.

So, what you want to do,? lets leave the how out for a bit

Alvaro

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/7b7a6c7b-4e85-4fb1-889c-e6e549196bbe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Alvaro

_nobody_ _nobody_

unread,
Jan 31, 2018, 10:38:17 AM1/31/18
to Vagrant
Hello Alvaro,

Here is my VBox Vagrant file (important part of it):

I have one physical ETH0 interface, and I also configured NAT forwarding, and here it is:

# Forward port 8888 for the internal REST server
  config
.vm.network :forwarded_port, guest: 8888, host: 8888
 
# Forward port 8010 for the Storage Server
  config
.vm.network :forwarded_port, guest: 8010, host: 8010
 
# Forward port 5000 for the KernelCI Frontend Web Server
  config
.vm.network :forwarded_port, guest: 5000, host: 5000
 
# Forward port 80 for the http Lava Frontend Web Server
  config
.vm.network :forwarded_port, guest: 8080, host: 8080
 
# Forward port 443 for the https Lava Frontend Web Server
  config
.vm.network :forwarded_port, guest: 443, host: 4443
 
# Configure network accessibility for tftp server
  config
.vm.network "public_network", :dev => "eth1", use_dhcp_assigned_default_route: true
  config
.vm.network "private_network", bridge: "eth2", ip: "192.168.15.2"

I would like to have private network hanging of VM, which is actually coming from USB->ETH convertor (AX88772) hanging of the host. Here is its configuration:

vbox.customize ["modifyvm", :id, "--usb", "on"]
    vbox
.customize ["modifyvm", :id, "--usbehci", "on"]
    vbox
.customize ["usbfilter", "add", "0",
     
"--target", :id,
     
"--name", "ASIX Electronics Corp. AX88772 [0001]",
     
"--vendorid", "0B95",
     
"--productid", "7720",
     
"--revision", "0001",
     
"--manufacturer", "ASIX Electronics Corp.",
     
"--product", "AX88772"]

Now, I would like to associate this device with my ETH2 adapter, give it the address 192.168.15.2, and configure it as: "ip route add default via 192.168.15.1 dev eth2" .

So, I would like to have ETH0 as port forwarding (so I do NOT need IP address on it), I also would like ETH1 to be inactive, and ETH2 to be my interface to the small private network.

In other words, I would like to hijack USB port (from where AX88772 hangs) from host, use it on VM for my external purposes. But I am not succeeding???

Here is my ifconfig:

root@stretch:~# ifconfig
eth0
: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet
10.0.2.15  netmask 255.255.255.0  broadcast 10.0.2.255
        inet6 fe80
::a00:27ff:fe8d:c04d  prefixlen 64  scopeid 0x20<link>
        ether
08:00:27:8d:c0:4d  txqueuelen 1000  (Ethernet)
        RX packets
3235  bytes 290021 (283.2 KiB)
        RX errors
0  dropped 0  overruns 0  frame 0
        TX packets
2492  bytes 461392 (450.5 KiB)
        TX errors
0  dropped 0 overruns 0  carrier 0  collisions 0

eth1
: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80
::a00:27ff:fe57:855c  prefixlen 64  scopeid 0x20<link>
        ether
08:00:27:57:85:5c  txqueuelen 1000  (Ethernet)
        RX packets
6498  bytes 658331 (642.9 KiB)
        RX errors
0  dropped 1  overruns 0  frame 0
        TX packets
119  bytes 28152 (27.4 KiB)
        TX errors
0  dropped 0 overruns 0  carrier 0  collisions 0

eth2
: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet
192.168.15.2  netmask 255.255.255.0  broadcast 192.168.15.255
        inet6 fe80
::a00:27ff:fec9:a365  prefixlen 64  scopeid 0x20<link>
        ether
08:00:27:c9:a3:65  txqueuelen 1000  (Ethernet)
        RX packets
80  bytes 7816 (7.6 KiB)
        RX errors
0  dropped 0  overruns 0  frame 0
        TX packets
108  bytes 8436 (8.2 KiB)
        TX errors
0  dropped 0 overruns 0  carrier 0  collisions 0

lo
: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet
127.0.0.1  netmask 255.0.0.0
        inet6
::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen
1  (Local Loopback)
        RX packets
28690  bytes 9108243 (8.6 MiB)
        RX errors
0  dropped 0  overruns 0  frame 0
        TX packets
28690  bytes 9108243 (8.6 MiB)
        TX errors
0  dropped 0 overruns 0  carrier 0  collisions 0

root@stretch
:~#

The question is: how I associate via Vagrant AX88772 with ETH2 port???

Thank you,
Zoran

Alvaro Miranda Aguilera

unread,
Feb 1, 2018, 8:47:28 AM2/1/18
to vagra...@googlegroups.com
hello

choose one of these:

- you pass the USB to the VM and configure that in the VM . what you are doing with vbox manage is plug the usb IN the VM
- configure the USB on the host, check what eth is, and use network_private to make a nic on the VM using that.

one or the other, no both

then use a shell script to remove the default gw and add one to the network/gwip you want, on the documentation is one example

you are very close, but I think you need to take 1 step back on my questions and then you should be there

good work

Alvaro

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Message has been deleted

_nobody_ _nobody_

unread,
Feb 2, 2018, 12:09:47 AM2/2/18
to Vagrant
This is the perfect answer (which I knew already/yesterday I got the more complete idea - the domain I am in is not so trivial). The only problem here: I do NOT see/envision anywhere in such /bin/bash script Vagrant/Vagrant environment?!

We are talking here about Vagrant networking, ain't/aren't we???

Thank you,
Zoran

_nobody_ _nobody_

unread,
Mar 12, 2018, 4:57:11 AM3/12/18
to Vagrant
There is an action going on regarding this issue. Please, find the explanation in some details here:

[Former issue #9426] Assigning private network to ETH2 interface got magically assigned to the ETH1 interface?! #9510
https://github.com/hashicorp/vagrant/issues/9510

Private network IP assigned to wrong interface on vagrant reload #9546
https://github.com/hashicorp/vagrant/issues/9546

Thank you,
Zoran
_______
Reply all
Reply to author
Forward
0 new messages