Community discussions

MikroTik App
 
cflee
just joined
Topic Author
Posts: 6
Joined: Fri May 30, 2014 4:48 am

dhcp-client stuck in rebinding state when moved to new network

Tue May 12, 2015 1:26 pm

Device: RB750
OS: v6.27

I'm having some issues with dhcp-client being stuck in "rebinding" state when the interface is moved to a new network.

After turning on logging for dhcp,debug I can see that the following happens:
  • link down (disconnect from old network)
  • link up (connect to new network)
  • dhcp-client entering "renewing..." state, dhcp-client sending request to original DHCP server
  • after 2 sec, dhcp-client sending request to original DHCP server
  • after 2 sec, dhcp-client entering "rebinding..." state, dhcp-client sending request to 255.255.255.255
  • after 2 sec, dhcp-client sending request to 255.255.255.255
Nothing happens after that, old IP address is used.

All that is correct because no DHCPNAK is received, so the client still uses the existing lease until it expires. However, because it's a new network and new address range, I either have to reboot or explicitly release the dhcp-client to get the interface unstuck.

Is there some workaround for this? Using scripting or otherwise? I am looking for a way to either (i) release dhcp-client immediately on link-down, or (ii) release after x seconds and still in "rebinding" state on link-up.
 
cflee
just joined
Topic Author
Posts: 6
Joined: Fri May 30, 2014 4:48 am

Re: dhcp-client stuck in rebinding state when moved to new network

Fri May 22, 2015 8:46 am

Answering my own question.

It is possible to add a script to scheduler that runs every 2 min that will check if the dhcp-client is stuck in rebinding state, and if internet connectivity is down. In that case, explicitly release the lease, so that the dhcp-client will obtain a fresh lease (instead of trying to renew existing lease).
# kick the dhcp-client if wan network changes and we need
# a new lease, but can't get it as we don't release current lease
# and no NAK received from dhcp server on network.
# 
# we do this only when the dhcp-client status is "rebinding..."
# and also no connectivity is found
#
# interface name of wan port with dhcp-client on
:local wan "ether1-gateway"
:if ( [ /ip dhcp-client get [ find interface=$wan ] status ] = "rebinding..." \
        && [/ping 8.8.8.8 interface=ether1-gateway count=6 ] = 0 ) do={ 
    /ip dhcp-client release [ find interface=$wan ] 
}
Put this inside a script in /system script, and then use /system scheduler to add the name of the script in the on-event parameter.

What I don't understand is what the policy field in script and scheduler means..
 
jo2jo
Forum Veteran
Forum Veteran
Posts: 980
Joined: Fri May 26, 2006 1:25 am

Re: dhcp-client stuck in rebinding state when moved to new network

Tue Sep 26, 2017 10:30 pm

Even as of rOS 6.40.3, Im still seeing this rebinding issue on various types of dhcp-servers (ie various types of devices that a rOS device is connected to as a dhcp-client).

