[Solved] How to refresh Internet connection if assigned private IP


I am connecting to my internet provider through PPPoE connection

provider assigns me IP dynamically

but provider sometimes assigns private IP (10.x.x.x) instead of public
(I mean that my provider assigns randomly private or public IP)
here is my question

how can I configure openwrt to renew connection automatically if private IP is assigned ??

I am using OpenWrt 19.07

thanks in advance

1 Like

renew != new-ip... time for a new provider

thank you for answer

but I am no so good in openwrt

can you give me more detiled answer? :slight_smile:

I mean after connection established provider assigned me IP
openwrt checks that IP
if IP is private
openwrt closes connection (or reboots openwrt)
waits few minutes connects to provider again
until public IP is not assigned by provider

As I understand better way to do it is write some script in /etc/ppp/ip-up

I think it is better to talk with your provider first. Explain them your situation and see what they have to say.
What if they don't allocate you a public IP for a long time?

no provider will do nothing
and I can not change provider

no mostly you should refresh connection max 3-4 times to get public ip

70% cases 1 time is enough

Yeah, that's right, you'd need something like

ip a show $IFACE | grep -q 'inet 10\.' && do-something-to-restart-this-interface

in if-up.d or as you mention something similar in /etc/ppp/ip-up if that's getting called on your system.

other forum user tried to help me with this generic linux script

but most important for me is do-something-to-restart-this-interface
so what I can write in /etc/ppp/ip-up to restart(reinitialize) that pppoe connection to get new IP

also man pppd says


A program or script that is executed when the link is available for sending and receiving IP packets (that is, IPCP has come up). It is executed with six command-line arguments: interface-name tty-device speed local-IP-address remote-IP-address ipparam.

I assume assigned IP address should be $4 (local-IP-address)

case ${WAN_ADDR} in
(10.*|172.1[6-9].*|172.2[0-9].*|172.3[0-1].*|192.168.*) ;;
(*) exit 0 ;;

Great to see you back :slight_smile:
Excellent work as always!


thank you. I will try and write feedback how it works

for me it will take time to understand script :slight_smile: (I want not only copy paste, but understand to make some changes in script when I need)


as I understood these are variables defined by you

but from where are this ones ??
is that from here ?? https://openwrt.org/docs/guide-user/base-system/hotplug

currently I read book The Linux Command Line W. Shotts
what you think this will help me to understand what is going on on this script??

1 Like

Using the network function library, we dynamically fetch network parameters from the runtime configuration, and with hotplug we catch the moment when the WAN interface becomes ready.


but script you wrote it is for /etc/ppp/ip-up ??

maybe it was obvious
and this is stupid question :slight_smile:

PPP-related scripts operate at a lower level than network hotplug scripts.
I'm not really familiar with the former and I'm not sure if a single PPP session is enough to assign the required address, so the first line of the script saves it to the /etc/hotplug.d/iface/10-fix-wan-ip.


I am testing this script 12 hours already

restarted router few times

only got real IPs

thank you :slight_smile:

1 Like

If your problem is solved, please consider marking this topic as [Solved]. See How to mark a topic as [Solved] for a short how-to.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.