質問

To test my implementation of a NAT, I want to send TCP packets from one internal host to two different external hosts, and make sure that the source port for both streams of packets that leave the NAT have the same source port. How can I control the source port? wget uses different source ports for separate TCP connections.

役に立ちましたか?

解決

Maybe you want to try netcat with -p option, if you don't want to write code by yourself, example: $ nc -p 31337 www.google.com 80

Here is the explanation for "-p" option from man page: Specifies the source port nc should use, subject to privilege restrictions and availability. It is an error to use this option in conjunction with the -l option.

Note though to use any port under 1024 requires root permission.

他のヒント

Bind the socket to a specific local port before you connect it.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top