Board logo

標題: Auto Random MAC Address and renew WAN IP address [打印本頁]

作者: tomleehk    時間: 2014-5-14 22:54     標題: Auto Random MAC Address and renew WAN IP address

本帖最後由 tomleehk 於 2014-5-14 22:57 編輯

This script will change your eth1 MAC address to a random address, then it will apply it to the system and restart the interfaces.
  1. #!/bin/ash
  2. MAC=`(date; cat /proc/interrupts) | md5sum | sed -r 's/^(.{10}).*$/\1/; s/([0-9a-f]{2})/\1:/g; s/:$//;'`
  3. echo "00:${MAC}"
  4. ifconfig eth1 hw ether 00:${MAC}
  5. nvram set def_hwaddr="00:${MAC}"
  6. nvram set wan_hwaddr="00:${MAC}"
  7. stopservice wan
  8. startservice wan
複製代碼
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

本帖最後由 tomleehk 於 2014-5-15 15:21 編輯

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.
  1. "00:17:9A:${MAC}"  
複製代碼
to represent D-link's random MAC address..
  1. #!/bin/ash
  2. MAC=`(date; cat /proc/interrupts) | md5sum | sed -r 's/^(.{10}).*$/\1/; s/([0-9a-f]{2})/\1:/g; s/:$//;'`
  3. echo "00:17:9A:${MAC}"
  4. ifconfig eth1 hw ether 00:17:9A:${MAC}
  5. nvram set def_hwaddr="00:17:9A:${MAC}"
  6. nvram set wan_hwaddr="00:17:9A:${MAC}"
  7. stopservice wan
  8. startservice wan
複製代碼





歡迎光臨 電訊茶室 (http://telecom-cafe.com/forum/) Powered by Discuz! 7.2