For example (in one configuration), if i power cycle a cable modem, in rOS the dhcp-client will go to rebinding as soon as the eth link drops and then comes back 2 or 3s later (as the modem is booting up), however even once the modem has booted up, dhcp-client still shows rebinding.. (and is stuck on the public IP address that was provided before the power cycle). If at any point i disable and re-enable the rOS dhcp-client, it works as it should (ie it will then grab a 192.168.100.x/24 IP w 20s lease time, until the modem has sync'd up, once the dhcp-client lease expires, it will properly re-new and grab the public IP)

The issue is mainly/mostly during ETH down and UP situations.

Although less frequently, i have seen rOS dhcp-client stuck at rebinding when a standard, long lease (ie 1 or 3 days) has expired, too.

I know they are ways to script / scheduler around this, but this bug/issue shouldn't be an issue in the first place,

i dont recall ever seeing these issues in early 6.x or pre 6.x rOS.

tks
:beep :beep :beep
 
cflee
just joined
Topic Author
Posts: 6
Joined: Fri May 30, 2014 4:48 am

Re: dhcp-client stuck in rebinding state when moved to new network

Wed Sep 27, 2017 9:28 am

I know they are ways to script / scheduler around this, but this bug/issue shouldn't be an issue in the first place,

i dont recall ever seeing these issues in early 6.x or pre 6.x rOS.
I haven't tested this lately, so thank you for the update! Fully agreed that this bug shouldn't be present in the first place; it's not a very safe assumption that the ethernet links are always up.
 
User avatar
floeff
newbie
Posts: 41
Joined: Sat Jan 28, 2017 6:39 pm
Location: Germany
Contact:

Re: dhcp-client stuck in rebinding state when moved to new network

Mon Jul 15, 2019 7:29 pm

I can confirm this problem even with recent RouterOS 6.44.5, with a Sagemcom DOCSIS 3.0 modem.
When the connectivity is gone temporarily due to cable operator outage, I need to explicitly release both IPv4 and IPv6 DHCP to get back connectivity.

I'm currently playing with two scripts that could fix the problem, but I did not yet put them into production, it's just "wild thinking". One option is to check for actual connectivity, and release DHCP in case the ping is unsuccessful:
:if ([/ping 8.8.8.8 interface=ether1 count=6]=0 && [/ping 1.1.1.1 interface=ether1 count=6]=0) do={/ip dhcp-client release [find interface=ether1]; /ip cloud force-update; :log info "forced DHCP IPv4 renew due to loss of connectivity"}
:if ([/ping 2001:4860:4860::8888 interface=ether1 count=6]=0 && [/ping 2606:4700:4700::1111 interface=ether1 count=6]=0) do={/ipv6 dhcp-client release [find interface=ether1]; /ip cloud force-update; :log info "forced DHCP IPv6 renew due to loss of connectivity"}

The alternative is to scan for the DHCP status, but I'm not sure if during a valid renewal the state is also "bound":
:foreach i in=[/ip dhcp-client find where interface=ether1 status!=bound disabled=no] do={/ip dhcp-client release $i; /ip cloud force-update; :log info "forced DHCP IPv4 renew due to loss of connectivity"}
:foreach i in=[/ipv6 dhcp-client find where interface=ether1 status!=bound disabled=no] do={/ipv6 dhcp-client release $i; /ip cloud force-update; :log info "forced DHCP IPv6 renew due to loss of connectivity"}

It should be possible to run either of these code snippets via the scheduler, e.g.
/system script add name=conncheck policy=read,write,test source={ ...code from above... }
/system scheduler add name=conncheck interval=5m on-event=conncheck

Take them with a grain of salt - they are untested, I'm right now looking into how to deploy this best! :)
 
rtolivia
just joined
Posts: 3
Joined: Fri Nov 02, 2018 11:32 pm

Re: dhcp-client stuck in rebinding state when moved to new network

Fri Jan 17, 2020 6:11 am

I can confirm this problem even with recent RouterOS 6.44.5, with a Sagemcom DOCSIS 3.0 modem.
When the connectivity is gone temporarily due to cable operator outage, I need to explicitly release both IPv4 and IPv6 DHCP to get back connectivity.

I'm currently playing with two scripts that could fix the problem, but I did not yet put them into production, it's just "wild thinking". One option is to check for actual connectivity, and release DHCP in case the ping is unsuccessful:
:if ([/ping 8.8.8.8 interface=ether1 count=6]=0 && [/ping 1.1.1.1 interface=ether1 count=6]=0) do={/ip dhcp-client release [find interface=ether1]; /ip cloud force-update; :log info "forced DHCP IPv4 renew due to loss of connectivity"}
:if ([/ping 2001:4860:4860::8888 interface=ether1 count=6]=0 && [/ping 2606:4700:4700::1111 interface=ether1 count=6]=0) do={/ipv6 dhcp-client release [find interface=ether1]; /ip cloud force-update; :log info "forced DHCP IPv6 renew due to loss of connectivity"}

The alternative is to scan for the DHCP status, but I'm not sure if during a valid renewal the state is also "bound":
:foreach i in=[/ip dhcp-client find where interface=ether1 status!=bound disabled=no] do={/ip dhcp-client release $i; /ip cloud force-update; :log info "forced DHCP IPv4 renew due to loss of connectivity"}
:foreach i in=[/ipv6 dhcp-client find where interface=ether1 status!=bound disabled=no] do={/ipv6 dhcp-client release $i; /ip cloud force-update; :log info "forced DHCP IPv6 renew due to loss of connectivity"}

It should be possible to run either of these code snippets via the scheduler, e.g.
/system script add name=conncheck policy=read,write,test source={ ...code from above... }
/system scheduler add name=conncheck interval=5m on-event=conncheck

Take them with a grain of salt - they are untested, I'm right now looking into how to deploy this best! :)
I do confirm this behavior, same cablemodem but dhcp-client shows status "renewing..." Same sometimes in "bound" state. For bound if no ping i directly disable and enable the interface and for
if "renewing" too.
 
nunodaniel
just joined
Posts: 1
Joined: Mon Feb 19, 2018 4:29 pm

Re: dhcp-client stuck in rebinding state when moved to new network

Sun Jan 10, 2021 9:59 pm

Same issue here.
News about that situation? Some fix or workaround provided by MikroTik?

MikroTik RouterBOARD 3011UiAS
OS / Firmware: 6.48

Thanks.

Who is online

Users browsing this forum: Bing [Bot], erkexzcx and 173 guests