1

I'm using curl command to send the traffic to the Server. In curl command, I'm using --local-port option. Below is the command:

curl -v --interface 10.1.1.3 -b --local-port 10000 http://30.1.1.101/myfile.txt

I'm taking tcpdump to confirm that whether the local-port is used or not. Below is the tcpdump stats(image):

tcpdump stats

tcpdump stats

After checking the tcpdump, I have observed that the local-port value is different in tcpdump. It is supposed to be like 10.1.1.1:10000 not like 10.1.1.1:random_val.

So my questions are:

  1. Is it possible to force curl to use the same local-port that I have mentioned in the command?

  2. What's the reason for getting different local-port value?

Any help would be appreciated

  • Any Solution for above problem? – alpha Jul 6 '18 at 7:35
  • According man curl as of v7.15.2 it should be possible via --local-port to "Set a preferred single number or range (FROM-TO) of local port numbers to use for the connection(s).". In a short test on my system it was working as long as port was free. – U880D Jul 18 '18 at 9:08
  • In your case, if the port were not free "If you ask for a local port number (or range) that curl can't obtain for you, it will exit with a failure.", according Using curl - Connections and which wasn't the case according your description. However, can you try with a port range? – U880D Jul 18 '18 at 9:17

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.