How to: Clone the mac address for the WAN interface on a Ubiquiti Unifi Security Gateway

How to: Clone the mac address for the WAN interface on a Ubiquiti Unifi Security Gateway


Nowadays you somewhat expect that cloning a mac address on a gateway/router would be a basic feature… but as Apple has taught us we don’t know what we want even if we need it. But getting back into topic, recently we started testing Ubiquiti products and part of that included the Unifi Security Gateway. One of the features we are not able to configure via the web administration console / controller is that of cloning a MAC address. For obvious reasons, we require to do that in order for our ISP to assign the correct IP address.


The solution is a bit more difficult than what I would have hoped for. As you probably already know, you are able to access the USG (Unifi Security Gateway) via SSH in order to configure several things. This has proven useful as the default IP it comes with is not compatible with our network. This time thought, it was useful in order to access the configuration console and change the MAC address of the WAN interface (eth0 in my case.) To do this, you need to follow these steps:

  1. Connect to your USG via SSH
  2. Run the following commands (where you replace the Xs for the right numbers):
set interfaces ethernet ethX mac XX:XX:XX:XX:XX:XX

Now, if you connect your Ethernet cable to the USG you’ll notice the change took place and you’re using the new mac address. But here comes the tricky part, when you reboot/restart the USG the settings will be lost! In order to persist the settings, you need to export the running configuration (after performing the changes/commands mentioned above) and include it in your config.gateway.json file. At this point I was like you, clueless as to what to do next. If you want to learn how to do this, please visit: UniFi – How to further customize USG configuration with config.gateway.json.

Now that you have prepared everything, it should look like this:


“interfaces”: {

“ethernet”: {

“eth0”: {

“mac”: “AB:CD:EF:01:23:45”





remember to put your actual MAC address there as well as confirm that your WAN interface is eth0. Also, don’t forget to validate the json file, you can use something like which is a JSON Validator. Just to make sure the syntax is correct.

Now, if you are using Ubuntu you need to create this json file on your controller. After logging in the default folder where you need to place the file is located at: /var/lib/unifi/sites/default. Keep in mind default here is the name of the site, so if your site has a different name you will need to access that folder not this one. Once you’re there, you will create a file (nano config.gateway.json) and paste there our configuration we obtained just before in json format. If you are doing this for different settings, you’ll need to add the interfaces section to your existing config file. One you’re done, reboot your USG and see if the setting worked. If it booted correctly and the MAC address changed as indicated, then you’re all set and good to go!

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.