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:
The Change TCP/IP Route (CHGTCPRTE) command is used to change an existing route in the Transmission Control Protocol/Internet Protocol (TCP/IP) configuration.
Use the show ip route EXEC command to display the current state of the routing table.
The /etc/iproute2/rt_tables file basically allows you to give meaningful names to the route tables. You can reference all the possible tables using just a number, but it is easier to remember and use them if you have a good name.
Did you try pyroute2
? Pyroute2 is a pure Python netlink and Linux network configuration library. It requires only Python standard modules and no other 3rd party libraries. Later it can change, but the dependency tree will remain as simple as possible.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With