Modify

Opened 10 years ago

Closed 10 years ago

#3022 closed defect (fixed)

udhcpc: default.script creates large /var/state/network

Reported by: iqt Owned by: developers
Priority: normal Milestone:
Component: packages Version:
Keywords: dns udhcpc Cc:

Description

Everytime the ISP renews the ip (event renew or bound for udhcpc) hotplug event is called although nothing has changed.

Attached my solution: Make changes to the configuration only if ip, router or dns have changed.

I use the following code to enable static dns (e.g. OpenDNS). The uci rules have not been updated (I don't know awk)

config_get static_dns $iface dns
[ -n "$static_dns" ] && dns="$static_dns"

Last trivial change: Pass the event to the user-script

Attachments (2)

default.script (2.2 KB) - added by iqt 10 years ago.
/usr/share/udhcpc/default.script
default.script_diff (3.0 KB) - added by pedrofaustino 10 years ago.
If a modification is to be done to the trunk's default.script (new UCI), this should be it

Download all attachments as: .zip

Change History (10)

Changed 10 years ago by iqt

/usr/share/udhcpc/default.script

comment:1 Changed 10 years ago by anonymous

I suggest also adding

config_get static_dnsdomain $iface dnsdomain
[ -n "$static_dnsdomain" ] && domain="$static_dnsdomain"

to override the DNS search domain set by the DHCP server. Perhaps though this should also permit the user to set a *blank* dnsdomain in the config to have no search domain? Is there a way to check whether a config is set to blank?

comment:2 Changed 10 years ago by anonymous

Sorry, last code snippet was improperly linebroken:

config_get static_dnsdomain $iface dnsdomain 
[ -n "$static_dnsdomain" ] && domain="$static_dnsdomain"

comment:3 Changed 10 years ago by pedrofaustino

Thank you for sharing your modification.
Nevertheless when using your script my wan interface doesn't get an ip address when booting (so a bond request, not a renew).

Have you had this issue?

comment:4 Changed 10 years ago by anonymous

teste

comment:5 Changed 10 years ago by anonymous

teste

comment:6 Changed 10 years ago by pedrofaustino

I've modified your script in order to work upon boot (deconfig event) and upon renew/bond events.

Here's the diff:

42c42
<               ifconfig $iface 0.0.0.0
---
>               ifconfig $interface 0.0.0.0
48c48
<               [ `config_get "$iface" ipaddr` != "$ip" ] && {
---
>               [ "`config_get "$iface" ipaddr`" != "$ip" ] && {
57c57
<               [ `config_get "$iface" router` != "$router" ] && [ -n "$router" ] && {
---
>               [ "`config_get "$iface" gateway`" != "$router" ] && [ -n "$router" ] && {
74c74
<               [ `config_get "$iface" dns` != "$dns" ] && [ -n "$dns" ] && {
---
>               [ "`config_get "$iface" dns`" != "$dns" ] && [ -n "$dns" ] && {

comment:7 Changed 10 years ago by thither

I just wanted to report that iqt's script, plus pedrofaustino's modifications above, have fixed a situation I had where udhcpd was constantly renewing my WAN IP address from my ISP (and bringing down the WAN address for a good 30 seconds or so to do it). My ISP also uses a very short lease time. I recommend that the patch + modifications be committed to the trunk for the next release, unless someone can see a problem with them.

(A thread on the forum has a few more details about this behavior.)

Changed 10 years ago by pedrofaustino

If a modification is to be done to the trunk's default.script (new UCI), this should be it

comment:8 Changed 10 years ago by nbd

  • Resolution set to fixed
  • Status changed from new to closed

uci now no longer stores updates if the new value is equal to the old one

Add Comment

Modify Ticket

Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.