Posted: Thu Mar 17, 2011 20:44 Post subject: How to get and recognise MAC via telnet/SSH?
Hi. I would like to change my WAN IP. I have cable modem, which gives me 3 public adresses. The only way how to get a new one is change MAC of the router, b/c the modem remembers MAC-IP. But I can not use ramdom MAC, b/c it also remembers only 3 last MACs.
So, I have to change between only 3 MACs.
For example: xx:xx:xx:xx:xx:27 ; xx:xx:xx:xx:xx:28 ; xx:xx:xx:xx:xx:29
The thing I would like to do is:
Code:
If "getwanMAC"=xx:xx:xx:xx:xx:27
Than
nvram set def_hwaddr=xx:xx:xx:xx:xx:28
nvram set wan_hwaddr=xx:xx:xx:xx:xx:28
stopservice wan
startservice wan
Else
If "getwanMAC"=xx:xx:xx:xx:xx:28
Than
nvram set def_hwaddr=xx:xx:xx:xx:xx:29
nvram set wan_hwaddr=xx:xx:xx:xx:xx:29
stopservice wan
startservice wan
Else
If "getwanMAC"=xx:xx:xx:xx:xx:29
Than
nvram set def_hwaddr=xx:xx:xx:xx:xx:27
nvram set wan_hwaddr=xx:xx:xx:xx:xx:27
stopservice wan
startservice wan
Is it possible to do something like this via telnet/SSH? Thanks in advance.
I m not sure about understanding your post.. maybe you can try this with a shell script?
I you need to write a script (eg. using the http gui function) , and after you should be able to launch it via command line every time you want...
an example maybe:
#!/bin/sh
current=$(nvram get wan_hwaddr)
if [ "$current" = "00:XX:XX:XX:XX" ]
then
nvram_set ...
stopservice wan..
startservier wan..
elif [ "$current" = "00:YY:YY:YY:YY" ]
then
....
.....
fi
Thanks for reply. I ran this script in command line (GUI) manually (can I do this?), but it does not work. I think something is in part "get mac", b/c it does not even restart wan.
Code:
#!/bin/sh
current=$(nvram get wan_hwaddr)
if [ "$current" = "xx:xx:xx:xx:xx:29" ]
then
nvram set def_hwaddr=xx:xx:xx:xx:xx:27
nvram set wan_hwaddr=xx:xx:xx:xx:xx:27
stopservice wan
startservice wan
elif [ "$current" = "xx:xx:xx:xx:xx:27" ]
then
nvram set def_hwaddr=xx:xx:xx:xx:xx:28
nvram set wan_hwaddr=xx:xx:xx:xx:xx:28
stopservice wan
startservice wan
elif [ "$current" = "xx:xx:xx:xx:xx:28" ]
then
nvram set def_hwaddr=xx:xx:xx:xx:xx:29
nvram set wan_hwaddr=xx:xx:xx:xx:xx:29
stopservice wan
startservice wan
fi
I would like to do this, b/c I would like to use reconnect function in jDownloader. But the cable modem connects IP with MAC, so the only way is change the router´s MAC.
Yes of course you can run it directly in command line..
You can use an editor like vi/gedit to write the script and then debug it using "sh -x /tmp/scriptname" .
I'm not sure about this, but since / fs is not directly writable you have to use the gui for placing your script somewhere, without losing it at next reboot.
I don't know if stopservice wan is actually a command recognized by dd-wrt, if yes, then it should work.Try debug with "-x" switch.
I am alive and back!
So, well if someone reads this I still have not solved it.
ray.rick.mini wrote:
I don't know if stopservice wan is actually a command recognized by dd-wrt
I think "stopservice wan" is recognized, b/c i could change the MAC by these commands:
Code:
nvram_set
nvram set def_hwaddr=00:00:00:00:00:02
nvram set wan_hwaddr=00:00:00:00:00:02
stopservice wan
startservier wan
ray.rick.mini wrote:
debug with "-x" switch
Sorry, I do not know what should I do, could you explain it on example?
Code:
current=$(nvram get wan_hwaddr)
if [ "$current" = "00:00:00:00:00:01" ]
then
nvram_set
nvram set def_hwaddr=00:00:00:00:00:02
nvram set wan_hwaddr=00:00:00:00:00:02
stopservice wan
startservier wan
elif
fi
The part from "nvram_set" is correct, I can manually change the MAc in this way.
But there is something wrong in the $current, it does not recognize the MAC. Is something wrong in that code?
THX
EDIT:
I also tried to write something like this:
Code:
if [ 1=1 ]
then
nvram_set
nvram set def_hwaddr=00:00:00:00:00:02
nvram set wan_hwaddr=00:00:00:00:00:02
stopservice wan
startservier wan
fi
This should run the condition every time, but it did not!
Running only
Code:
nvram_set
nvram set def_hwaddr=00:00:00:00:00:02
nvram set wan_hwaddr=00:00:00:00:00:02
stopservice wan
startservier wan
works great. _________________ TL-WR1043ND v1.8- OpenWRT Backfire 10.03.1 with LuCI; DD no more