Thanks everyone for their reply and the pointer to ifstated(8)!
For the archives; this simple configuration did the trick:
====== 8< ======
state if_up {
    init {
            run "/usr/local/sbin/dyndnsupdate.sh"
    }
    if pppoe0.link.down {
            run "/usr/bin/logger -p daemon.warn -i -t ifstated -- pppoe0 link 
is down"
            set-state if_down
    }
}

state if_down {
    if pppoe0.link.up {
            run "/usr/bin/logger -p daemon.warn -i -t ifstated -- pppoe0 link 
is up with IP: `/sbin/ifconfig pppoe0 |/usr/bin/grep -F -we inet`"
            set-state if_up
    }
}
====== 8< ======

-- 
Lévai, Dániel

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Wednesday, June 17, 2020 5:53 PM, Olivier Taïbi <[email protected]> wrote:

> I am in a similar situation (pppoe sessions restarts, although my IP addresses
> do not change), and I needed to re-add the default IPv6 route after completion
> of IPv6CP. Note that there are several layers involved (link, IPv4, IPv6), I
> would guess that for pppoe "link is up" would mean LCP succeeded, which is
> before you get a new IP. For this reason I put together a small ad-hoc tool
> that monitors the addition of a new route, which occurs just after IPv6CP
> succeeds. See
> https://marc.info/?l=openbsd-misc&m=158834859429490&w=2
> You could probably modify it to do what you need, using the monitor option of
> route(8) to guess what event you want to trigger the execution of your script.
> In fact it should be simpler.
>
> If you manage to use ifstated(8) reliably, please let me know.
>
> On Wed, Jun 17, 2020 at 01:08:30PM +0000, Lévai, Dániel wrote:
>
> > Hi misc@!
> > I'm trying to run a script whenever I get a new IP address from my ISP over 
> > pppoe0. They disconnect me occasionally and the router reconnects then, eg.:
> > /bsd: pppoe: GENERIC ERROR: RP-PPPoE: Child pppd process terminated
> > /bsd: pppoe0: received unexpected PADO
> > last message repeated 2 times
> > I have this as the last line in /etc/hostname.pppoe0:
> > !/bin/sh /etc/hostname.pppoe0.script pppoe0 0.0.0.1
> > It doesn't seem to be executed when this happens, only when I reboot the 
> > router. Is the culprit here something along the lines of not 
> > (re)configuring the interface with ifconfig up/down (in which case the 
> > script would run), instead only getting disconnected and reconnecting?
> > Daniel


Reply via email to