def build(self, *args, **kwargs): """ +---+ +---+ +------------+ | H +-------+ R +-------+ DNS server | +---+ +---+ +------------+ Host H is attached to router R and gets its IPv6 addresses via Router Advertisements. The DNS server address is also advertised. Therefore, issuing dig(1) in Host H should trigger DNS requests towards this DNS server. Note that the DNS service is not actually started and thus the host won't get a DNS reply. """ r = self.addRouter_v6('r') r.addDaemon(RADVD) h = self.addHost('h') dns = self.addHost('dns') self.addLink(r, h, params1={ "ip": ("2001:1341::1/64", "2001:2141::1/64"), "ra": [AdvPrefix("2001:1341::/64"), AdvPrefix("2001:2141::/64")], "rdnss": [AdvRDNSS("2001:89ab::d"), AdvRDNSS("2001:cdef::d")]}) self.addLink(r, dns, params1={"ip": ("2001:89ab::1/64", "2001:cdef::1/64")}, params2={"ip": ("2001:89ab::d/64", "2001:cdef::d/64")}) super(RouterAdvNet, self).build(*args, **kwargs)
def build(self, *args, **kwargs): """ +---+ +---+ +------------+ | H +-------+ R +-------+ DNS server | +---+ +---+ +------------+ Host H is attached to router R and gets its IPv6 addresses via Router Advertisements. The DNS server address is also advertised. Therefore, issuing dig(1) in Host H should trigger DNS requests towards this DNS server. Note that the DNS service is not actually started and thus the host won't get a DNS reply. """ r = self.addRouter_v6('r') r.addDaemon(RADVD) h = self.addHost('h') dns = self.addHost('dns') lrh = self.addLink(r, h) lrh[r].addParams(ip=("2001:1341::1/64", "2001:2141::1/64"), ra=[AdvConnectedPrefix()], rdnss=[AdvRDNSS(dns)]) lrdns = self.addLink(r, dns) lrdns[r].addParams(ip=("2001:89ab::1/64", "2001:cdef::1/64")) lrdns[dns].addParams(ip=("2001:89ab::d/64", "2001:cdef::d/64")) super(RouterAdvNet, self).build(*args, **kwargs)
net.start() assert_connectivity(net, v6=True) net.stop() finally: cleanup() @require_root @pytest.mark.parametrize("link_params,expected_cfg", [ ({"params1": {"ra": [AdvPrefix("2001:1341::/64", valid_lifetime=2000, preferred_lifetime=1000)]}}, [" prefix 2001:1341::/64", " AdvValidLifetime 2000;", " AdvPreferredLifetime 1000;"]), ({"params1": {"ra": [AdvPrefix("2001:1341::/64")], "rdnss": [AdvRDNSS("2001:89ab::d", max_lifetime=1000)]}}, [" RDNSS 2001:89ab::d {", " AdvRDNSSLifetime 1000; # in seconds (0 means invalid)"]) ]) def test_radvd_daemon_params(link_params, expected_cfg): try: net = IPNet(topo=CustomRouterAdvNet(link_params), use_v4=False, use_v6=True, allocate_IPs=False) net.start() # Check generated configuration with open("/tmp/radvd_r.cfg") as fileobj: cfg = fileobj.readlines() for line in expected_cfg: assert line + "\n" in cfg,\ "Cannot find the line '%s' in the generated" \