JuliandotNut
JuliandotNut

Reputation: 1219

Modifying Linux kernel routing table programmatically

While browing through /proc, I am across /proc/net/fib_trie which seems to have main routing table of kernel inside it. My question is if modifying it will change the routing table or it is a stat only file?

(I want to modify routing table programmatically and I am total noob in C so looking for other options. File modification will be easy in any language)

In another question, MattSmith mentioned in a comment that modifying the file /proc/net/route and using ioctls is a solution, Can someone please guide me how?

Upvotes: 0

Views: 2422

Answers (1)

Jurasic
Jurasic

Reputation: 1956

My question is if modifying it will change the routing table or it is a stat only file?

No, route table won't change as file is read-only.

In another question, MattSmith mentioned in a comment that modifying the file /proc/net/route and using ioctls is a solution, Can someone please guide me how?

From user space perspective you can use netlink sockets to manage routing table. See some C example. However, it would be difficult for newcomer.

So the easiest way is to use ip utility(in fact it uses netlink sockets). That way, you can implement your own shell script and execute routing manipulations within it. You can search for proper usage of ip tool.

Upvotes: 2

Related Questions