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
or in /etc/sysctl.conf:
Code:
net.ipv4.ip_local_port_range = 49152 65535
oh and this range is apparently called the "ephemeral" port range.
well, that's me having learnt a whole bunch today... nice to know. thanks!