What's new

[RT-AC68U] Ip change automatically

  • 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!

sman

Occasional Visitor
Hi guys,

I Have RT-AC68U with Merlin version 380.66_2 on the Windows 10 and a PPPOE connection.
Now i need a way to simulate a click to WAN settings to Apply button like in attach pic.

When the button is pressed, I will get a new IP in 5-10 seconds. After if is possible, i need the new IP copied to a .txt file or to any readable format... ( i need the ip to be writed into a .cfg file, a new task)

LE: I have installated wamp, if a .php script can do that..
LE2: A batch file is perfect.

Thanks for any hints.
 

Attachments

  • apply button.png
    apply button.png
    215 KB · Views: 713
Last edited:
Hi guys,

I Have RT-AC68U with Merlin version 380.66_2 on the Windows 10 and a PPPOE connection.
Now i need a way to simulate a click to WAN settings to Apply button like in attach pic.

When the button is pressed, I will get a new IP in 5-10 seconds. After if is possible, i need the new IP copied to a .txt file or to any readable format... ( i need the ip to be writed into a .cfg file, a new task)

LE: I have installated wamp, if a .php script can do that..
LE2: A batch file is perfect.

Thanks for any hints.
The nvram variable you are looking for is wan0_ipaddr
if you type

Code:
nvram get wan0_ipaddr

or

nvram show | grep wan0_ipaddr
will return the value. There are different ways to pipe the output to a file in a script. The question is how to trigger the script to run when you press save? If you look here
https://github.com/RMerl/asuswrt-merlin/wiki/User-scripts, there is a reference to a wan-start. Most of us on the forum use it to call other scripts upon boot up. I have not tested it to see if it is called when saving this screen. But I suspect it may. You can test it by doing something like this in wan-start:
Code:
#!/bin/sh
WAN_IP=$(nvram get wan0_ipaddr)
echo $WAN_IP >> /jffs/scripts/my-wan-ip-addr
chmod 755 wan-start
Run wan start at the command line: ./wan-start
look at the content of the file using the cat /jffs/scripts/my-wan-ip-addr command. It should contain your current ip address. Then do the save on the screen. Then see if a second line got added to the file my-wan-ip-addr.

One I have not looked into is dhcp-event. Anyway, I just wanted to get you pointed in the right direction.

I have a dynamic IP assigned by my ISP. I have seen it change three times over the course of a weekend when I monitored that last year. Does your ISP do this as well? If so, you may need a script that runs very frequently to check to see the IP has been updated. For this, you will need to set up a cron job to run it.

You need to have the jffs partition enabled on the router for the above to work.
 
Last edited:
Xentrk thank you for your help.
The question is how to trigger the script to run when you press save?
That's the big "problem". How to trigger the script... If trigger only when router start then is not enought, i need to come from a batch or somthing when router is already started.

I follow the refferince and is not so detailed for a regular user.I must do it in 2 steps:

1. Trigger the script, or trigger somthing to press that button
2. Save the IP to a txt.

i need to study more about and an example are welcome
 
just hitting apply without making any changes issues the following command which you can use in a script....

service restart_wan_if 0
 
i add from putty like this:
http://prntscr.com/fdlfmw
but i have an error
Usage: service <action_service>

LE: I tryed
service restart_wan_if
and the response is "Done." But the 'button' It was not pressed, because is the same ip (after refresh the page)


LE2 : Succesfull with:
service restart_wan
Now I must find a way to run it.
 
Last edited:
You found the answer I was going to suggest :).....I forgot there is a limitation(bug?) that the service command won't process actions that require a parameter (in this case the interface id of 0)
 
i'am close, must be somthing like
plink.exe -telnet 192.168.1.1 -P 23 < commands.txt
i must try more...
 
i'am close, must be somthing like
plink.exe -telnet 192.168.1.1 -P 23 < commands.txt
i must try more...

First off I suggest you use SSH over telnet, its more secure and supports encryption and is much better all round.

Here's how to install the script once you are in a SSH or telnet session;

Code:
wget https://pastebin.com/raw/R1hf85ku -O /jffs/scripts/renewip.sh
dos2unix /jffs/scripts/renewip.sh

That will download the file to "/jffs/scripts/renewip.sh

To execute it use;

Code:
sh /jffs/scripts/renewip.sh

This will paste the new IP in your terminal and make a copy of it at "/jffs/scripts/newip.txt

To view this at a later date use;

Code:
cat /jffs/scripts/newip.txt
 
awesome script and it work (via SSH), thank you!
here is a print http://prntscr.com/fdp4uk maybe can help someone.
Btw, i saw in script
Code:
sleep 10
10 mean miliseconds or seconds? A faster retsart is better, ms is very good.

And a little update for script with a custom DDNS, my ISP offers me a dynamic DNS which is being auto updated for every WAN restart, without a password. But after a WAN restart, the newly domain is not fast assigned, sometime in 5 seconds,but other time in 2 minutes. I want the custom DDNS because after a WAN restart I have that feedback when doamin is assigned, when the yellow " !" warning disappear(Network map>Internet status). Domain is test57.go.ro

The default DDNS mydomain.asuscomm.com is easy to use but unfortunately, sometime took over 5 min to update.
 
10 mean miliseconds or seconds?
This is value is seconds, I set it to that to give WAN time to process the restart. This can be lowered I guess, I set it at a relatively safe value.

As for the DDNS, I've never really used the feature, if its triggered upon WAN restart there's not much we can do to speed it up.
 
Is not for a speed up, its for the feedback, that check when the newly doamin is asigned/valid. I will make a print when i go home, probably I didn't write clearly
 
Last edited:
Now I try to use the IP from .txt file and saving to PC. Is there a way to acces the jffs partition somthing like:
http://192.168.1.1/jffs/scripts/newip.txt

or to save to PC (media server never is off)
nvram get wan0_ipaddr > /jffs/scripts/newip.txt
to be
nvram get wan0_ipaddr > 192.168.1.3/sharedfolder/newip.txt
or to local ftp server.
 
Last edited:
already I have a webserver (wamp) and a ftp server (filezila). now I will do like you said

LE: I miss somthing http://prntscr.com/fdso1t



You are right about the downside, and I can't login to interface all the time.
I must find another option, mby a ftp?
 
Last edited:
I must find another option, mby a ftp?
I'd suggest SCP, but it depends on what you want to do with the file. There are many different ways, choose what is most appropriate for what you are trying to do.
 
Idk howto use the SCP, probably can be exported with a similar command for nvram?
nvram get wan0_ipaddr > SCP code code ?
Practically i can see the IP in putty command line, but for me it's hard to get him out, in my pc or anywhere, preferably to work only with putty.
 
PuTTY has an SCP client if that helps you?

Code:
C:\Program Files\PuTTY>pscp -scp -pw XXXXX admin@RT-AC68U:/jffs/syslog.log D:\myfile
myfile                    | 172 kB | 172.8 kB/s | ETA: 00:00:00 | 100%
 
Thank you Colin, now I get it and i'll try.
LE: pscp -scp -pw xxxxx admin@192.168.1.1:/jffs/scripts/newip.txt D:\myfile
work ! thank you


@Adamm,
Im home and here are the print for mydomain.asuscomm.com http://prntscr.com/fdzky4 where i have a feedback and I know when the domain are registred (assigned)
But for the custom DDNS i don't have a script and feedback, is not registred when I set the domain to test57.go.ro http://prntscr.com/fdznnr
There must be a way to fix it via script
 
Last edited:

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