Change WAN Port MAC Address? (Tomato Shibby)

Discussion in 'Tomato Firmware' started by tahayassen, Dec 24, 2013.

  1. tahayassen

    tahayassen Reformed Router Member

    So I found the below script from here:

    MAC=`(date; cat /proc/interrupts) | md5sum | sed -r 's/^(.{10}).*$/\1/; s/([0-9a-f]{2})/\1:/g; s/:$//;'`
    echo "00:${MAC}"
    ifconfig eth1 hw ether 00:${MAC}
    nvram set def_hwaddr="00:${MAC}"
    nvram set wan_hwaddr="00:${MAC}"
    stopservice wan
    startservice wan
    This script is for DD-WRT - not Tomato. Is there any way I can modify this script so that it changes the WAN port MAC address to a random one? Or is there a command to do this? The reason why I want to do this is because I want to write a script that automatically changes my WAN IP address.
  2. Mate Rigo

    Mate Rigo Networkin' Nut Member

    Do a nvram dump. Search for the value holding the MAC address of the WAN, then make a script where you set that nvram value.
    Something like:
    nvram set value=newvalue

    This should do it, I guess.

    Then do a reboot.

    Edit: before reboot do a nvram commit

    But perhaps this is not the best way, as your flash will wear out eventually, if you modify nvram all the time.
    Last edited: Dec 26, 2013
    HitheLightz likes this.
  3. tahayassen

    tahayassen Reformed Router Member


    I won't do it often so hopefully this won't be an issue. Does anyone know if I modify nvram when I save settings to router?
  4. koitsu

    koitsu Network Guru Member

    nvram set, AFAIK, changes the active value returned, but doesn't commit it to NVRAM. Meaning, in some roundabout way, it gets cached and will be lost on a reboot. nvram commit (after doing nvram set) will save the settings to NVRAM permanently.

    A DD-WRT thread implies that if you change the WAN MAC address, you need to fully reboot the router for it to take effect. That conflicts with what's in their Wiki (I'm not surprised in the least).

    However, be aware there is a short window during the reboot period where the original (hard-wired) MAC address of the physical NIC itself (i.e. not what's in NVRAM) shows up on the network, which is known to cause problems for some people (e.g. some packets won't work/will act strangely because the MAC for the IP of the router suddenly changes).

    Likewise, if your ISP is cable-based (uses cable modems), then be aware that many cable modems do not implement ARP correctly on their Ethernet ports -- every time your MAC address changes on your router/device connected to the Ethernet port of your cable modem, you need to power-cycle (not reboot) the cable modem. Motorola modems are well-known for this.

    Finally, please be aware what you're doing could in fact get you in trouble with your ISP, depending on what their ToS is. In effect what you could end up doing is filling up/exhausting their DHCP lease table depending on how often you do this, and god only knows what their ARP cache would look like. I strongly suggest you do not use this feature; it indicates you're up to something sneaky and as said maybe upset your ISP. Consider this your warning.
  5. azdps

    azdps LI Guru Member

    This is what I was using in the past. I haven't tested this in awhile so I don't know how well it will work. But koitsu, is right, your router will need to be rebooted as well as your modem.

    Example of setting random mac, along with rebooting the modem and then the router:
    MAC=`(date; cat /proc/interrupts) | md5sum | sed -r 's/^(.{10}).*$/\1/; s/([0-9a-f]{2})/\1:/g; s/:$//;'`
    nvram set et0macaddr="00:${MAC}"
    MAC=`(date; cat /proc/interrupts) | md5sum | sed -r 's/^(.{10}).*$/\1/; s/([0-9a-f]{2})/\1:/g; s/:$//;'`
    nvram set def_hwaddr="00:${MAC}"
    nvram set wan_hwaddr="00:${MAC}"
    nvram commit
    sleep 30
    Each modem is a little different. I did a google search for my modem and was able to find information on how to restart it using wget.

    Router is rebooted 30 seconds after the modem, to allow the modem to get a head start to get up and running before the router does.
    Last edited: Dec 28, 2013
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice