Vaprobash icon indicating copy to clipboard operation
Vaprobash copied to clipboard

Public Network Addition to Vagrantfile : Device Testing

Open grayghostvisuals opened this issue 11 years ago • 5 comments

Since device testing is pretty important these days I thought I would suggest adding this line to the base Vagrantfile before I submit a PR. This would also be noted in the README regarding usage.

config.vm.network :public_network, :bridge => 'en1: Wi-Fi (AirPort)'

grayghostvisuals avatar Sep 03 '14 11:09 grayghostvisuals

I'm not sure we can make assumption on the network to bridge on - for example, my wifi is on en0 instead of en1:

image

fideloper avatar Sep 03 '14 11:09 fideloper

Is there a way to dynamically detect and adjust for that? maybe using a variable of some sort?

grayghostvisuals avatar Sep 03 '14 13:09 grayghostvisuals

I'm not sure on that, that would be nice tho!

fideloper avatar Oct 06 '14 17:10 fideloper

@fideloper Forgive my ignorance here, but when you ran networksetup -listallhardwareports it looks like you were not ssh'd into your vagrant machine. Can you run vagrant ssh then run ifconfig and list to me what it reports if it differs from your original lines above?

looks like this for me…

grayghostvisuals ✭ grayghostvisualsmacbookair.rochester.rr.com in ~/Vagrant/vaprobash on master
$ networksetup -listallhardwareports

Hardware Port: Bluetooth DUN
Device: Bluetooth-Modem
Ethernet Address: N/A

Hardware Port: Wi-Fi
Device: en0
Ethernet Address: 98:fe:94:47:dd:1a

Hardware Port: Bluetooth PAN
Device: en1
Ethernet Address: N/A

Hardware Port: Thunderbolt 1
Device: en2
Ethernet Address: 32:00:1a:fb:53:20

Hardware Port: Thunderbolt Bridge
Device: bridge0
Ethernet Address: N/A
grayghostvisuals ✭ grayghostvisualsmacbookair.rochester.rr.com in ~/Vagrant/vaprobash on master
$ vagrant ssh
Welcome to Ubuntu 14.04.1 LTS (GNU/Linux 3.13.0-35-generic x86_64)
vagrant@vaprobash:~$ ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:6e:fb:ee
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe6e:fbee/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2429 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2267 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:186873 (186.8 KB)  TX bytes:176913 (176.9 KB)

eth1      Link encap:Ethernet  HWaddr 08:00:27:87:c3:b5
          inet addr:192.168.22.10  Bcast:192.168.22.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:19019 errors:0 dropped:0 overruns:0 frame:0
          TX packets:16233 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:7809702 (7.8 MB)  TX bytes:9208644 (9.2 MB)

eth2      Link encap:Ethernet  HWaddr 08:00:27:6f:b1:a9
          inet addr:192.168.1.109  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2204 errors:0 dropped:0 overruns:0 frame:0
          TX packets:18 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:306815 (306.8 KB)  TX bytes:2234 (2.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:3747 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3747 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:7171650 (7.1 MB)  TX bytes:7171650 (7.1 MB)

grayghostvisuals avatar Oct 06 '14 17:10 grayghostvisuals

Correct I was on my Mac.

Vagrant bridges to an existing network interface, or creates a new on on your host machine.

When you add the following:

config.vm.network :public_network, :bridge => 'en1: Wi-Fi (AirPort)'

...to your Vagrantfile, you're telling Vagrant which network on your host machine to bridge to (you're not telling Vagrant what network to create within the Virtual machine, but the VM will be setup to communicate over the bridged network).

I'm not 100% sure on the inner workings of this either, what I just said is about as far as I know for sure :D

In any case, here's what I see within a Vagrant server running that command:

  1. From my mac:

image

  1. From with a Vagrant VM, using ifconfig:

image

Keep in mind my Vagrantfile contains this:

config.vm.network :private_network, ip: "192.168.33.10"

I'm not specifically bridging a network here, I'm creating a private network for use between my Mac and the Virtual Machine.

fideloper avatar Oct 06 '14 17:10 fideloper