What's new

Question About DHCPC events.

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

SomeWhereOverTheRainBow

Part of the Furniture
Okay SO I have setup dhcpc.event to run on
Code:
"start")
    
    ;;
"bound")
    
    ;;
"renew")
    
    ;;
"deconfig")
    
    ;;
"internal")
    
    ;;
are there any other events I should be concerned about in regards to dhcpc.event ? if not, here is my dilemma. I have setup a custom addressing for IPV6 using IP -6 addr add, but the address mysteriously vanished after a short period within a day. Is there a better place (or event script) I should be placing this ip addr directive at so I do not lose the added address?
 
I assume these additions are for the WAN given your interest in the dhcpc event. But is it really the dhcpc event that's relevant, or just anytime the WAN is reinitialized (whatever the cause and resulting actions the router takes)? My own inclination would be to use the wan-event script, unless I specifically wanted to know what dhcp event triggered a change. It's just not obvious based on what you've presented so far that the specific dhcp event matters.
 
I assume these additions are for the WAN given your interest in the dhcpc event. But is it really the dhcpc event that's relevant, or just anytime the WAN is reinitialized (whatever the cause and resulting actions the router takes)? My own inclination would be to use the wan-event script, unless I specifically wanted to know what dhcp event triggered a change. It's just not obvious based on what you've presented so far that the specific dhcp event matters.

So to pass any argument for each event, I am assuming i would change it to ?

Code:
"0 init")

;;
"0 connecting")

;;
"0 connected")

;;
"0 disconnected)

;;
"0 stopped")

;;
"0 disabled")

;;
"0 stopping")

;;
.....

for wan-event?

or would it be all one word like

wan0-init
 
That would work assuming the case statement was trapping on "$1 $2".
Sorry for bothering for your expert opinion, but would I only be concerned with connected? what would you think?

Code:
#!/bin/sh

_noaddress(){
        /usr/sbin/ip -6 addr add fd35:xxxx:xxxx::1/64 dev br0
        logger -st "($(basename "$0"))" "ULA IPv6 Address not found.. Adding"
}
_addressfound(){
        logger -st "($(basename "$0"))" "ULA IPv6 Address found.. Skipping"
}

case "$1 $2" in
"0 connected")
    continue
    ;;
*)
    exit 1
    ;;
esac

logger -st "($(basename "$0"))" "Triggering: WAN Event / Status Change"
/usr/sbin/ip -6 addr show dev br0 | /bin/grep -q "xxxx:xxxx" && _addressfound || _noaddress

This is what I came up with. Ideally I believe the only connection events truely worth hooking into are connected and init, but for this instance I think I only need to be concerned with connected.
 
So it appears after running

service restart_wan

numerous times, it seems it still fails to retain the address at a certain point. it seems to lose the addition. would dhcp6s.postconf be the best place to add this route then?
 
Last edited:
I'm not sure why you want to keep returning to the dhcp event. Frankly, it's not obvious to me even the WAN event is relevant if you're adding an IPv6 address to the *private* network (br0)! It's certainly not intuitive. Something else seems to be going on. I don't use IPv6 myself, but when multihoming IPv4 to the private network in the past, I don't recall it being lost for any reason once the private network was established. Or is this a case of mistakenly referencing br0 when it should be the WAN's network interface?
 
I'm not sure why you want to keep returning to the dhcp event. Frankly, it's not obvious to me even the WAN event is relevant if you're adding an IPv6 address to the *private* network (br0)! It's certainly not intuitive. Something else seems to be going on. I don't use IPv6 myself, but when multihoming IPv4 to the private network in the past, I don't recall it being lost for any reason once the private network was established. Or is this a case of mistakenly referencing br0 when it should be the WAN's network interface?
I am assuming it is the logic in the last line, which sometimes adds and sometimes doesn't. I have added alittle more logic to it and it is working perfectly. The problem is that there seems to be a possibility it detects an address when one isn't present.

I encapsulated the argument in a -n check

Code:
[ -n "$(/usr/sbin/ip -6 addr show dev br0 | /bin/grep -q "xxxx:xxxx")" ] && _addressfound || _noaddress
 
Last edited:
I'm not sure why you want to keep returning to the dhcp event. Frankly, it's not obvious to me even the WAN event is relevant if you're adding an IPv6 address to the *private* network (br0)! It's certainly not intuitive. Something else seems to be going on. I don't use IPv6 myself, but when multihoming IPv4 to the private network in the past, I don't recall it being lost for any reason once the private network was established. Or is this a case of mistakenly referencing br0 when it should be the WAN's network interface?
Though the issue was not intuitive at first. Your help was undoubtedly invaluable as it led me to the answer.
 

Similar threads

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top