Manually configure ipv6 address in 2 different subnets

ipv6

I have a following setup

 Linux1---------------Linux2------------------Linux3
(eth0)            (eth1)     (eth0)           (eth0)

I have this in a local network i.e the Ethernet cables are connected directly.I am configuring the IPV6 address for the first time.
I want Linux1(eth0) and Linux2(eth1) to be in one ipv6 subnet and Linux2(eth0) and Linux3(eth0) in a different ipv6 subnet.

After going through this link http://techxcellence.net/2011/05/09/v6-subnetting-made-easy/
i chose the following

For Linux3 eth0

   ifconfig eth0 add 2002:db8:c001:ba40::/58

For Linux 2 eth0

   ifconfig eth0 add 2001:db8:c001:ba40::/58

I am not sure if this is correct. the intention is to have 2 different ipv6 addresses in the same ipv6 subnet. I am guessing we can change any bit in the prefix.

Is my understanding correct?

The ipv6 address in the other subnet would be

2002:db8:c001:ba00::/58 and 2001:db8:c001:ba00::/58?

Best Answer

When subnetting you define a fixed start of the address prefix. You then give addresses within that prefix (so with the same start) to your devices. So you don't use 2001:… and 2002:…, but you use e.g. 2001:db8:c001:ba40::1 and 2001:db8:c001:ba40::2.

Subnets in IPv6 are always a /64. (well, there are cases like point-to-point and loopback interfaces where you might want to use something else, but let's keep it simple for now) That means that the first 64 bits of the address are fixed and the remaining bits (128 - 64 = 64) are available to number your devices with.

The addresses you use (from 2001:db8::/32) are only for documentation purposes. To determine which addresses you can use you ask your ISP (if your ISP provides IPv6) or you generate a ULA prefix (private addresses, not usable on the internet). Sites such as SixXS provide a ULA generator that you can use.

You usually get a /48 prefix. For example my home network has 2a00:8640:1::/48. That means that I can use 2a00:8640:1:0000::/64 to 2a00:8640:1:ffff::/64 to number my subnets. When building a network such as described in your example I could do something like:

  • Linux1 eth0: 2a00:8640:1:a::1/64
  • Linux2 eth1: 2a00:8640:1:a::2/64
  • Linux2 eth0: 2a00:8640:1:b::1/64
  • Linux3 eth0: 2a00:8640:1:b::2/64

You can do the same with your own IPv6 addresses.

Related Question