Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linux,ssh: set IP_BIND_ADDRESS_NO_PORT on connected socket #379

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

crrodriguez
Copy link

if binding to a local address (ssh -b ...) the source port is taken at bind() time when the kernel does not know if the socket will be connect()ed or listen()ed on. It also does not know the destination host or port so it has to reserve the port until the socket is closed, effectively limiting the number of useful source ports to ~32k. a very small number in the modern era.

Set IP_BIND_ADDRESS_NO_PORT, which delays source port allocation to connect() time allowing a few million connections out from the same -b address.

sshconnect.c Outdated Show resolved Hide resolved
@crrodriguez crrodriguez force-pushed the IP_BIND_ADDRESS_NO_PORT branch 2 times, most recently from 7d79ede to 9ab742d Compare December 27, 2023 21:33
sshconnect.c Outdated Show resolved Hide resolved
if binding to a local address (ssh -b ...) the source port is taken
at bind() time when the kernel does not know if the socket
will be connect()ed or listen()ed on. It also does not
know the destination host or port so it has to reserve the port
until the socket is closed, effectively limiting the number
of useful source ports to ~32k. a very small number in the modern era.

Set IP_BIND_ADDRESS_NO_PORT, which delays source port allocation
to connect() time allowing a few million connections out from the
same -b address.
@crrodriguez crrodriguez force-pushed the IP_BIND_ADDRESS_NO_PORT branch from 9ab742d to 93ab609 Compare December 6, 2024 17:58
Copy link

@kalvdans kalvdans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautiful, short way to do the argument to setsockopt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants