Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Networking
User Name
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.


  Search this Thread
Old 12-21-2006, 04:40 AM   #1
Registered: Feb 2006
Location: belgium
Distribution: FC5
Posts: 39

Rep: Reputation: 16
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.
Old 12-21-2006, 05:02 AM   #2
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1971Reputation: 1971Reputation: 1971Reputation: 1971Reputation: 1971Reputation: 1971Reputation: 1971Reputation: 1971Reputation: 1971Reputation: 1971Reputation: 1971
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...
echo "49152 65535" > /proc/sys/net/ipv4/ip_local_port_range
or in /etc/sysctl.conf:
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!

Last edited by acid_kewpie; 12-21-2006 at 05:08 AM.
Old 12-21-2006, 05:24 AM   #3
Registered: Feb 2006
Location: belgium
Distribution: FC5
Posts: 39

Original Poster
Rep: Reputation: 16
Thank you very much Chris, just what I needed.

And happy to see I'm not alone learning everyday ;-)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Linux laptop promblem: PCI: Cannot allocate resource region 7 of bridge 0000:00:1c1 tryynanen Linux - Laptop and Netbook 3 07-24-2006 03:51 PM
outbound port 80 winchester169 Linux - Security 1 07-21-2006 04:32 PM
Error inserting lockd: Cannot allocate memory - Linux Iceberg69 Linux - Software 1 09-29-2005 11:20 PM
Linux outbound dialer? jmral23 Linux - Newbie 1 12-17-2003 09:01 PM
Unable to allocate Partition (XP & Linux) Monish Linux - Software 2 08-19-2003 05:23 AM

All times are GMT -5. The time now is 01:58 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration