I'm Writing a script in python2.7 on a windows XP machine. The machine is connected to multiple networks using different network cards.
I'm running into an issue where I've bound a UDP Socket to a specific interface(I understand that you can accomplish this in windows by just providing the network cards existing IP address)
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self.sock.bind(('10.31.9.0', 6466)) #<<< 10.31.9.0 is address of desired card
I then set the timeout to 5s
self.sock.settimeout(5)
Then I try to send a message out to a server that I can prove exists and works. then wait for a response.
self.destintation = ('10.42.40.34', 62434)
# Send the msg
self.sock.sendto(msg, self.destintation)
# receive data
reply, addr = self.sock.recvfrom(1024)
However a socket.timeout is always thrown. so I open up wire shark to see what is going wrong, and it turns out that my initial message never gets sent on the desired interface.
What I do see is an arp broadcast on a different interface(10.10.10.12 ) from my machine asking who is attached to my desired destination IP:
1 0.000000 IntelCor_8c:6d:97 Broadcast ARP 42 Who has 10.42.40.34? Tell 10.10.10.12
Of course there is no response to the broadcast because the 10.42.40.34 Address/machine is not reachable from the 10.10.10.12 interface
How do I tell Python to send the ARP broadcast out on '10.31.9.0'? What have I done Wrong?
EDIT:
Additional Information> The network for the interface I am using is a Class B (netmask is 255.255.0.0)
The interface IP is : 10.31.9.0
The target IP is: 10.42.40.34.
I am wondering if the issue is a result of my target sitting on a separate subnet. However, as described in a related issue here. there is traffic from the server to me... =/
UPDATE:
Results of "route PRINT 10*"
Active Routes:
Network Destination Netmask Gateway Interface Metric
10.0.0.0 255.0.0.0 10.10.10.12 10.10.10.12 10
10.10.10.12 255.255.255.255 127.0.0.1 127.0.0.1 10
10.31.0.0 255.255.0.0 10.31.9.0 10.31.9.0 10
10.31.9.0 255.255.255.255 127.0.0.1 127.0.0.1 10
10.255.255.255 255.255.255.255 10.10.10.12 10.10.10.12 10
10.255.255.255 255.255.255.255 10.31.9.0 10.31.9.0 10
Default Gateway: 153.4.84.1
===========================================================================
Persistent Routes:
None
UPDATE #2 Full route PRINT
Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 153.4.84.1 153.4.85.81 10
10.10.0.0 255.255.0.0 10.10.10.12 10.10.10.12 10
10.10.10.12 255.255.255.255 127.0.0.1 127.0.0.1 10
10.31.0.0 255.255.0.0 10.31.9.0 10.31.9.0 10
10.31.9.0 255.255.255.255 127.0.0.1 127.0.0.1 10
10.255.255.255 255.255.255.255 10.10.10.12 10.10.10.12 10
10.255.255.255 255.255.255.255 10.31.9.0 10.31.9.0 10
127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1
153.4.84.0 255.255.252.0 153.4.85.81 153.4.85.81 10
153.4.85.81 255.255.255.255 127.0.0.1 127.0.0.1 10
153.4.255.255 255.255.255.255 153.4.85.81 153.4.85.81 10
192.168.56.0 255.255.255.0 192.168.56.1 192.168.56.1 20
192.168.56.1 255.255.255.255 127.0.0.1 127.0.0.1 20
192.168.56.255 255.255.255.255 192.168.56.1 192.168.56.1 20
224.0.0.0 240.0.0.0 10.10.10.12 10.10.10.12 10
224.0.0.0 240.0.0.0 10.31.9.0 10.31.9.0 10
224.0.0.0 240.0.0.0 153.4.85.81 153.4.85.81 10
224.0.0.0 240.0.0.0 192.168.56.1 192.168.56.1 20
255.255.255.255 255.255.255.255 10.10.10.12 10.10.10.12 1
255.255.255.255 255.255.255.255 10.31.9.0 10.31.9.0 1
255.255.255.255 255.255.255.255 153.4.85.81 153.4.85.81 1
255.255.255.255 255.255.255.255 192.168.56.1 192.168.56.1 1
255.255.255.255 255.255.255.255 192.168.56.1 5 1
Default Gateway: 153.4.84.1
===========================================================================
Persistent Routes:
None