電訊茶室's Archiver

tomleehk 發表於 2014-5-14 22:54

Auto Random MAC Address and renew WAN IP address

[i=s] 本帖最後由 tomleehk 於 2014-5-14 22:57 編輯 [/i]

This script will change your eth1 MAC address to a random address, then it will apply it to the system and restart the interfaces.[code]#!/bin/ash
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
[/code]Save the script as the startup scrupt
1. Using the Web Interface, goto the Administration tab.
2. If available, go to the Command subtab, otherwise go to the diagnostics subtab.
3. Type the commands you wish to run every startup into the Commands: dialog box (place each command on a newline using the enter key, and if the command isn't something that stops running after a moment, put a '&' after the command)
4. Click the Save Startup button at the bottom of the page if you'd like the commands to save into the rc_startup variable (you may need to scroll). Save Firewall will save the commands into the rc_firewall variable.

tomleehk 發表於 2014-5-15 15:18

[i=s] 本帖最後由 tomleehk 於 2014-5-15 15:21 編輯 [/i]

If you need to generate random MAC address of the same vendor, you need to fix the prefix of the parameter in the script, e.g.[code]"00:17:9A:${MAC}"  [/code]to represent D-link's random MAC address..[code]#!/bin/ash
MAC=`(date; cat /proc/interrupts) | md5sum | sed -r 's/^(.{10}).*$/\1/; s/([0-9a-f]{2})/\1:/g; s/:$//;'`
echo "00:17:9A:${MAC}"
ifconfig eth1 hw ether 00:17:9A:${MAC}
nvram set def_hwaddr="00:17:9A:${MAC}"
nvram set wan_hwaddr="00:17:9A:${MAC}"
stopservice wan
startservice wan[/code]

頁: [1]

Powered by Discuz! Archiver 7.2  © 2001-2009 Comsenz Inc.