문제

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