diff --git a/.gitignore b/.gitignore index c674098..134f3a4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +*/venv + # ---> Linux *~ diff --git a/netst b/netst new file mode 100755 index 0000000..07d7d6a --- /dev/null +++ b/netst @@ -0,0 +1,6 @@ +#!/bin/bash +# +BASEDIR=$(dirname $0) + +$BASEDIR/netst.src/venv/bin/python $BASEDIR/netst.src/netst.py $* + diff --git a/netst.src/netst.py b/netst.src/netst.py new file mode 100644 index 0000000..6d2c923 --- /dev/null +++ b/netst.src/netst.py @@ -0,0 +1,60 @@ +import dns.resolver +import ifcfg +import json +import socket +import struct +import sys +import time + +def gateway(device): + with open("/proc/net/route") as fh: + # skip header + next(fh) + for line in fh: + routes = line.strip().split() + if routes[0] == device: + destination = socket.inet_ntoa(struct.pack("