Wednesday, May 11, 2011

Interface configuration

I am learning IPv6, both for work and because it's the future, so I may as well get a head start on it.  To this end, I've built a linux router at home where I have an IPv6 link from my ISP configured.  Thats great - it seems to work.  But as a habit from work, you don't bind your services to the machines main IP - if you have IPs to spare (which you certainly do with IPv6) you bind each service to its own IP address, so that you can move services around without having to change the IP of the individual box.

With IPv4, you can define a subinterface/alias (ie: eth0:1) and attach various addresses to that. But with IPv6 you cannot do that any longer.

To add a extra / mulitple IPv6 IPs to your Linux (SLES/Ubuntu/Redhat/etc) box, you can use the "ip" command (you can do the same with ifconfig, but ifconfig is deprecated, so you shouldn't use that).

Example:

 ip -6 addr add 2607:f2c0:dead:beef::1 dev eth0

this will add that IP to eth0.

However, IPv6 addresses can get a little confusing to read and type out correctly, so during the course of trying this, I ran into this error

ip -6 addr add 2607:f2c0:dead:beef:1/64 dev eth0
Error: an inet prefix is expected rather than "2607:f2c0:dead:beef:1/64"


Trying to get this sorted out took a while - there are lot of hits for that error, but none explain what the heck that means.


I figured out what it means in this case - the "ip" command is looking for a properly formatted IP Address, which the command contains.  It took me a while to realize, but I'd typed out the address incorrectly - I wanted "2607:f2c0:dead:beef::1/64" not "2607:f2c0:dead:beef:1/64"


So if you see the "Error: an inet prefix is expected rather than ..." error, it means you've incorrectly formatted your IP address.  Make sure your "/" notation is correct, that you've got your colons in the right spot, that you're not using bad letters, etc.


*edit* (adding links)


http://techblog.roethof.net/ubuntudebian-and-multiple-ipv6-addresses/
http://en.wikipedia.org/wiki/IPv6_address#Special_addresses

No comments:

Post a Comment