Do a better job with network interfaces when faced with vlans

This commit is contained in:
Tim Young 2019-03-17 14:26:51 +03:00
parent 073cba135e
commit cecd14a901
1 changed files with 11 additions and 2 deletions

View File

@ -1393,8 +1393,17 @@ namespace EduNetworkBuilder
//If we are doing vlans, the vlan should match if we are doing management interface
//
//right now, just do it.
nic.PrimaryInterface().myIP = new NB_IPAddress(newip, gateway._mask.ToIpString(), IPAddressType.ip);
return true;
NetworkInterface nif = nic.PrimaryInterface();
if(nif == null)
{ //There are multiple interfaces, or there are no interfaces.
//If multiple interfaces, try one with the specified vlan.
nif = nic.InterfaceFromVlanTag(vlan);
}
if (nif != null)
{
nif.myIP = new NB_IPAddress(newip, gateway._mask.ToIpString(), IPAddressType.ip);
return true;
}
}
}
return false;