Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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 10.11.20.10/24 to eth0, it creates an interface route in the main table.

   ip route show
   10.11.20.0/24 dev eth1  proto kernel  scope link  src 10.11.20.10

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

2 Answers 2

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

 
discard

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.