How does linux allocate outbound ports ?
Hello All,
For some good reasons I won't discuss here, I configure daemons to listen on unprivileged ports. My question is : how can I make sure that these ports will always be free for my daemons ? Does linux automatically exclude ports listed in /etc/services before choosing a port number for outbound connection ? Is it another way to exclude a port range from outbound ports allocation ? TIA for your help. |
to be honest i don't nkow the exact allocation policy, but i wouldn't expect it to refer to an external file before doing this. i'd not think there would be any need to check though, just to pick the next available port, normally counted through sequentially. if a port is alrady in use, be it an existing client connection or an obscure service, it'll just plain be in use so avoided. most client connections only use a certain port number for a few seconds or minutes, and unless you're starting a service manually on a heavily loaded systme, i can't imagine you'll ever have a snowball in hells chance of wishing to us the same ports.
it does seem that you can control what client port ranges are permitted though... Code:
echo "49152 65535" > /proc/sys/net/ipv4/ip_local_port_range Code:
net.ipv4.ip_local_port_range = 49152 65535 well, that's me having learnt a whole bunch today... nice to know. thanks! |
Thank you very much Chris, just what I needed.
And happy to see I'm not alone learning everyday ;-) |
All times are GMT -5. The time now is 02:16 AM. |