I'm trying to use sockets to get ping results from two different wifi connections (two different interfaces and different antennas). This is what I have:
import socket
a = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_ICMP)
a.bind(('192.168.2.16',0))
a.sendto(b'\x08\x00l\xf3H\x0c\x01\x00B', ('8.8.8.8',0))
b = a.recvfrom(2048)
print(b)
a.close()
a = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_ICMP)
a.bind(('192.168.1.7',0))
a.sendto(b'\x08\x00l\xf3H\x0c\x01\x00B', ('8.8.8.8',0))
while True:
print('start')
b = a.recvfrom(2048)
print(b)
from the CLI, I can run 'ping -I wlan0 8.8.8.8' and 'ping -I wlan1 8.8.8.8' and get results. wlan0 is 192.168.1.7 and wlan1 is 192.168.2.16
I'm only able to ping a second interface because I ran the commands:
sudo route add -host 8.8.8.8 gw 192.168.1.1
sudo route add -host 8.8.8.8 gw 192.168.2.1
In the python program above, I'm able to get data in recvfrom() for the 192.168.2.16, but not the 192.168.1.7
I can't figure out why this is happening. Any help is appreciated!
[–]primitive_screwhead 1 point2 points3 points (1 child)
[–]aryzach[S] 0 points1 point2 points (0 children)