Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 151543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:27:59+00:00 2026-05-11T09:27:59+00:00

This could be considered a continuation of this earlier SO question . Ideally, I’d

  • 0

This could be considered a continuation of this earlier SO question.

Ideally, I’d like to jail a process into only using a certain interface, no matter what. It will be making TCP connections, sending UDP datagrams, and listening for UDP broadcasts. Currently, what I am doing is:

  1. Determine the IP of the interface to use.
  2. Create an IP policy rule to route all packets coming from the interface to that IP
  3. Create another IP policy rule to route all packets coming from that IP to that interface
  4. Set up a default routing table for each rule

Now, this works, mostly, but the client process has to also be willing to play along. That is, it needs to bind to the specific IP of the interface it wants to use, and I think I need to set SO_BINDTODEVICE as well. (However, I keep reading conflicting information about whether SO_BINDTODEVICE actually works when using TCP or UDP.) Luckily, the client application is Python, and I can extend the socket class to do all of this transparently. But I’m not sure it is a complete solution, especially with regard to receiving broadcasts.

My questions are:

  1. Does SO_BINDTODEVICE do what I want here? Or is it only effective for raw sockets? Someone commented that, ‘SO_BINDTODEVICE on a socket doesn’t guarantee the socket will only receive packets that arrived on that physical interface’s wire/antenna.’ If this is indeed true, then what does SO_BINDTODEVICE do?

  2. Is there a way to do this such that the local IP doesn’t have to be unique? This wouldn’t be a problem other than the fact that the DHCP server on one interface may allocate it an IP that is in use by another interface, thus confusing the routing table.

  3. How do I receive broadcasts only from a specific interface? Binding to a specific IP seems to make it ignore broadcasts, which makes sense, but isn’t quite what I’m looking for.

I’m running on Ubuntu 8.04 w/ Linux kernel 2.6.26. Being able to access the same subnet on two different networks through two different interfaces simultaneously is a non-negotiable requirement, thus making it (mostly) immune to ‘don’t do that.’ 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T09:27:59+00:00Added an answer on May 11, 2026 at 9:27 am

    After a hard-fought weekend, I’m pleased to present a solution that addresses most of what I’ve previously discussed with almost zero hassle.

    There is a sysctl called net.ipv4.conf.all.rp_filter that can be set to 0 to disable source validation:

         rp_filter - INTEGER          2 - do source validation by reversed path, as specified in RFC1812              Recommended option for single homed hosts and stub network              routers. Could cause troubles for complicated (not loop free)              networks running a slow unreliable protocol (sort of RIP),              or using static routes.           1 - (DEFAULT) Weaker form of RP filtering: drop all the packets              that look as sourced at a directly connected interface, but              were input from another interface.           0 - No source validation. 

    This can also be set on a per interface basis using /proc/sys/net/ipv4/conf/<interface>/rp_filter.

    As one poster explained it, it makes IP routing ‘less deterministic’ in the sense that packets coming from one subnet aren’t guaranteed to always go out the same interface. In this instance, this is exactly what it is needed. Please do additional research to determine if this is really what you want.

    Broadcasts are still problematic for reasons I do not understand, but I am finally satisfied with this issue and I hope it helps others.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This could be considered a duplicate question, as a similar one has already been
I suppose this question could just as easily be applied to PHP with regard
This could be weird, Have you ever come across a blog which you wanted
This could be a little off the ballpark, but a friend asked me about
Can anybody please explain how this could possibly happen? I am completely aware of
I am busy writing my thesis (so, I guess this could count as a
Possible Duplicate: How do I calculate someone's age in C#? Maybe this could be
I have a lot of classes in the App_Code directory could this be a
I have roughly the following code. Could this be made nicer or more efficient?
I could do this in C#.. int number = 2; string str = Hello

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.