Jmeter: IP spoofing not working

旧街凉风 提交于 2019-12-06 16:58:42

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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!