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 -b --local-port 10000

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 not like

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.