0

i'm trying to create a virtual testing environment. for purpose of testing, i'm going to send udp packets to application running inside the virtual machine. i want to control source ip of the packet when it is received by the application.

i tried different vagrant configurations:

config.vm.network "forwarded_port", guest: 1111, host: 11111, adapter: 2

or

config.vm.network "forwarded_port", guest: 1111, host: 11111, host_ip: "x.x.x.x"

but no success.

it seems to me that this can not be solved by Vagrant alone. unfortunately, i'm completely unfamiliar with iptables/route.

let me explain the problem in greater detail: ideal scenario is to be able to send this from within virtual environment itself - application is listening on some port P. then test script sends data to host1:port1 and it comes through one interface and application sees it's source ip as 1.1.1.1, and when script sends packets to host2:port2, application sees it as though it's coming from 2.2.2.2.

keeping it inside virtual environment is good because i can use just the image across QA local machines and build servers, as it will contain everything.

if this configuration is not possible (though i don't see why), configuring virtual box to have 2 (or more) ports forwarded via different interfaces, so that sending packets to them results in different source addresses.

ilj
  • 859
  • 8
  • 18

1 Answers1

0

This will be partly dependent on the number of unique source address's you'd like to generate. Using just vagrant you can configure multiple machines within your test environment to be part of a private network and have a single one elected as you application server and the others as clients. This has the benefit of allowing you to configure more than just different IP address per client.

If however you would like to generate a wide range of source IP addresses which exceed the number of VM Clients you can run, you could look at ifconfig to create a vlan and test DNS on the virtual interface of either your host machine or a single VM in your test environment.

Sparko
  • 735
  • 6
  • 15