NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: bin/53655: ifwatchd(8) should handle IPv6 "deprecated" interface flags



On Mon, 8 Oct 2018 13:34:56 +0200
Joerg Sonnenberger <joerg%bec.de@localhost> wrote:

> On Mon, Oct 08, 2018 at 01:50:01AM +0000, clare%csel.org@localhost wrote:
> >  >  > 	in Japan, LTE based ISPs does not provide fixed IPv6 prefix for
> >  >  > 	general consumers.  power-cycling of LTE routers are result in
> >  >  > 	changed (upstream) IPv6 prefix.
> >  >  
> >  >  Why don't you use dhcpcd for that?
> >  
> >  dhcpcd itself is already used for accepting dynamic RAs.
> >  Should I hook dhcpcd directry?
> 
> It provides you a message for new prefix delegations at least, so I
> would expect that you can script the rest from that.
> 
> Joerg

I wrote following script for my tunnel router.


$ cat /libexec/dhcpcd-hooks/90-racoon
#!/bin/sh
logger "XXX reason=$reason"
logger "XXX interface=$interface"
if [ $reason != "ROUTERADVERT" ]; then
  exit 0
fi

rm -f /tmp/.newaddr
rm -f /tmp/.curaddr

# search newly bound address
ifconfig vlan30 | {
  while read proto ifaddr flags code; do
    if [ "$proto" != "inet6" ]; then
      continue
    fi
    if [ "$flags" != "flags" ]; then
      continue
    fi
    if [ "$code" != "0x0" ]; then
      continue
    fi
    newaddr=`echo "$ifaddr" | sed -e s,/64,,g`
    echo "$newaddr" > /tmp/.newaddr
    logger "XXX address=$newaddr"
  done
}

# search tunnel address
ifconfig ipsec0 | {
  while read tunnel proto myaddr arrow hisaddr; do
    if [ "$tunnel" != tunnel ]; then
      continue
    fi
    if [ "$proto" != inet6 ]; then
      continue
    fi
    echo "$myaddr" > /tmp/.curaddr
  done
}

curaddr=`cat /tmp/.curaddr`
newaddr=`cat /tmp/.newaddr`

if [ -z "$newaddr" ]; then
  exit 0
fi

if [ "$newaddr" != "$curaddr" ]; then
  logger "XXX we need update tunnels"
else
  logger "XXX we can keep tunnels"
  exit 0
fi

/sbin/ifconfig ipsec0 tunnel "$newaddr" 2400:8500:1302:823::DEAD:BEEF
/sbin/ifconfig ipsec0 up
/sbin/ifconfig ipsec1 tunnel "$newaddr" 2400:8500:1302:829::DEAD:BEEF
/sbin/ifconfig ipsec1 up
/sbin/ifconfig ipsec2 tunnel "$newaddr" 2400:8500:1302:825::DEAD:BEEF
/sbin/ifconfig ipsec2 up
service racoon restart


-- 
Shinichi Doyashiki <clare%csel.org@localhost>


Home | Main Index | Thread Index | Old Index