Jmeter: IP spoofing not working - jmeter

To test IP Spoofing I am following below steps:
Open CMD and do nslookup www.xyz.com.asdfg-staging.net
This will give the IP address , add this IP address at the bottom of hosts file.Here C:\Windows\System32\drivers\etc
Open Jmeter and add this IP in Http Sample as shown below:
As instrcuted in links How to setup IP spoofing in jmeter? and send requests with multiple ip address to my application using apache-JMeter(IP Spoofing)
4. Run the tests and I only see red errors in View Results Tree listener but I do not follows step #3 then there are only greens.
What I am expecting is "spoofed IP" i.e. the IP adress that I added in host file should be present in Request tab of View Results Tree listener.
What am I doing wrong here? The tutorials that shared above also asked to edit IPv4 properties , is that really mandatory to achieve what I am looking for?

IP Spoofing is done for the client side addresses. In your screenshot, you are trying to find the value of the spoofed IP in the HOST header which usually points to the actual server hostname and not the IP.
Scenario 1 with no values assigned in IPv4 field with test done against myhost.test.com
Request Headers:
Connection: close
Content-Type: application/json
Content-Length: 162
Host: myhost.test.com
User-Agent: Apache-HttpClient/4.5.2 (Java/1.8.0_111)
Scenario 2 with Source Address field set to 10.1.153.90
Request Headers:
Connection: close
Content-Type: application/json
Content-Length: 162
Host: myhost.test.com
User-Agent: Apache-HttpClient/4.5.2 (Java/1.8.0_111)
**X-LocalAddress: /10.1.153.90**
To me, it looks like you are trying to spoof your server IP to a specific IP provided by the service provider so that you hit only that like Akamai staging environment. In that case, setting your C:\Windows\System32\drivers\etc\hosts file with the assigned IP for your server (not the client) will work outside JMeter and is handled by the OS (not JMeter).
1.54.163.146 myhost.test.com
At the OS level, your OS will take care of sending requests addressed for myhost.test.com to the IP that you gave above in C:\Windows\System32\drivers\etc\hosts file
To see the actual IP address, add a pre-processor (beanshell or equivalent) and add the below lines
import java.net.InetAddress;
InetAddress address = InetAddress.getByName("myhost.test.com");
log.info("Address=" + address.getHostAddress());
If you want to measure your request time taken by this IP addresses, you can put it in a variable and add that in your sampler name
import java.net.InetAddress;
InetAddress address = InetAddress.getByName("myhost.test.com");
log.info("Address=" + address.getHostAddress());
vars.put("addressused", address.getHostAddress());
Then append ${addressused} to your samplername. It will measure the transaction based on samplername+ipaddress

Related

Can we send 5000 request in jmeter with different ip's

I have a requirement where we have to send requests with different/unique IP's and can we set 5000 unique IP's and send through JMeter.
You can set the source IP address for the request under "Advanced" tab of the HTTP Request sampler
The tricky point is that the IP address (or its alias) must exist on the operating system level so the steps you need to take are:
Assign 5k IP addresses (or aliases) to your network interface(s), refer your operating system documentation for details on how this could be done
Put these addresses into a CSV file
Use CSV Data Set Config so each thread could get the new IP address from the CSV file on each iteration
Use the variable from the CSV file in "Source address" field of the HTTP Request sampler
That should be it
More information: Using IP Spoofing to Simulate Requests from Different IP Addresses with JMeter

ip spoofing not working jmeter

I am trying IP spoofing in JMeter HTTP requests but my public IP is going to the request, not the IP address which I have specified under advanced option in HTTP sampler. can anyone help me in this?
I am also sharing the screenshot of my test plan.
here
In my test plan my let's say my IP is x.x.x.x and the IP which I have configured for IP spoofing is: 192.168.23.12 as shown in the screenshot but request to the server is still going with my IP which is x.x.x.x.
Can anyone help me out in this?
As per HTTP Request sampler documentation
Source address field [Only for HTTP Request with HTTPClient implementation]
So change "Implementation" to HttpClient4 and it should start working as expected.
Also be aware that you need to have this IP address (or alias) defined in the underlying operating system.
See Using IP Spoofing to Simulate Requests from Different IP Addresses with JMeter article for more information and configuration instructions for different operating systems.
Please check the below test plan:-

jMeter source address not working

When source address field is empty, all runs fine. When I put in an IP, even if it is my actual IP, I get an error:
Response code: Non HTTP response code: java.net.SocketException
Response message: Non HTTP response message: Network is unreachable: connect
I run Windows... Also I have already tried all the Implementations.
There should be few pre-requisites met:
You need to have HTTPClient implementation (see HTTP Request sampler documentation)
Source address field[Only for HTTP Request with HTTPClient implementation]
In case of single IP address:
The IP address needs to be available in the underlying operating system, it may be either IP associated with NIC or an IP alias
Relevant Source address type needs to be specified, in case of single IP it should be IP/Hostname
See Using IP Spoofing to Simulate Requests from Different IP Addresses with JMeter guide for more detailed information on the domain.

How to make Jmeter recognize "localhost" URL?

