I have been using NicSetSetting to set the MAC address of Virtual NICs joining a Hub. I used static leases, so the MAC address effectively determines the IP Address the NIC should obtain.
I have noticed however that the change of MAC Address, though recorded in Softether data, is not reflected in the actual OS, until after a restart of the VPN Client itself. This means on first contact my NIC's are configured with incorrect IP addresses.
I also tried:
However only vpnclient stop && vpnclient start works for me. I am using two separate clients:
Both exhibit the same behaviour. Is this a bug or a feature?
Could you please verify that this problem still occur?
@moatazelmasry2 Sorry for the slow response. Haven't been active with Softether for a few months.
Today I took a look at this.
So it seems to me this issue is still live. The versions of Server and Client were:
@moatazelmasry2 I'm not really a C++ person but it seems to me the issue lies in or around the code here:
r in this case being the result of r = Search(c->UnixVLanList, &t);. After this there are calls to CiSaveConfigurationFile and CiNotify and CiSendGlobalPulse - none of which seem to do anything much at OS level. So maybe it is merely setting the MAC on the internal list, saving it to a config and then not actually attempting to update the virtual adaptor?
When the client restarts of course it will initialize the adaptor correctly with what it finds in the config.
Looking further at the initialization of the TAP device for the Virtual NIC we see this line which seems to set the MAC Address at init:
This is in a function called UnixCreateTapDeviceEx - so I guess what we need is a UnixModifyTapDevice call, which actually calls ioctl with the new MAC? Given that this doesn't already exist though perhaps there is a good reason!
Didn't test that yet, but this looks like a very good analysis. Solid work!!!. Now we need someone to implement that :)
Most helpful comment
@moatazelmasry2 I'm not really a C++ person but it seems to me the issue lies in or around the code here:
https://github.com/SoftEtherVPN/SoftEtherVPN/blob/bed99f9a56e29a0fcd7a9e3d02f84f9d8621eb3d/src/Cedar/Client.c#L8104
rin this case being the result ofr = Search(c->UnixVLanList, &t);. After this there are calls toCiSaveConfigurationFileandCiNotifyandCiSendGlobalPulse- none of which seem to do anything much at OS level. So maybe it is merely setting the MAC on the internal list, saving it to a config and then not actually attempting to update the virtual adaptor?When the client restarts of course it will initialize the adaptor correctly with what it finds in the config.
Looking further at the initialization of the TAP device for the Virtual NIC we see this line which seems to set the MAC Address at init:
https://github.com/SoftEtherVPN/SoftEtherVPN/blob/d7d0e6d36fe1d73eca6205d9b2144ded67f52b13/src/Cedar/VLanUnix.c#L527
This is in a function called
UnixCreateTapDeviceEx- so I guess what we need is aUnixModifyTapDevicecall, which actually callsioctlwith the new MAC? Given that this doesn't already exist though perhaps there is a good reason!