OpenWrt Forum Archive

Topic: Change wan MAC address

The content of this topic has been archived on 28 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Greetings, I haven't been using OpenWRT/Kamikaze for very long, but I'm not a linux newbie.    I'm having a hard time figuring the right way to change the MAC address of WAN on my WRT-54GL.

Most of the documentation out there must pertain to WhiteRussian because nothing seems to apply anymore.   Most docs say to use an nvram parameter wan_hwaddr to set it, but it seems to have no effect.

ifconfig shows this:

br-lan    Link encap:Ethernet  HWaddr 00:1D:7E:DC:31:44 
          inet addr:192.168.0.8  Bcast:192.168.0.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:53 errors:0 dropped:0 overruns:0 frame:0
          TX packets:83 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:5257 (5.1 KiB)  TX bytes:12708 (12.4 KiB)

eth0      Link encap:Ethernet  HWaddr 00:1D:7E:DC:31:44 
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3383 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3894 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:361769 (353.2 KiB)  TX bytes:685028 (668.9 KiB)
          Interrupt:4

eth0.0    Link encap:Ethernet  HWaddr 00:1D:7E:DC:31:44 
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3395 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3500 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:301917 (294.8 KiB)  TX bytes:535915 (523.3 KiB)

eth0.1    Link encap:Ethernet  HWaddr 00:1D:7E:DC:31:44 
          inet addr:10.10.10.10  Bcast:10.10.10.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:405 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:133245 (130.1 KiB)

lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

wl0       Link encap:Ethernet  HWaddr 00:1D:7E:DC:31:46 
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:195
          TX packets:0 errors:119 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:2 Base address:0x5000

I have set 10.10.10.10 as the WAN address static for now, for testing.   The webif set the address on eth0.1 - isn't that a virtual interface?   The MAC is the same as all the others.    Do I need to do something to specify the correct WAN interface?   What is it called?   All of the documentation I've seen online shows vlan0 as being wan or something, and that interface does not exist.

Any points in the right direction would be greatly appreciated.

add "option macaddr xx:xx:xx:xx:xx:xx" to the corresponding "config interface" section in /etc/config/network

Thanks.   I actually just guessed what it was five minutes before your reply smile

But does the interface name of eth0.1 seem right for the WAN?   I'll be testing it in a couple hours - the device is actually not here, it's remote.   I've installed and configured most of OpenWRT remotely but unfortunately I don't have a robot over there that can plug in the WAN interface for me.

Normally eth0.1 is the WAN interface, if you didn't change the vlan configuration too much.
However, it's configuration section is "config interface wan"

If you didn't changed to much in the wan section in /etc/config/network you can run the commands below to change the wan MAC address.

uci set network.wan.macaddr="<mac_address>"
uci commit network
ifdown wan && ifup wan

(Last edited by forum2008 on 3 Feb 2008, 11:55)

This works great for me also but does anybody have a script that will set network.wan.macaddr=<network.lan.macaddr>+1 or something like that. I assume that the MAC address is derived from the nvram setting but where does that happen?

Actually, I'm not sure where it gets the original values.   For the router I installed OpenWRT on (Linksys WRT54GL) it just had one - 00:1D:7E:DC:31:44 which OpenWRT assigned to both the LAN and WAN ports.   nvRAM on this unit shows this:  et0macaddr=00:1D:7E:DC:31:44  but that could have been left behind from the DD-WRT install that was on this unit.   It could get the information from the network chip like in a PC, maybe.

It will be interesting to see how it works with my Motorola WR850R, since that unit apparently has no pre-determined MAC addresses.   When I installed DD-WRT on that one, I had to assign both the WAN and LAN addresses manually and it was a pain in the butt.

I'm curious as to why you'd like to automate it with a script or some such?

The original Linksys firmware uses 2 different MAC addresses. My nvram contains a 2nd MAC address in il0macaddr which is set to a value of et0macaddr +2 but I'm not certain if this is a remnant of the Linksys sonfig. or not.

Manually setting the WAN macaddr is no big deal for my personal router but this loadfile will be installed on potentially many more and I want to make the configuration automagical.

The discussion might have continued from here.