Nate Jones
unread,Jul 23, 2013, 2:28:30 PM7/23/13Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to vagra...@googlegroups.com, drb...@umich.edu, jon...@umich.edu
Hi,
A bit of background on the project I'm working on:
Me and
my coworkers are working on an Android library called MANES that
emulates local Adhoc (wifi direct) communication through a server
cluster located in Amazon EC2. When applications based on this library
want to send packets to other phones within Adhoc range, the library
sends the data to our server cluster, which calculates what other phones
are nearby the sending phone (using a combination of GPS coordinates
and if they have access to identical wireless routers). The packets are
then sent back from our servers to other phones that were found to be
within range of the sending phone, and are forwarded from the MANES
library to the correct application.
Our library sends packets to
port 7889 (among others), utilizing both UDP and TCP protocols on the same port, and
this has worked fine on our EC2 instances. We found Vagrant, and thought
it could help speed production, and reduce costs of server maintenance,
as we won't have to launch additional EC2 instances to test our server
software.
The problem is, in Vagrant we are trying to forward
both UDP and TCP packets from port 7889 on the host machine to the same
port on the guest machine; however, only one of the two protocols is
ever forwarded to the guest machine (which ever one is last in the
Vagrantfile).
The following lines in the Vagrantfile seem to be the issue (I am using Vagrant 1.2.4-1, installed on Arch Linux):
Vagrant.configure("2") do |config|
# ... (database server is configured)
packet_config['count'].times do |i|
# Hostname is set
config.vm.define "#{hostname}" do |box|
box.vm.network :forwarded_port, host: 7889, guest: 7889, protocol: :tcp
box.vm.network :forwarded_port, host: 7889, guest: 7889, protocol: :udp
# ... (additional servers configured, and other settings)
end
end
end
This is part of the log that forwards the port:
INFO interface: info: Forwarding ports...
[packet-00] Forwarding ports...
INFO
subprocess: Starting process: ["/usr/bin/VBoxManage", "showvminfo",
"af3ada75-94cd-4530-b5f3-e3315fcc5e8b", "--machinereadable"]
INFO interface: info: -- 22 => 2200 (adapter 1)
[packet-00] -- 22 => 2200 (adapter 1)
INFO interface: info: -- 7889 => 7889 (adapter 1)
[packet-00] -- 7889 => 7889 (adapter 1)
INFO
subprocess: Starting process: ["/usr/bin/VBoxManage", "modifyvm",
"af3ada75-94cd-4530-b5f3-e3315fcc5e8b", "--natpf1",
"ssh,tcp,127.0.0.1,2200,,22", "--natpf1", "7889,udp,,7889,,7889"]
Using
tcpdump, we found that only UDP packets were being forwarded to the
guest machine using the vagrantfile above, and when we switched the two
lines around (UDP before TCP), only TCP packets were being forwarded
(confirmed using the vagrant logs).
We were able to work around
this using a vb.customize statement as follows, while removing the
vm.network statements in the vagrantfile above:
box.vm.provider :virtualbox do |vb|
vb.customize [
"modifyvm", :id,
"--name", hostname,
"--memory", packet_config['memory'],
"--natdnshostresolver1", "on",
"--nataliasmode1", "sameports",
"--natpf1", '"tcp7889,tcp,,7889,,7889"',
"--natpf1", '"udp7889,udp,,7889,,7889"'
]
This allowed us to forward both UDP and TCP packets.
Now,
we have our software working on Vagrant fine now using this work-around, but I was wondering if the
vb.customize statement is necessary, or if we should report a bug to
the maintainers of Vagrant about being able to forward both TCP and UDP.
Thanks,
Nate Jones