I'm trying to find a Pythonic interface to what the ip route-style commands do on Linux, similar to how python-iptables is a nice Pythonic interface to iptables which directly calls the C library functions, rather than using subprocess to call and parse the output of running /usr/sbin/iptables. Does such a module exist?
If not, what would be the best way (preferably not involving subprocess-parsing) to do the following in Python:
- Get the machine's IP routing table
- Add a new rule to the IP routing table
- Delete a rule from the IP routing table?