How to do performance testing of localhost url which is accessible only to my computer?
I am able to do performance testing using jmeter for live websites like google etc but jmeter is not able to detect local url.
URL of application-192.168.121.20:8001
2. Output of View Results Tree listener- ALL failed http alerts Description of screenshot of HTTP Request sampler- added only server name i.e URL –
I have the same problem, but my mistake is that I thik the Server Name was the URL Base and it is not works.
This is the wrong way:
Server Name: "localhost/api/v1" (Wrong)
Http Request -> Path: "/auth"
Http Request Defaults (Jmeter):
The correct way:
Server Name: "localhost"
Http Request -> Path: "/api/v1/auth"
Http Request Defaults (Jmeter):
Http Request (Test):
JMeter doesn't care whether application under test is local or remote, if you cannot hit local URL with JMeter - something is wrong with your HTTP Request Sampler configuration, most likely "Port" value is wrong.
In order to be able to help we need to know the following:
1. URL of your application
2. Output of View Results Tree listener
3. Contents of JMeter log
4. Description of screenshot of your HTTP Request sampler
As an alternative option you can try recording your scenario using JMeter Chrome Extension and see if you're able to replay recorded scenario without errors. Again, use View Results Tree listener to inspect request and response details.
In general it is not recommended to run the application under test and the load generator on the same physical or virtual machine as the load generator (JMeter in your case) may consume immense amount of resources like CPU and RAM and it may interfere your application health (unless you're using completely isolated containers), so I would recommend use separate hosts for application and the load generator.
For anyone testing localhost with JMeter for the first time, make sure endpoint are configured correctly.
For a Get request of http://localhost:8080/rest/comments, set:
Server Name or IP: localhost
Port Number: 8080
Path: /rest/comments
Method: Get
please note that i have attached images for each step
Step 1 : First create Thread Group .After Create thread group you will see three part.
Number of thread means how many requests you want to perform and loop count means how many time you want to execute
Step 2 : right click on the thread group Add --> Sampler --> http request as like attach image .In the name filed just give a name as like whats you want.In my case it was Order Service http request
In protocol filed i am going to http request so for that i have given http in the box
In the server name i have set it to localhost because i am using local machine .If you use just remote server then use Ip address or domain name . Don't use http or port number before or after the ip address or domain name
In the port number field i am using 9003 that's why I have given 9003 .
In the http request field use your desired http method in my case i will post some data so i am using POST method so that i have selected post method
Path field just use the path after the ip address or domain name or localhost in my case it was order/create-order . please note that do not add forward slash before that. slash will automatically added by JMeter.
As it is post request so My server side request some body data so i have attached that as json format so click on the body data
step 3 : Sometimes you need to pass some header information for example content type . for that you need to create another option HTTP header manager to create that option . Right click on the thread group then add-> config element- > http header manage as like attach image . I have given the content type
Step 4 : Now you are ready to for request to server but sometimes you need to check the response and other thing so for that click on the thread group then add -> listner -> view result tree
Final Step : To execute the request, click on the greeen button from the top bar.
In order to have Jmeter "recognize" localhost (and any other program on your machine) you have to modify host file:
On Windows
Typically host is located under C:/windows/system32/drivers/etc/. Just open it with any text editor.
Add following record to this file and save changes:
127.0.0.1 localhost
On OSx
Open /private/etc/hosts file for editing with any text editor
Add following record to this file and save changes:
127.0.0.1 localhost
As a result you'll map localhost to your computers default local IP address which is 127.0.0.1
Get your ip addres using ipconfig (windows)
Think your URL is - http://192.168.8.149:3000/api/user/showTeams
Use Server Name or IP -192.168.8.149
Use Port Number - 3000
Use Protocol - http
Use Path - api/user/showTeams
Use IPv4 address instead of using localhost or 127.0.0.1 to access your local application.
Get JMeter's recording template from File > Template.
Set proxy on 8888 port and start recording
In my case, I was running a web app using local Tomcat on port 8080. JMeter was unable to connect using localhost:8080/app-name. It was connecting just fine to the remote-host:8080/app-name.
Solution: I found out that there was another application accessible using 127.0.0.1:8080/another-app. Perhaps, this was confusing JMeter. So, eventually, I changed my tomcat port to 9090 using server.xml and then JMeter was able to connect to localhost:9090/app-name
for your path use http://[::1]:{port}/route
[::1] instead of localhost fixed this for me, took me hours to figure that out

Countering Fuckip IP Anonymity FireFox Addon

http://ipfuck.paulds.fr/
We've been recently getting hammered by this Firefox plug-in. It sends a fake IP in the headers so when our nginx web server picks up the IP it is a fake one.
Is there any way to get a real IP address or block out requests that have this plug-in installed?
There is actually no client IP entries in any HTTP Headers. There are only some un-official proxy headers which are added to a request, so that a proxy server can tell you the real ip of the connecting client (since the tcp socket will only reveal the IP address of the proxy server).
The plugin you linked to adds those proxy headers, to "fake" a proxy request, by adding a X-Real-IP: 1.2.3.4 or X-Forwarded-For: 1.2.3.4 header to the request. But no one forces you to use that IP address (which can be fake, like the 1.2.3.4 example here), you can always use the IP address of the socket that initiated the connection - which will be the client's real IP address if he uses the mentioned plugin.
Within the location section of your nginx configuration, you get the socket IP address through the $remote_addr variable. To retrieve the "fake" IP address, you can use $http_x_forwarded_for or $http_x_real_ip variable.
If you are using any application/cgi backend, you usually can examine the full headers and the socket IP address (i.e. in PHP you should check $_REQUEST and $_HEADERS variables)

Resources