LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 12-21-2006, 03:40 AM   #1
genese
Member
 
Registered: Feb 2006
Location: belgium
Posts: 76

Rep: Reputation: 20
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, 04:02 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
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!

Last edited by acid_kewpie; 12-21-2006 at 04:08 AM.
 
Old 12-21-2006, 04:24 AM   #3
genese
Member
 
Registered: Feb 2006
Location: belgium
Posts: 76

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

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


Reply



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 02:51 PM
outbound port 80 winchester169 Linux - Security 1 07-21-2006 03:32 PM
Error inserting lockd: Cannot allocate memory - Linux 2.6.13.2 Iceberg69 Linux - Software 1 09-29-2005 10:20 PM
Linux outbound dialer? jmral23 Linux - Newbie 1 12-17-2003 08:01 PM
Unable to allocate Partition (XP & Linux) Monish Linux - Software 2 08-19-2003 04:23 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 08:48 PM.

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