Skip to Content [alt-c]

Comment

In reply to Beware the IPv6 DAD Race Condition

Reader Mark on 2016-09-01 at 23:21:

Here's how I tackle this using zsh without having to disable duplicate address detection:

ip -6 addr add 2001:DB8:1234:f00::2/64 dev eth0 wait_dad=0 until (( ++wait_dad > 100 )) { grep -q 2001:DB8:1234:f00::1 <(ip -6 r l table local) && no_da=1 && break sleep 0.2 } (( no_da )) && ip -6 r a 2001:DB8::/32 via 2001:DB8:1234:f00::ffff dev eth0 src 2001:DB8:1234:f00::2

The trick is; once dad detection has finished and the address is safe to use (no one uses it on the network already), the address is added to the local ipv6 route table. So, we wait max 20 seconds for it (should never be reached) and if we find the address in the local table, we can add the route.

The code should be easy enough for people who don't use zsh to read and adapt for their preferred shell.

Hope this helps others.

Reply

Post a Reply

Your comment will be public. If you would like to contact me privately, please email me. Please keep your comment on-topic, polite, and comprehensible.

(Optional; will be published)

(Optional; will not be published)

(Optional; will be published)

  • Blank lines separate paragraphs.
  • Lines starting with ">" are indented as block quotes.
  • Lines starting with two spaces are reproduced verbatim.
  • Text surrounded by *asterisks* is italicized.
  • Text surrounded by `back ticks` is monospaced.
  • URLs are turned into links.
  • Use the Preview button to check your formatting.