Ori Marko
Ori Marko

Reputation: 58772

JMeter - Set HTTP Source address (aka IP spoofing) isn't working

I want to send HTTP request using different IP country,

I tried to assign Source address by IP, also with HTTPClient4, and it fails:

java.net.BindException: Cannot assign requested address: JVM_Bind
    at java.net.DualStackPlainSocketImpl.bind0(Native Method)
    at java.net.DualStackPlainSocketImpl.socketBind(Unknown Source)
    at java.net.AbstractPlainSocketImpl.bind(Unknown Source)
    at java.net.PlainSocketImpl.bind(Unknown Source)
    at java.net.Socket.bind(Unknown Source)
    at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:339)
    at org.apache.jmeter.protocol.http.sampler.hc.LazyLayeredConnectionSocketFactory.connectSocket(LazyLayeredConnectionSocketFactory.java:92)
    at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
    at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl$JMeterDefaultHttpClientConnectionOperator.connect(HTTPHC4Impl.java:336)
    at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:374)
    at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:393)
    at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
    at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
    at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
    at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
    at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
    at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.executeRequest(HTTPHC4Impl.java:843)
    at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:574)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:67)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1231)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1220)
    at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:622)
    at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:546)
    at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:486)
    at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:253)
    at java.lang.Thread.run(Unknown Source)

I found previous post and answer, but it seems irrelevant, because HttpClient4 isn't working

So change "Implementation" to HttpClient4 and it should start working as expected.

I tried with Java implementation and although it didn't failed, it didn't updated the IP seen in server

I added in hosts file a line with the IP

1.33.213.199 localhost

Can I change my IP in HTTP Request using vanilla JMeter?

Upvotes: 1

Views: 1833

Answers (1)

Dmitri T
Dmitri T

Reputation: 168002

It does work, you're getting the error because the IP address (or at least an IP alias) must exist on the system so Java (and JMeter) could use it as the source address for establishing a Socket connection.

  1. Open network connection properties

    enter image description here

  2. Open IPv4 properties

    enter image description here

  3. Click "Advanved" button

    enter image description here

  4. Add IP address(es) you want to simulate

    enter image description here

More information: Using IP Spoofing to Simulate Requests from Different IP Addresses with JMeter

Upvotes: 1

Related Questions