10-Mar-2015 09:44
Hi,
Still to new to iRules so I have problem figuring out rule that will simulate clients coming from different geolocations when traffic is generated from limited pool of private ip addresses. So something like that: 1. Packet is coming with private IP 2. Random generator (I will find code for that but if somebody has ready one allowing to generate country located ip I will appreciate sharing) is generating some IP and replacing original one with generated before sending request to server - actually it would be great if it could be changed on client side but I doubt it is possible? I would like to generate some date for Analytic and other statistic modules on LTM 3. Before sending response packet destination IP is changed back to original source IP before sending back to the client
Piotr
10-Mar-2015
11:08
- last edited on
03-Jun-2023
09:14
by
JimmyPackets
Hi Piotr,
here is a sample iRule to do exactly this:when CLIENT_ACCEPTED {
snat [expr { int(rand()*193) + 1}].[expr { int(rand()*254) + 1}].[expr { int(rand()*254) +1}].[expr { int(rand()*253) +1}]
}
Thanks, Stephan
10-Mar-2015
11:14
- last edited on
03-Jun-2023
09:14
by
JimmyPackets
And maybe you find these useful as well:
when CLIENT_ACCEPTED {
snat 10.10.10.[expr ( [getfield [IP::client_addr] "." 4] % 32 ) + 1]
snat 10.10.[getfield [IP::client_addr] "." 3].[getfield [IP::client_addr] "." 4]
}
The following one simulates varying clients by inserting a randomized X-Forwarded-For and uses another internal virtual server for processing:
when HTTP_REQUEST {
snat automap
HTTP::header insert X-Forwarded-For [expr int(rand()*128) + 32].[expr int(rand()*254)].[expr int(rand()*254)].[expr int(rand()*254)]
virtual vs_internal
}
03-Jun-2023 01:27
Hi Pitor,
I understand that you had a question back in 2015 about simulating clients from different geolocations using a limited pool of private IP addresses. Although your question was from a few years ago, I wanted to provide an updated answer for anyone facing a similar challenge in 2023.
If you're looking to simulate clients from different geolocations using a limited pool of private IP addresses, you can consider using a random IP address generator. I recommend checking out https://randomtools.io/random-ipaddress-generator/ for a ready-to-use tool that can generate country-located IP addresses.
To achieve the desired flow:
Please keep in mind that modifying IP addresses in transit may have specific limitations or dependencies on the network infrastructure and client capabilities.