diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java index 2eb269fc1e2..ea32025ba32 100755 --- a/server/src/com/cloud/configuration/Config.java +++ b/server/src/com/cloud/configuration/Config.java @@ -105,6 +105,8 @@ public enum Config { SecurityGroupDefaultAdding("Network", ManagementServer.class, Boolean.class, "network.securitygroups.defaultadding", "true", "If true, the user VM would be added to the default security group by default", null), + GuestOSNeedGatewayOnNonDefaultNetwork("Network", NetworkManager.class, String.class, "network.dhcp.nondefaultnetwork.setgateway.guestos", "Windows", "The guest OS's name start with this fields would result in DHCP server response gateway information even when the network it's on is not default network. Names are separated by comma.", null), + //VPN RemoteAccessVpnPskLength("Network", AgentManager.class, Integer.class, "remote.access.vpn.psk.length", "24", "The length of the ipsec preshared key (minimum 8, maximum 256)", null), RemoteAccessVpnClientIpRange("Network", AgentManager.class, String.class, "remote.access.vpn.client.iprange", "10.1.2.1-10.1.2.8", "The range of ips to be allocated to remote access vpn clients. The first ip in the range is used by the VPN server", null), @@ -293,6 +295,7 @@ public enum Config { VmOpCleanupWait("Advanced", ManagementServer.class, Long.class, "vm.op.cleanup.wait", "3600", "Time (in seconds) to wait before cleanuping up any vm work items", "Seconds"), VmOpCancelInterval("Advanced", ManagementServer.class, Long.class, "vm.op.cancel.interval", "3600", "Time (in seconds) to wait before cancelling a operation", "Seconds"), + DefaultPageSize("Advanced", ManagementServer.class, Long.class, "default.page.size", "500", "Default page size for API list* commands", null), TaskCleanupRetryInterval("Advanced", ManagementServer.class, Integer.class, "task.cleanup.retry.interval", "600", "Time (in seconds) to wait before retrying cleanup of tasks if the cleanup failed previously. 0 means to never retry.", "Seconds"), diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java index 0af034f014f..208bd9b7647 100755 --- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java +++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java @@ -341,6 +341,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian int _routerCheckInterval = 30; protected ServiceOfferingVO _offering; private String _dnsBasicZoneUpdates = "all"; + private Set _guestOSNeedGatewayOnNonDefaultNetwork = new HashSet(); private boolean _disable_rp_filter = false; int _routerExtraPublicNics = 2; @@ -592,6 +593,14 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian _routerExtraPublicNics = NumbersUtil.parseInt(_configDao.getValue(Config.RouterExtraPublicNics.key()), 2); + String guestOSString = configs.get("network.dhcp.nondefaultnetwork.setgateway.guestos"); + if (guestOSString != null) { + String[] guestOSList = guestOSString.split(","); + for (String os : guestOSList) { + _guestOSNeedGatewayOnNonDefaultNetwork.add(os); + } + } + String value = configs.get("start.retry"); _retry = NumbersUtil.parseInt(value, 2); @@ -2931,14 +2940,22 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian DhcpEntryCommand dhcpCommand = new DhcpEntryCommand(nic.getMacAddress(), nic.getIp4Address(), vm.getHostName()); DataCenterVO dcVo = _dcDao.findById(router.getDataCenterIdToDeployIn()); String gatewayIp = findGatewayIp(vm.getId()); + boolean needGateway = true; if (!gatewayIp.equals(nic.getGateway())) { + needGateway = false; GuestOSVO guestOS = _guestOSDao.findById(vm.getGuestOSId()); - // Don't set dhcp:router option for non-default nic on CentOS/RHEL, because they would set routing on wrong interface - // This is tricky, we may need to update this when we have more information on various OS's behavior - if (guestOS.getDisplayName().startsWith("CentOS") || guestOS.getDisplayName().startsWith("Red Hat Enterprise")) { - gatewayIp = "0.0.0.0"; + // Do set dhcp:router option for non-default nic on certain OS(including Windows), and leave other OS unset. + // Because some OS(e.g. CentOS) would set routing on wrong interface + for (String name : _guestOSNeedGatewayOnNonDefaultNetwork) { + if (guestOS.getDisplayName().startsWith(name)) { + needGateway = true; + break; + } } } + if (!needGateway) { + gatewayIp = "0.0.0.0"; + } dhcpCommand.setDefaultRouter(gatewayIp); dhcpCommand.setDefaultDns(findDefaultDnsIp(vm.getId())); diff --git a/setup/db/db/schema-40to41.sql b/setup/db/db/schema-40to41.sql index 51afde47bfe..61cb4a22b39 100644 --- a/setup/db/db/schema-40to41.sql +++ b/setup/db/db/schema-40to41.sql @@ -21,3 +21,5 @@ ALTER TABLE `cloud`.`network_offerings` ADD COLUMN `eip_associate_public_ip` int(1) unsigned NOT NULL DEFAULT 0 COMMENT 'true if public IP is associated with user VM creation by default when EIP service is enabled.' AFTER `elastic_ip_service`; + +INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Network','DEFAULT','NetworkManager','network.dhcp.nondefaultnetwork.setgateway.guestos','Windows','The guest OS\'s name start with this fields would result in DHCP server response gateway information even when the network it\'s on is not default network. Names are separated by comma.');