Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there any way I can add an ip to an interface , but interface route gets created on a routing table other than 'main' routing table in linux?

For ex: If I add an IP to eth0, it creates an interface route in the main table.

   ip route show dev eth1  proto kernel  scope link  src

But I don't want this interface route to be created on 'main' table but a different routing table with table id 10. It seems 'ip addr' doesn't take table id as an option, only way I could think of is deleting the interface route from 'main' table and add it into other routing table.

share|improve this question
up vote 4 down vote accepted

The kernel is what adds the routing rules after adding an IP to the box, not the ip command. So you cannot prevent it from adding to the 'main' table. The only way to do this is to manually remove the route from 'main' and add it to your custom table.

share|improve this answer

You can refer to this link regarding Linux Advanced Routing and Traffic Control. It contains everything whatever you need: how to add a new table with a particular id and priority, how to delete a route from a "main" table and add it your new table. I think it must fulfill you needs.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.