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.

I know I can add several IP addresses to an interface without using interface aliases (ex.: eth0:0).

My question: but how can I create different routing decisions for the different IP addresses on one interface? Can someone provide a small example for this?

UPDATE: IP addresses that I got:

$ ip -6 addr show
31: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qlen 1000
    inet6 2001:XXXX::16:3eff:fe76:13c6/64 scope global dynamic
       valid_lft 85692sec preferred_lft 13692sec
    inet6 2001:XXXX::XXXX:XXXX/64 scope global
       valid_lft forever preferred_lft forever
    inet6 fe80::216:3eff:fe76:13c6/64 scope link
       valid_lft forever preferred_lft forever

So I got a static IP (2001:XXXX::XXXX:XXXX/64) and a dinamically assigned (2001:XXXX::16:3eff:fe76:13c6/64). The routing:

$ ip -6 route
2001:XXXX::/64 dev eth0  proto kernel  metric 256
fe80::/64 dev eth0  proto kernel  metric 256
default via fe80::XXXX:XXff:feXX:XXXX dev eth0  proto ra  metric 1024  expires 423sec

Outside the host I tried to ping the dinamic IP. I got ping replies. I tried to ping the static IP, I didn't got replies.

ps.: "default via fe80::XXXX:XXff:feXX:XXXX" -> the "fe80::XXXX:XXff:feXX:XXXX" is the IP address of the IPv6 router.

share|improve this question
    
Do you mean you want to set different source IP addresses for outbound packets, depending on the destination address/network? –  Mikel Jan 23 at 18:29
    
Without understanding your exact use case, I can't give an example, but a good starting point would be Linux Advanced Routing HOWTO and possibly also the ip-rule man page. –  Mikel Jan 23 at 18:31
    
Well, when it already has been decided on which interface the packet will leave the machine, than what other routing decision do you want to influence? –  Martin von Wittich Jan 23 at 18:37
add comment

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.