Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import socket
- import select
- MTU = 1168
- IPS = "ip1", "ip2"
- TARGET = "targetip", 4444
- tunnel = open("/dev/tun0", "rw")
- sockets = [socket.socket(socket.AF_INET, sock.SOCK_DGRAM) for x in IPS]
- for ip, s in zip(ips, sockets):
- s.bind((ip, 1))
- rr = []
- while True:
- r, w, _ = select.select([tunnel] + sockets, [], [])
- for fd in w:
- if fd == tunnel:
- if not rr:
- rr = list(sockets)
- rr.pop(0).sendto(TARGET, tunnel.read(MTU))
- else:
- tunnel.write(fd.recv(MTU))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement