LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux > 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
 
Thread Tools
Old 11-05-2009, 06:04 PM   #1
stockwellgreen
LQ Newbie
 
Registered: Nov 2009
Posts: 2
Thanked: 0
Question How do processes decide which network interface/IP to use?


[Log in to get rid of this advertisement]
I apologise if this is a idiot question, I've searched at length but failed to find an answer!

My server has 1 NIC, configured with 5 public IPs. From analysing log files there seems little consistency with which running processes decide on which IP to use when making outgoing connections. For example, if I run a PHP script on an Apache instance listening on IP X, which sends out an email, I find that my mail server has initiated the SMTP connection on IP Y, or sometimes IP Z.

Are there any general rules for how processes decide which IPs they'll use to initiate socket connections? The configuration for most daemons seems to include the specification of which addresses to bind to, to listen for incoming connections, but not which addresses to utilise for unsolicited outgoing connections.

Please enlighten me.
windows_vista stockwellgreen is offline     Reply With Quote
Old 11-05-2009, 10:35 PM   #2
kbp
Member
 
Registered: Aug 2009
Posts: 484
Thanked: 44
If you check your routing table.. generally the first match is used to send off-network traffic

eg.
Code:
netstat -nr
I'd guess that your routing table will have a default gateway entry (flags = UG) that references a specific interface not a specific IP address, that's why you're seeing some randomness

cheers

Last edited by kbp; 11-05-2009 at 10:36 PM.. Reason: typo
linuxfedora kbp is offline     Reply With Quote
Old 11-07-2009, 02:27 PM   #3
stockwellgreen
LQ Newbie
 
Registered: Nov 2009
Posts: 2
Thanked: 0

Original Poster
Question

Thanks for the reply, now I'm really confused!

This is my routing table:

Code:
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
aa.bb.cc.128   0.0.0.0         255.255.255.248 U         0 0          0 eth0
0.0.0.0         aa.bb.cc.129   0.0.0.0         UG        0 0          0 eth0
0.0.0.0         aa.bb.cc.129   0.0.0.0         UG        0 0          0 eth0
0.0.0.0         aa.bb.cc.129   0.0.0.0         UG        0 0          0 eth0
0.0.0.0         aa.bb.cc.129   0.0.0.0         UG        0 0          0 eth0
0.0.0.0         aa.bb.cc.129   0.0.0.0         UG        0 0          0 eth0
And my interface, as shown by ifconfig -a, is:

Code:
eth0      Link encap:Ethernet  HWaddr 00:22:19:d6:66:d6
          inet addr:aa.bb.cc.130  Bcast:aa.bb.cc.135  Mask:255.255.255.248
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

eth0:1    Link encap:Ethernet  HWaddr 00:22:19:d6:66:d6
          inet addr:aa.bb.cc.131  Bcast:aa.bb.cc.135  Mask:255.255.255.248
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

eth0:2    Link encap:Ethernet  HWaddr 00:22:19:d6:66:d6
          inet addr:aa.bb.cc.132  Bcast:aa.bb.cc.135  Mask:255.255.255.248
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

eth0:3    Link encap:Ethernet  HWaddr 00:22:19:d6:66:d6
          inet addr:aa.bb.cc.133  Bcast:aa.bb.cc.135  Mask:255.255.255.248
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

eth0:4    Link encap:Ethernet  HWaddr 00:22:19:d6:66:d6
          inet addr:aa.bb.cc.134  Bcast:aa.bb.cc.135  Mask:255.255.255.248
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
My public IPs, as allocated by the ISP, are aa.bb.cc.130 - aa.bb.cc.134. I'm assuming aa.bb.cc.128 is the network address, and aa.bb.cc.129 is the ISPs router which my server connects to.

My mail server is listening on all of the public IPs, .130 - .134, yet mainly makes outgoing connections via the .134 IP. Apart from occasionally when it uses .132 or .133 (it may use the others too, I've not trawled through every single log!).

Presumably there's some underlying logic at work that I'm unaware of?
windows_vista stockwellgreen is offline     Reply With Quote
Old 11-07-2009, 03:38 PM   #4
nimnull22
Member
 
Registered: Jul 2009
Distribution: OpenSuse 11.1
Posts: 300
Thanked: 15
May be that article can help a bit.
http://linux-ip.net/html/adv-multi-internet.html
linux nimnull22 is online now     Reply With Quote

Reply

Bookmarks


Thread Tools

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
How NET_TX_SOFTIRQ select network interface when multiple interface exits Mr.J Linux - Kernel 0 06-03-2009 08:45 PM
In FC6 network interface doesn't come up if 'service network restart' command is run rajat Linux - Networking 2 05-03-2007 12:53 AM
any way to see network usage by processes irfanhab Linux - Networking 3 04-19-2007 07:27 PM
network interface (BCM4401-B0) hangs on hight network load indig0kid Linux - Hardware 0 03-09-2007 10:49 AM
Which processes are using network? bobest Linux - Security 1 03-13-2006 10:43 AM


All times are GMT -5. The time now is 10:54 PM.

Main Menu
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
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration