How to get and recognise MAC via telnet/SSH?

Post new topic   Reply to topic    DD-WRT Forum Index -> Advanced Networking
Author Message
durib
DD-WRT Novice


Joined: 07 Oct 2010
Posts: 49

PostPosted: Thu Mar 17, 2011 20:44    Post subject: How to get and recognise MAC via telnet/SSH? Reply with quote
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.
Sponsor
ray.rick.mini
DD-WRT Novice


Joined: 16 Mar 2011
Posts: 31

PostPosted: Thu Mar 17, 2011 23:18    Post subject: Reply with quote
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
durib
DD-WRT Novice


Joined: 07 Oct 2010
Posts: 49

PostPosted: Fri Mar 18, 2011 7:24    Post subject: Reply with quote
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.
ray.rick.mini
DD-WRT Novice


Joined: 16 Mar 2011
Posts: 31

PostPosted: Fri Mar 18, 2011 9:12    Post subject: Reply with quote
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.
durib
DD-WRT Novice


Joined: 07 Oct 2010
Posts: 49

PostPosted: Fri Mar 18, 2011 16:36    Post subject: Reply with quote
I am pausing it, b/c I bricked my router with new FW. I am going to try warranty. Thanks for advices, I will continue when I get my router working.
ray.rick.mini
DD-WRT Novice


Joined: 16 Mar 2011
Posts: 31

PostPosted: Fri Mar 18, 2011 16:46    Post subject: Reply with quote
durib wrote:
I am pausing it, b/c I bricked my router with new FW. I am going to try warranty. Thanks for advices, I will continue when I get my router working.

lol Ok..good luck
durib
DD-WRT Novice


Joined: 07 Oct 2010
Posts: 49

PostPosted: Wed Apr 06, 2011 18:24    Post subject: Reply with quote
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 Wink
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Advanced Networking All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum