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 6927953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:07:17+00:00 2026-05-27T11:07:17+00:00

The target machine running the python application will have three network interfaces available to

  • 0

The target machine running the python application will have three network interfaces available to it. In general all three networks will be vastly different, however there is a possibility that two of the three could be on similar networks.

In the example below I do not have control over the destination address on ETH 2 (as it a pre-configured system), so I forced into selecting what adapter to use programmaticly.

I am fairly sure that this will fall on how the OS works with routing the connections. My hope is that there will be a platform independent way to solve the issue using python, because there is a possibility that this application will need to run on Windows 7 as well as a Linux machine.

Example Code

import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('192.168.0.2', 8000)) # Which device will this connect to??

Normal Case

  • ETH 0 Source: 192.168.0.1
  • ETH 0 Destination: 192.168.0.2
  • ETH 1 Source: 10.20.30.1
  • ETH 1 Destination: 10.20.30.2
  • ETH 2 Source: 60.50.40.1
  • ETH 2 Destination: 60.50.40.1

Possible Trouble Case

  • ETH 0 Source: 192.168.0.1
  • ETH 0 Destination: 192.168.0.2
  • ETH 1 Source: 10.20.30.1
  • ETH 1 Destination: 10.20.30.2
  • ETH 2 Source: 192.168.0.3
  • ETH 2 Destination: 192.168.0.2

Additional Information
Adapters ETH0,1,and 2 are all connected to different physical netoworks

  • 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. Editorial Team
    Editorial Team
    2026-05-27T11:07:18+00:00Added an answer on May 27, 2026 at 11:07 am

    On Windows, if you know the IP address of the interface you want to use, just bind to that before you connect. On Linux,use socket option SO_BINDTODEVICE as suggested by JimB (seems to be a privileged call too).

    i.e. on Windows

    import socket
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.bind(('192.168.0.1', 0))
    s.connect(('...'))
    

    Binding source address under Windows, selects the interface with the same IP address as that device, even if that IP address has a higher routing metric cost. This doesn’t work under Linux though, as it always overwrites the source address with the IP address of the selected device. Routing is done based solely on the destination address. The only exception it seems is if you set source address to 127.0.0.1, then Linux prevents these packets from going out of that box.

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

Sidebar

Related Questions

We currently have an web application running on IIS6 on a 32bit machine. This
The target machine is running Ububtu server 8.04. Here's the tramp output: tramp: Opening
I have an application I wrote which has been running well for 4 years.
I have an application running on iis(7) ( asp.net mvc if that matters )
On my machine I have a WSDL file and all the necessary schema files.
I have a windows 2003 / IIS 6.5 machine running a classic ASP site.
Can I debug a program running on a remote target to which I have
I have an external Windows .exe that is actually Java application: Running the .exe
Target application is a medium-sized website built to support several hundred to several thousand
(The target browser is IE8) I have a div that contains a list of

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.