Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Im looking for a way to have applications started from different accounts automatically bind to a specific network interface. For example: applications started on accountA bind to eth0 and applications started from accountB bind to eth1. Is there any way I can accomplish this? I hope this is easier to understand. I would like to do this because im looking to share a dedicated server with someone. It would be beneficial if we could have account specific ip's so we could both run services requiring the same port without the hassle of trying to bind every application.

share|improve this question
    
Hang on a sec - this is a dupe of a question that was closed without any commentary about why it was closed. If we need clarification, lets ask for it. –  Paul Nov 24 '11 at 3:41
    
@Josh, do you mean for example that firefox would use eth0 for user0 and use eth1 for user1? Can you add a bit more detail in the question as to why you want to do this and what your hardware setup is. –  Paul Nov 24 '11 at 3:43
    
Question seems valid but at least a bit inconsistent: one interface can have multiple IP addresses and binding is usually happening to an IP address not to an interface. –  vtest Nov 24 '11 at 6:15
    
Hi @Josh, welcome to Super User. If your question is closed, please don't re-ask it. Instead, you can just edit your original question and leave a comment asking for people to consider reopening it based on your edits. I'm going to merge these questions for you now that you've edited it to be more clear, but in the future, please don't re-ask. –  nhinkle Nov 24 '11 at 22:31
    
@vtest I was talking about virtual interfaces but yes binding to different ip's is the goal in mind –  Josh Nov 24 '11 at 23:23
add comment

migrated from superuser.com Dec 2 '11 at 20:50

This question came from our site for computer enthusiasts and power users.

1 Answer

First you have to configure all interfaces with their own routing tables (look at /etc/iproute2/rt_tables). Then you need to mark traffic based on UID. Use ipt_owner module for that. Then add routing rules for these marks (fwmark). This is good start for such exercise: Linux Advanced Routing & Traffic Control HOWTO

share|improve this answer
    
does this work for services like Apache? –  Josh Nov 24 '11 at 23:37
    
It works for Apache but not for different Apache pages. Apache runs under one UID (usually www or wwwrun). You can use suEXEC to change UID of your CGIs and in this case all connections initiated from these scripts will use different interfaces. –  Cougar Nov 25 '11 at 7:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.