Advertisement
Guest User

Untitled

a guest
Jul 24th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. YETI_DEVICE=eth1
  4. YETI_SERVICE=2001:4b98:dc2:45:216:3eff:fe4b:8c5b
  5. YETI_TABLE=Yeti-DNS
  6. USE_RDISC6=yes
  7.  
  8. # Apparently not always done automatically
  9. ifconfig ${YETI_DEVICE} up
  10.  
  11. if [ "${USE_RDISC6}" = "yes" ]; then
  12. sleep 30
  13. ROUTER=$(rdisc6 --single ${YETI_DEVICE} | awk '/^ from/ {print $2}')
  14. else
  15. # Does not work, ip -6 neigh returns other machines which are not routers
  16. #ROUTER=$(ping6 -c1 -I ${YETI_DEVICE} ff02::1 > /dev/null; ip -6 neigh | awk "/dev ${YETI_DEVICE}.*router REACHABL
  17. E/ {print \$1}" | tail -n 1)
  18. sysctl -w net.ipv6.conf.eth1.accept_ra_defrtr=1
  19. ROUTER=$(ping6 -c1 -I ${YETI_DEVICE} ff02::1 > /dev/null; ip -6 route | awk "/^default.*dev ${YETI_DEVICE}.*proto r
  20. a/ {print \$3}" | tail -n 1)
  21. fi
  22.  
  23. if [ -z "${ROUTER}" ]; then
  24. echo "Cannot find IPv6 router on ${YETI_DEVICE}"
  25. exit 1
  26. fi
  27.  
  28. if [ "${USE_RDISC6}" != "yes" ]; then
  29. sysctl -w net.ipv6.conf.eth1.accept_ra_defrtr=0
  30. fi
  31.  
  32. echo 200 ${YETI_TABLE} >> /etc/iproute2/rt_tables
  33. ip -6 rule add from ${YETI_SERVICE} table ${YETI_TABLE}
  34. ip -6 route add default via ${ROUTER} dev ${YETI_DEVICE} table ${YETI_TABLE}
  35. ip -6 route flush cache
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement