diff --git a/api/src/com/cloud/agent/api/routing/DhcpEntryCommand.java b/api/src/com/cloud/agent/api/routing/DhcpEntryCommand.java index 3b0d8339765..e9097d48e5b 100644 --- a/api/src/com/cloud/agent/api/routing/DhcpEntryCommand.java +++ b/api/src/com/cloud/agent/api/routing/DhcpEntryCommand.java @@ -29,6 +29,7 @@ public class DhcpEntryCommand extends NetworkElementCommand { String nextServer; String defaultRouter; String staticRoutes; + String defaultDns; protected DhcpEntryCommand() { @@ -96,5 +97,11 @@ public class DhcpEntryCommand extends NetworkElementCommand { this.staticRoutes = staticRoutes; } - + public String getDefaultDns() { + return defaultDns; + } + + public void setDefaultDns(String defaultDns) { + this.defaultDns = defaultDns; + } } diff --git a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java index 72ee2cfa667..12bce92d4c3 100755 --- a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java +++ b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java @@ -1442,6 +1442,11 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe if (cmd.getStaticRoutes() != null) { args += " -s " + cmd.getStaticRoutes(); } + + if (cmd.getDefaultDns() != null) { + args += " -N " + cmd.getDefaultDns(); + } + String result = callHostPlugin(conn, "vmops", "saveDhcpEntry", "args", args); if (result == null || result.isEmpty()) { return new Answer(cmd, false, "DhcpEntry failed"); diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java index 5d36ae98895..26584fc5ebb 100755 --- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java +++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java @@ -2024,8 +2024,8 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian if (sendDnsDhcpData) { DhcpEntryCommand dhcpCommand = new DhcpEntryCommand(nic.getMacAddress(), nic.getIp4Address(), profile.getVirtualMachine().getHostName()); - String defaultDhcpIp = findDefaultDhcpIp(profile.getVirtualMachine().getId()); - dhcpCommand.setDefaultRouter(defaultDhcpIp); + dhcpCommand.setDefaultRouter(findGatewayIp(profile.getVirtualMachine().getId())); + dhcpCommand.setDefaultDns(findDefaultDnsIp(profile.getVirtualMachine().getId())); dhcpCommand.setAccessDetail(NetworkElementCommand.ROUTER_IP, routerControlIpAddress); dhcpCommand.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, router.getGuestIpAddress()); @@ -2084,11 +2084,11 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian return rets; } - private String findDefaultDhcpIp(long userVmId) { + private String findDefaultDnsIp(long userVmId) { NicVO defaultNic = _nicDao.findDefaultNicForVM(userVmId); - //check if the DhcpProvider is the domR - if (!_networkMgr.isProviderSupportServiceInNetwork(defaultNic.getNetworkId(), Service.Dhcp, Provider.VirtualRouter)) { + //check if DNS provider is the domR + if (!_networkMgr.isProviderSupportServiceInNetwork(defaultNic.getNetworkId(), Service.Dns, Provider.VirtualRouter)) { return null; } @@ -2096,6 +2096,11 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian NicVO domrDefaultNic = _nicDao.findByNetworkIdAndType(defaultNic.getNetworkId(), VirtualMachine.Type.DomainRouter); return domrDefaultNic.getIp4Address(); } + + private String findGatewayIp(long userVmId) { + NicVO defaultNic = _nicDao.findDefaultNicForVM(userVmId); + return defaultNic.getGateway(); + } @Override public List applyUserData(Network network, NicProfile nic, VirtualMachineProfile profile, DeployDestination dest, ReservationContext context, List routers) @@ -2570,7 +2575,8 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian s_logger.debug("Creating dhcp entry for vm " + vm + " on domR " + router + "."); DhcpEntryCommand dhcpCommand = new DhcpEntryCommand(nic.getMacAddress(), nic.getIp4Address(), vm.getHostName()); - dhcpCommand.setDefaultRouter(findDefaultDhcpIp(vm.getId())); + dhcpCommand.setDefaultRouter(findGatewayIp(vm.getId())); + dhcpCommand.setDefaultRouter(findDefaultDnsIp(vm.getId())); dhcpCommand.setAccessDetail(NetworkElementCommand.ROUTER_IP, router.getPrivateIpAddress()); dhcpCommand.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());