Advertisement
Guest User

DHCPv6 PD Revoke Script / DenisKlimek

a guest
Aug 21st, 2019
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.97 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. RACONF="/etc/radvd.conf"
  4.  
  5. tmp=`sudo ifconfig eth1 | grep global | awk -F " " '{ print $2 }'`
  6. if [ "$tmp" ]; then
  7.     echo "Active IPv6 Prefix found"
  8.     CURRENT_INET6=${tmp::-1}
  9. fi
  10. if [ "$CURRENT_INET6" ]; then
  11.     echo $CURRENT_INET6 > ~/CURRENT_INET6
  12.     if [ -f ~/LAST_INET6 ]; then
  13.         LAST_INET6=`cat ~/LAST_INET6`
  14.         if [ "$CURRENT_INET6" != "$LAST_INET6" ]; then
  15.             sed '$d' $RACONF > /var/tmp/radvd.conf
  16.             mv /var/tmp/radvd.conf $RACONF
  17.             echo "Different IPv6 Prefix found"
  18.             echo "    prefix "$LAST_INET6"/64 {" >> $RACONF
  19.             echo "        AdvOnLink on;" >> $RACONF
  20.             echo "        AdvPreferredLifetime 0;" >> $RACONF
  21.             echo "        AdvAutonomous on;" >> $RACONF
  22.             echo "        AdvValidLifetime 0;" >> $RACONF
  23.             echo "    };" >> $RACONF
  24.             echo "};" >> $RACONF
  25.             /etc/init.d/radvd reload
  26.             echo $CURRENT_INET6 > ~/LAST_INET6
  27.         else
  28.             echo "Same prefix as before"
  29.         fi
  30.     else
  31.         echo "Copying..."
  32.         cp ~/CURRENT_INET6 ~/LAST_INET6
  33.     fi
  34. fi
  35.  
  36. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement