View previous topic :: View next topic |
Author |
Message |
firespace n00b
Joined: 13 Dec 2014 Posts: 1
|
Posted: Sat Dec 13, 2014 6:35 am Post subject: Drop dhcpcd lease before connecting |
|
|
I have a peculiar problem with my USB-modem. When modem is shut off, it forgets about all DHCP leases and it resets every time one tries to rebind a DHCP lease a modem knows nothing about, so if my modem gets disconnected due to a bad USB cable, I can no longer connect until I remove /var/lib/dhcp/*.lease. The problem is I don't know how to delete it automatically. I have already tried digging into configuration files, but to no avail.
Is there any way to make dhcpcd forget about a lease right after a link goes down or when a USB-modem goes up? |
|
Back to top |
|
|
khayyam Watchman
Joined: 07 Jun 2012 Posts: 6227 Location: Room 101
|
Posted: Sat Dec 13, 2014 11:16 am Post subject: Re: Drop dhcpcd lease before connecting |
|
|
firespace wrote: | Is there any way to make dhcpcd forget about a lease right after a link goes down or when a USB-modem goes up? |
firespace ... are you using netifrc to manage the interface? If so you can do something like the following:
/etc/conf.d/net
Code: | preup() {
[ -f "/var/lib/dhcpcd/dhcpcd-${IFACE}.lease" ] && {
rm -f /var/lib/dhcpcd/dhcpcd-${IFACE}.lease
}
return 0
} |
HTH & best ... khay |
|
Back to top |
|
|
lost+found Guru
Joined: 15 Nov 2004 Posts: 509 Location: North~Sea~Coa~s~~t~~~
|
Posted: Sat Dec 13, 2014 11:49 am Post subject: |
|
|
Welcome to the forums!
Another way is to use /etc/dhcpcd.enter-hook (See `dhcpcd-run-hooks' manual), and execute commands on dhcp events. Even a firewall script can be (re)run here.
Code: | case "${reason}" in
#BOUND|INFORM|REBIND|REBOOT|TIMEOUT|STATIC)
# /root/scripts/firewall.sh &>/dev/null
# ;;
PREINIT|NOCARRIER)
rm -f /var/lib/dhcpcd/dhcpcd-eth0.lease
;;
esac |
|
|
Back to top |
|
|
UberLord Retired Dev
Joined: 18 Sep 2003 Posts: 6835 Location: Blighty
|
|
Back to top |
|
|
|