diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/App.config b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/App.config
index 1bf17d4791f..0e75ef9b5f4 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/App.config
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/App.config
@@ -24,7 +24,7 @@
8
- 10.1.1.1
+ 0.0.0.0
Routing
@@ -45,13 +45,13 @@
34359738368
- camldonall01.citrite.net
+ 0.0.0.0
1
- 10.70.176.1
+ 0.0.0.0
2
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs
index f5008123930..201d58019ce 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs
@@ -1609,13 +1609,19 @@ namespace HypervResource
dynamic strtRouteCmd = cmdArray[0][CloudStackTypes.StartupRoutingCommand];
// Insert networking details
- strtRouteCmd.privateIpAddress = config.PrivateIpAddress;
- strtRouteCmd.privateNetmask = config.PrivateNetmask;
- strtRouteCmd.privateMacAddress = config.PrivateMacAddress;
- strtRouteCmd.storageIpAddress = config.PrivateIpAddress;
- strtRouteCmd.storageNetmask = config.PrivateNetmask;
- strtRouteCmd.storageMacAddress = config.PrivateMacAddress;
- strtRouteCmd.gatewayIpAddress = config.GatewayIpAddress;
+ string privateIpAddress = strtRouteCmd.privateIpAddress;
+ string subnet;
+ System.Net.NetworkInformation.NetworkInterface privateNic = GetNicInfoFromIpAddress(privateIpAddress, out subnet);
+ strtRouteCmd.privateIpAddress = privateIpAddress;
+ strtRouteCmd.privateNetmask = subnet;
+ strtRouteCmd.privateMacAddress = privateNic.GetPhysicalAddress().ToString();
+ string storageip = strtRouteCmd.storageIpAddress;
+ System.Net.NetworkInformation.NetworkInterface storageNic = GetNicInfoFromIpAddress(storageip, out subnet);
+
+ strtRouteCmd.storageIpAddress = storageip;
+ strtRouteCmd.storageNetmask = subnet;
+ strtRouteCmd.storageMacAddress = storageNic.GetPhysicalAddress().ToString();
+ strtRouteCmd.gatewayIpAddress = storageNic.GetPhysicalAddress().ToString();
strtRouteCmd.caps = "hvm";
// Detect CPUs, speed, memory
@@ -1696,9 +1702,11 @@ namespace HypervResource
public static System.Net.NetworkInformation.NetworkInterface GetNicInfoFromIpAddress(string ipAddress, out string subnet)
{
System.Net.NetworkInformation.NetworkInterface[] nics = System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces();
+ System.Net.NetworkInformation.NetworkInterface defaultnic = null;
foreach (var nic in nics)
{
subnet = null;
+ defaultnic = nic;
// TODO: use to remove NETMASK and MAC from the config file, and to validate the IPAddress.
var nicProps = nic.GetIPProperties();
bool found = false;
@@ -1716,7 +1724,9 @@ namespace HypervResource
}
return nic;
}
- throw new ArgumentException("No NIC for ipAddress " + ipAddress);
+ var defaultSubnet = defaultnic.GetIPProperties().UnicastAddresses[0];
+ subnet = defaultSubnet.IPv4Mask.ToString();
+ return defaultnic;
}
public static void GetCapacityForLocalPath(string localStoragePath, out long capacityBytes, out long availableBytes)