Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NicSetSetting: change of MAC Address does not take effect until manual restart of VPN Client #172

Open
scandox opened this issue Aug 28, 2015 · 6 comments
Assignees

Comments

@scandox
Copy link

scandox commented Aug 28, 2015

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:

  • Enable and Disable of NIC
  • Setting it multiple times
  • Disconnecting any Accounts and then Reconnecting.

However only vpnclient stop && vpnclient start works for me. I am using two separate clients:

  • Version 4.17 Build 9562 on Debian Wheezy
  • Version 4.18 Build 9570 on Raspbian

Both exhibit the same behaviour. Is this a bug or a feature?

@moatazelmasry2
Copy link
Member

Could you please verify that this problem still occur?

@scandox
Copy link
Author

scandox commented Dec 1, 2017

@moatazelmasry2 Sorry for the slow response. Haven't been active with Softether for a few months.

Today I took a look at this.

  • I setup a server and client
  • Connected the client
  • Checked the MAC Address which was 00:AC:B2:5A:26:93
  • Logged in to vpncmd and ran "NicSetSetting ether MAC:/00-AC-BA-B5-B4-78
  • Logged out of vpncmd and ran ifconfig. Still seeting MAC ending with 93
  • Restarted vpnclient
  • Ran ifconfig and now see MAC ending with 78

So it seems to me this issue is still live. The versions of Server and Client were:

  • Client Ver 4.24, Build 9651 on Ubuntu 16.06
  • Server Ver 4.24, Build 9651 on Ubuntu 16.06

@scandox
Copy link
Author

scandox commented Dec 5, 2017

@moatazelmasry2 I'm not really a C++ person but it seems to me the issue lies in or around the code here:

StrToMac(r->MacAddress, set->MacAddress);

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:

ioctl(s, SIOCSIFHWADDR, &ifr);

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!

@moatazelmasry2
Copy link
Member

Didn't test that yet, but this looks like a very good analysis. Solid work!!!. Now we need someone to implement that :)

@davidebeatrici davidebeatrici self-assigned this Jul 30, 2018
@Hamilkar247
Copy link

If i good understand, problem with set MAC address still exist?

@scandox
Copy link
Author

scandox commented May 31, 2021

@Hamilkar247 Yes it looks that way. There is no apparent change to the way this works,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants