You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
WSL 2 - Static MAC Address or Changing MAC After Booting Without Breaking Internet Connection #5352
Windows build number: 10.0.19041.264
Your Distribution version: Ubuntu 20.04
Whether the issue is on WSL 2 and/or WSL 1: WSL 2
Steps to reproduce
sudo ip link set dev eth0 down
sudo ip link set dev eth0 address 00:15:5d:09:b0:a0 # or any address, which will be fixed
sudo ip link set dev eth0 up
Expected behavior
IPv4 and IPv6 address can change(and would change), but the connection to the local physical machine and internet should be OK.
Actual behavior
I cannot use any program that requires to connect to the internet and GUI program which is attached to the local physical machine's vcxsrv X server.
Reacted by therealkenc, John Hagen, tthrx, Rex Shepherd, rp42, Keith Hill, leejae04, Makoto Schoppert, Tim auf der Landwehr, Guillermo González de Agüero and 1 more
Yeah, I was all ready to dupe this user-error variation #4454 when you posted, but quickly figured out that's not it. I also looked to see if there was a way to modify the adapter properties from the Windows side (by mashing keys in powershell) but had no luck. I did find that putting the MAC address back the way it was does enable packets to route properly again. Which is of no use at all, except for the data point the damage is reversible.
I don't know the peoples in here how the issue faced on this, but I faced the licensing issue from this. Need to static hardware address for using License... Is there any other place to push this issue on Windows?
I have the same issue. I am trying to run MATLAB in WSL2 and get a license error every time I restart the WSL because the mac addresses change.
Hey fritut08,
I solved the license problem derived from the non-supported static mac address.
Below the guy "therealkenc" mentioned, you can use the "bond0" field to attach the license when issuing licenses.
I have the same issue. I am trying to run MATLAB in WSL2 and get a license error every time I restart the WSL because the mac addresses change.
Hey fritut08,
I solved the license problem derived from the non-supported static mac address.
Below the guy "therealkenc" mentioned, you can use the "bond0" field to attach the license when issuing licenses.
Hey mauver15,
it does not work for me since MATLAB seems to use the mac address of eth0 when issuing the license but uses a combination of eth0 and bond0 when checking the license. So, whenever I start MATLAB after a restart of WSL2 it tries to compare the eth0 from when the license was issued with the current "eth0 bond0".
I have the same issue. I am trying to run MATLAB in WSL2 and get a license error every time I restart the WSL because the mac addresses change.
Hey fritut08,
I solved the license problem derived from the non-supported static mac address.
Below the guy "therealkenc" mentioned, you can use the "bond0" field to attach the license when issuing licenses.
Hey mauver15,
it does not work for me since MATLAB seems to use the mac address of eth0 when issuing the license but uses a combination of eth0 and bond0 when checking the license. So, whenever I start MATLAB after a restart of WSL2 it tries to compare the eth0 from when the license was issued with the current "eth0 bond0".
Ok, I got it.
Set the static mac address of the "bond0" field. Do change mac address to the address you are previously applied at the license.
And this change does not affect your internet connection.
(In your uploaded picture, there are two mac addresses that the license looks for. One is from eth0/other one is bond0)
-> sudo ip link set dev bond0 address XX:XX:XX:XX:XX:XX
Confirm that is your bond0's mac address fixed.
Re-activate your license.
You can do this with the flows I wrote.
Reacted by frankli998, Jared Tanner, JiaAn Chen, Fabrizio Romanelli, Jestzer and aalmagrospace
1. Set the static mac address of the "bond0" field. Do change mac address to the address you are previously applied at the license.
And this change does not affect your internet connection.
(In your uploaded picture, there are two mac addresses that the license looks for. One is from eth0/other one is bond0)
-> sudo ip link set dev bond0 address XX:XX:XX:XX:XX:XX
2. Confirm that is your bond0's mac address fixed.
3. Re-activate your license.
You can do this with the flows I wrote.
No, I do not think the bond0 address is the problem. The bond0 address is not used in the license files after all. It is the eth0 address that is mentioned in the license file. So I would have to change that.
I think I am getting the same issue with Gurobi in WSL2, the licence does not work after reboot due to HostID mismatch. Gurobi-recommended solution is to switch to WSL1.
Reacted by Sebastian Guerraty, Alberto Schiabel, Matthias Miltenberger, Max Kratz and Keith Hill
For software that only checks eth0, I'm using a workaround involving changing the bond0 interface name to eth0. For example, something like this in .bashrc:
mac=7b:6c:2a:30:2b:08
gateway=$(ip route | awk '/default via /{print $3; exit}' 2>/dev/null)
if ! ip link show | grep -q $mac; then
sudo ip link set dev eth0 down
sudo ip link set dev eth0 name eth1
sudo ip link set dev eth1 up
sudo ip route add default via $gateway dev eth1
sudo ip link set dev bond0 down
sudo ip link set dev bond0 address $mac
sudo ip link set dev bond0 name eth0
sudo ip link set dev eth0 up
fi
The old eth0 is renamed to eth1 but all connections still appear to work after the rename.
Thanks Jim Chen (@darchons) this works perfect.
To change my MAC address automatically on WSL startup:
I put your snippet in a bash file "wsl.mac" that I put in /etc/ and that I made executable.
Then I created wsl.conf in /etc/ with the following content:
[boot]
command = sudo /etc/wsl.mac
Reacted by Linden Wells, FliffNight, Tyler, Yoshio TAKAEDA, Alessandro Zavoli and Priscila Nunes
For software that only checks eth0, I'm using a workaround involving changing the bond0 interface name to eth0. For example, something like this in .bashrc:
mac=7b:6c:2a:30:2b:08
gateway=$(ip route | awk '/default via /{print $3; exit}' 2>/dev/null)
if ! ip link show | grep -q $mac; then
sudo ip link set dev eth0 down
sudo ip link set dev eth0 name eth1
sudo ip link set dev eth1 up
sudo ip route add default via $gateway dev eth1
sudo ip link set dev bond0 down
sudo ip link set dev bond0 address $mac
sudo ip link set dev bond0 name eth0
sudo ip link set dev eth0 up
fi
The old eth0 is renamed to eth1 but all connections still appear to work after the rename.
When I try this approach, I got the following errors
Not sure why, after upgrade windows recently, I can not change the mac address,
ip link set eth0 addr XXXXXXXXXXXXX
RTNETLINK answers: Cannot assign requested address
Ran into the same problem, I needed static MAC addresses for network authentication, so I modified WSLAttachSwitch to add the ability to add NICs with static MAC addresses: you can get my modified version here, if the author hasn't merged it yet遇到了同样的问题,我需要静态MAC地址进行网络身份验证,因此我修改了WSLAttachSwitch以添加具有静态MAC地址的NIC的功能:如果作者尚未合并,则可以在此处获取我的修改版本。
大佬,我想问问这个方案还能用吗,我尝试了一下显示“The application to execute does not exist: 'D:**\WSLAttachSwitch.dll'.”,我搜索了一下都没有找到这个文件
Ran into the same problem, I needed static MAC addresses for network authentication, so I modified WSLAttachSwitch to add the ability to add NICs with static MAC addresses: you can get my modified version here, if the author hasn't merged it yet遇到了同样的问题,我需要静态MAC地址进行网络身份验证,因此我修改了WSLAttachSwitch以添加具有静态MAC地址的NIC的功能:如果作者尚未合并,则可以在此处获取我的修改版本。
大佬,我想问问这个方案还能用吗,我尝试了一下显示“The application to execute does not exist: 'D:**\WSLAttachSwitch.dll'.”,我搜索了一下都没有找到这个文件
作者已经合并此PR,请使用作者的版本。另外我没遇到这种问题 for non Chinese speakers: The author has merged this PR, please use the original version. Besides, I have not encountered this problem
I want to add my solution to the already presented bulk as well. Since my original comments (#5352 (comment)) four years ago, a few things changed but this problem still persists. I have since switched machines and reinstalled WSL and MATLAB a few times. Currently, the WSL only has two network devices by default:
ip address
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
...
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1492 qdisc mq state UP group default qlen 1000
link/ether SOME:MAC:ADDRESS brd ff:ff:ff:ff:ff:ff
...
When MATLAB is registered in this situation, the license will include the mac address of eth0. After restarting the machine, the mac address of eth0 changes and MATLAB will complain since it cannot find any device whose mac address matches the one in the license.
Therefore, I simply create an additional network device with the mac address in the license with this command:
sudo ip link add bond0 address SOME:MAC:ADDRESS type bond
Afterwards, MATLAB can be started without license errors.
Unfortunately, this device is lost when the machine is shut down. Therefore, instead of executing the command above after every restart, one can let this command automatically be executed every time WSL is started by adding this to the file /etc/wsl.conf within the WSL:
[boot]
command = ip link add bond0 address 00:15:5d:e1:cf:3f type bond
Reacted by Anaerobe, Ali-Steel, mrpp, Xinyuan Yu, Johannes Brust, jhbit and Sam_Monkey
I'm also having this issue while trying to use WSL within an organization that has firewall rules locally implemented by Symantec Endpoint Protection. We can apply firewall rule to MAC but if it keeps changing, this will not work. Any ideas?
I want to add my solution to the already presented bulk as well. Since my original comments (#5352 (comment)) four years ago, a few things changed but this problem still persists. I have since switched machines and reinstalled WSL and MATLAB a few times. Currently, the WSL only has two network devices by default:
ip address
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
...
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1492 qdisc mq state UP group default qlen 1000
link/ether SOME:MAC:ADDRESS brd ff:ff:ff:ff:ff:ff
...
When MATLAB is registered in this situation, the license will include the mac address of eth0. After restarting the machine, the mac address of eth0 changes and MATLAB will complain since it cannot find any device whose mac address matches the one in the license. Therefore, I simply create an additional network device with the mac address in the license with this command:
sudo ip link add bond0 address SOME:MAC:ADDRESS type bond
Afterwards, MATLAB can be started without license errors. Unfortunately, this device is lost when the machine is shut down. Therefore, instead of executing the command above after every restart, one can let this command automatically be executed every time WSL is started by adding this to the file /etc/wsl.conf within the WSL:
[boot]
command = ip link add bond0 address 00:15:5d:e1:cf:3f type bond
Thank you! I'm trying this to vitis/vivado and it works!
This issue has been automatically closed since it has not had any activity for the past year. If you're still experiencing this issue please re-file this as a new issue or feature request.
Activity
therealkenc commentedon Jun 7, 2020
Was able to repro here.
therealkenc commentedon Jun 9, 2020
Yeah, I was all ready to dupe this user-error variation #4454 when you posted, but quickly figured out that's not it. I also looked to see if there was a way to modify the adapter properties from the Windows side (by mashing keys in powershell) but had no luck. I did find that putting the MAC address back the way it was does enable packets to route properly again. Which is of no use at all, except for the data point the damage is reversible.
Biswa96 commentedon Jun 9, 2020
HcnCreateNetwork -> HcnCreateEndpoint -> HcsModifyComputeSystem
mauver15 commentedon Aug 14, 2020
I don't know the peoples in here how the issue faced on this, but I faced the licensing issue from this. Need to static hardware address for using License... Is there any other place to push this issue on Windows?
I'm desperate now.
fritut08 commentedon Aug 21, 2020
I have the same issue. I am trying to run MATLAB in WSL2 and get a license error every time I restart the WSL because the mac addresses change.
mauver15 commentedon Aug 24, 2020
I filed a QnA to docs.microsoft but they commented there is no solution for this...
Sadly, I'm gonna install the VMware or something.
https://docs.microsoft.com/en-us/answers/questions/73672/ubuntu-on-the-wsl2-fixed-mac-address-with-availabl.html
mauver15 commentedon Sep 28, 2020
Hey fritut08,
I solved the license problem derived from the non-supported static mac address.
Below the guy "therealkenc" mentioned, you can use the "bond0" field to attach the license when issuing licenses.
fritut08 commentedon Sep 28, 2020
Hey mauver15,
it does not work for me since MATLAB seems to use the mac address of eth0 when issuing the license but uses a combination of eth0 and bond0 when checking the license. So, whenever I start MATLAB after a restart of WSL2 it tries to compare the eth0 from when the license was issued with the current "eth0 bond0".
mauver15 commentedon Sep 28, 2020
Ok, I got it.
Set the static mac address of the "bond0" field. Do change mac address to the address you are previously applied at the license.
And this change does not affect your internet connection.
(In your uploaded picture, there are two mac addresses that the license looks for. One is from eth0/other one is bond0)
-> sudo ip link set dev bond0 address XX:XX:XX:XX:XX:XX
Confirm that is your bond0's mac address fixed.
Re-activate your license.
You can do this with the flows I wrote.
fritut08 commentedon Sep 28, 2020
No, I do not think the bond0 address is the problem. The bond0 address is not used in the license files after all. It is the eth0 address that is mentioned in the license file. So I would have to change that.
BoZenKhaa commentedon Jan 11, 2021
I think I am getting the same issue with Gurobi in WSL2, the licence does not work after reboot due to
HostID mismatch. Gurobi-recommended solution is to switch to WSL1.15 remaining items
VonAlphaBisZulu commentedon Mar 23, 2022
Thanks Jim Chen (@darchons) this works perfect.
To change my MAC address automatically on WSL startup:
I put your snippet in a bash file "
wsl.mac" that I put in /etc/ and that I made executable.Then I created
wsl.confin /etc/ with the following content:AlessandroZavoli commentedon Apr 12, 2023
When I try this approach, I got the following errors
any idea?
ailiop commentedon Apr 12, 2023
Apparently,
bond0and other network devices are not created by default since WSL 1.17, which was released last week. See also #7791.You can create
bond0manually:sudo ip link add bond0 type bondFor me, this was sufficient for then setting its MAC address as per #5866 (comment). I suspect the same will be true for cloning
eth0intoeth1, etc.AlessandroZavoli commentedon Apr 12, 2023
kenvix commentedon Jul 28, 2023
Ran into the same problem, I needed static MAC addresses for network authentication, so I modified WSLAttachSwitch to add the ability to add NICs with static MAC addresses: you can get my modified version here, if the author hasn't merged it yet
luwening commentedon Dec 15, 2023
Not sure why, after upgrade windows recently, I can not change the mac address,
ip link set eth0 addr XXXXXXXXXXXXX
RTNETLINK answers: Cannot assign requested address
youyouhdhd commentedon Dec 28, 2023
大佬,我想问问这个方案还能用吗,我尝试了一下显示“The application to execute does not exist: 'D:**\WSLAttachSwitch.dll'.”,我搜索了一下都没有找到这个文件
kenvix commentedon Dec 28, 2023
作者已经合并此PR,请使用作者的版本。另外我没遇到这种问题
for non Chinese speakers: The author has merged this PR, please use the original version. Besides, I have not encountered this problem
chanpreetdhanjal commentedon Jan 8, 2024
Hi. Can you please collect networking logs by following the instructions below?
https://github.com/microsoft/WSL/blob/master/CONTRIBUTING.md#collect-wsl-logs-for-networking-issues
fritut08 commentedon Feb 24, 2024
I want to add my solution to the already presented bulk as well. Since my original comments (#5352 (comment)) four years ago, a few things changed but this problem still persists. I have since switched machines and reinstalled WSL and MATLAB a few times. Currently, the WSL only has two network devices by default:
When MATLAB is registered in this situation, the license will include the mac address of
eth0. After restarting the machine, the mac address ofeth0changes and MATLAB will complain since it cannot find any device whose mac address matches the one in the license.Therefore, I simply create an additional network device with the mac address in the license with this command:
Afterwards, MATLAB can be started without license errors.
Unfortunately, this device is lost when the machine is shut down. Therefore, instead of executing the command above after every restart, one can let this command automatically be executed every time WSL is started by adding this to the file
/etc/wsl.confwithin the WSL:seabeam commentedon Aug 20, 2024
It's really common in specified domain softwares who use FLEXlm to manage license. One MAC, one license, and one bill
CodeWilliamson commentedon Nov 13, 2024
I'm also having this issue while trying to use WSL within an organization that has firewall rules locally implemented by Symantec Endpoint Protection. We can apply firewall rule to MAC but if it keeps changing, this will not work. Any ideas?
SamMonkey51 commentedon Oct 4, 2025
Thank you! I'm trying this to vitis/vivado and it works!
microsoft-github-policy-service commentedon Oct 8, 2026
This issue has been automatically closed since it has not had any activity for the past year. If you're still experiencing this issue please re-file this as a new issue or feature request.
Thank you!