ipmininet.router.config package

This module holds the configuration generators for daemons that can be used in a router.

class ipmininet.router.config.BasicRouterConfig(node, daemons=(), additional_daemons=(), *args, **kwargs)

Bases: ipmininet.router.config.base.RouterConfig

A basic router that will run an OSPF daemon

A simple router made of at least an OSPF daemon

Parameters:additional_daemons – Other daemons that should be used
class ipmininet.router.config.NodeConfig(node, daemons=(), sysctl=None, *args, **kwargs)

Bases: object

This class manages a set of daemons, and generates the global configuration for a node

Initialize our config builder

Parameters:
  • node – The node for which this object will build configurations
  • daemons – an iterable of active routing daemons for this node
  • sysctl – A dictionnary of sysctl to set for this node. By default, it enables IPv4/IPv6 forwarding on all interfaces.
build()

Build the configuration for each daemon, then write the configuration files

cleanup()

Cleanup all temporary files for the daemons

daemon(key)

Return the Daemon object in this config for the given key

Parameters:key – the daemon name or a daemon class or instance
Returns:the Daemon object
Raises:KeyError – if not found
daemons
post_register_daemons()

Method called after all daemon classes were instantiated

register_daemon(cls, **daemon_opts)

Add a new daemon to this configuration

Parameters:
  • cls – Daemon class or object, or a 2-tuple (Daemon, dict)
  • daemon_opts – Options to set on the daemons
sysctl

Return an list of all sysctl to set on this node

class ipmininet.router.config.Zebra(*args, **kwargs)

Bases: ipmininet.router.config.zebra.QuaggaDaemon

KILL_PATTERNS = ('zebra',)
NAME = 'zebra'
PRIO = 0
STARTUP_LINE_EXTRA = '-k'
build()

Build the configuration tree for this daemon

Returns:ConfigDict-like object describing this configuration
has_started()

Return whether this daemon has started or not

listening()
set_defaults(defaults)
Parameters:
  • debug – the set of debug events that should be logged
  • access_lists – The set of AccessList to create, independently from the ones already included by route_maps
  • route_maps – The set of RouteMap to create
class ipmininet.router.config.OSPF(node, *args, **kwargs)

Bases: ipmininet.router.config.zebra.QuaggaDaemon

This class provides a simple configuration for an OSPF daemon. It advertizes one network per interface (the primary one), and set interfaces not facing another L3Router to passive

DEPENDS = (<class 'ipmininet.router.config.zebra.Zebra'>,)
KILL_PATTERNS = ('ospfd',)
NAME = 'ospfd'
build()

Build the configuration tree for this daemon

Returns:ConfigDict-like object describing this configuration
static is_active_interface(itf)

Return whether an interface is active or not for the OSPF daemon

set_defaults(defaults)
Parameters:
  • debug – the set of debug events that should be logged
  • dead_int – Dead interval timer
  • hello_int – Hello interval timer
  • priority – priority for the interface, used for DR election
  • redistribute – set of OSPFRedistributedRoute sources
class ipmininet.router.config.OSPF6(node, *args, **kwargs)

Bases: ipmininet.router.config.ospf.OSPF

This class provides a simple configuration for an OSPF6 daemon. It advertizes one network per interface (the primary one), and set interfaces not facing another L3Router to passive

DEAD_INT = 3
KILL_PATTERNS = ('ospf6d',)
NAME = 'ospf6d'
set_defaults(defaults)
Parameters:
  • debug – the set of debug events that should be logged
  • dead_int – Dead interval timer
  • hello_int – Hello interval timer
  • priority – priority for the interface, used for DR election
  • redistribute – set of OSPFRedistributedRoute sources
  • instance_id – the number of the attached OSPF instance
class ipmininet.router.config.OSPFArea(area, routers=(), links=(), **props)

Bases: ipmininet.overlay.Overlay

An overlay to group OSPF links and routers by area

Parameters:
  • area – the area for this overlay
  • routers – the set of routers for which all their interfaces belong to that area
  • links – individual links belonging to this area
apply(topo)

Apply the Overlay properties to the given topology

area
class ipmininet.router.config.BGP(node, port=179, *args, **kwargs)

Bases: ipmininet.router.config.zebra.QuaggaDaemon

This class provides the configuration skeletons for BGP routers.

DEPENDS = (<class 'ipmininet.router.config.zebra.Zebra'>,)
KILL_PATTERNS = ('bgpd',)
NAME = 'bgpd'
STARTUP_LINE_EXTRA

We add the port to the standard startup line

build()

Build the configuration tree for this daemon

Returns:ConfigDict-like object describing this configuration
build_access_list()

Build and return a list of acess_filter :return:

build_community_list()

Build and return a list of community_filter

build_route_map(neigbors)

Build and return a list of route map for the current node

classmethod get_config(topo, router, **kwargs)

Returns a config object for the daemon if any

set_defaults(defaults)
Parameters:
  • debug – the set of debug events that should be logged
  • address_families – The set of AddressFamily to use
class ipmininet.router.config.AS(asn, routers=(), **props)

Bases: ipmininet.overlay.Overlay

An overlay class that groups routers by AS number

Parameters:
  • asn – The number for this AS
  • routers – an initial set of routers to add to this AS
  • props – key-vals to set on all routers of this AS
asn
class ipmininet.router.config.iBGPFullMesh(asn, routers=(), **props)

Bases: ipmininet.router.config.bgp.AS

An overlay class to establish iBGP sessions in full mesh between BGP routers.

Parameters:
  • asn – The number for this AS
  • routers – an initial set of routers to add to this AS
  • props – key-vals to set on all routers of this AS
apply(topo)

Apply the Overlay properties to the given topology

ipmininet.router.config.bgp_peering(topo, a, b)

Register a BGP peering between two nodes

class ipmininet.router.config.RouterConfig(node, sysctl=None, *args, **kwargs)

Bases: ipmininet.router.config.base.NodeConfig

compute_routerid()

Computes the default router id for all daemons. If a router ids were explicitly set for some of its daemons, the router id set to the daemon with the highest priority is chosen as the global router id. Otherwise if it has IPv4 addresses, it returns the most-visible one among its router interfaces. If both conditions are wrong, it generates a unique router id.

static incr_last_routerid()
post_register_daemons()

Method called after all daemon classes were instantiated

ipmininet.router.config.bgp_fullmesh(topo, routers)

Establish a full-mesh set of BGP peerings between routers

Parameters:routers – The set of routers peering within each other
ipmininet.router.config.ebgp_session(topo, a, b, link_type=None)

Register an eBGP peering between two nodes, and disable IGP adjacencies between them.

Parameters:
  • topo – The current topology
  • a – Local router
  • b – Peer router
  • link_type – Can be set to SHARE or CLIENT_PROVIDER. In this case ebgp_session will create import and export filter and set local pref based on the link type
class ipmininet.router.config.CommunityList(name=None, action='permit', community=0)

Bases: object

A zebra community-list entry

Parameters:
  • name
  • action
  • community
count = 0
ipmininet.router.config.set_rr(topo, rr, peers=())

Set rr as route reflector for all router r

Parameters:
  • topo – The current topology
  • rr – The route reflector
  • peers – Clients of the route reflector
class ipmininet.router.config.AccessList(name=None, entries=())

Bases: object

A zebra access-list class. It contains a set of AccessListEntry, which describes all prefix belonging or not to this ACL

Setup a new access-list

Parameters:
  • name – The name of the acl, which will default to acl## where ## is the instance number
  • entries – A sequence of AccessListEntry instance, or of ip_interface which describes which prefixes are composing the ACL
count = 0
class ipmininet.router.config.IPTables(node, template_lookup=<mako.lookup.TemplateLookup object>, **kwargs)

Bases: ipmininet.router.config.base.Daemon

iptables: the default Linux firewall/ACL engine for IPv4. This is currently mainly a proxy class to generate a list of static rules to pass to iptables.

As such, see man iptables and man iptables-extensions to see the various table names, commands, pre-existing chains, …

Parameters:
  • node – The node for which we build the config
  • template_lookup – The TemplateLookup object of the template directory
  • kwargs – Pre-set options for the daemon, see defaults()
NAME = 'iptables'
build()

Build the configuration tree for this daemon

Returns:ConfigDict-like object describing this configuration
dry_run

The startup line to use to check that the daemon is well-configured

set_defaults(defaults)
Parameters:rules – The (ordered) list of iptables rules that should be executed. If a rule is an iterable of strings, these will be joined using a space.
startup_line

Return the corresponding startup_line for this daemon

class ipmininet.router.config.IP6Tables(node, template_lookup=<mako.lookup.TemplateLookup object>, **kwargs)

Bases: ipmininet.router.config.iptables.IPTables

The IPv6 counterpart to iptables …

Parameters:
  • node – The node for which we build the config
  • template_lookup – The TemplateLookup object of the template directory
  • kwargs – Pre-set options for the daemon, see defaults()
NAME = 'ip6tables'
class ipmininet.router.config.SSHd(node, template_lookup=<mako.lookup.TemplateLookup object>, **kwargs)

Bases: ipmininet.router.config.base.Daemon

Parameters:
  • node – The node for which we build the config
  • template_lookup – The TemplateLookup object of the template directory
  • kwargs – Pre-set options for the daemon, see defaults()
KILL_PATTERNS = ('None -D -u0',)
NAME = 'sshd'
STARTUP_LINE_BASE = 'None -D -u0'
build()

Build the configuration tree for this daemon

Returns:ConfigDict-like object describing this configuration
dry_run

The startup line to use to check that the daemon is well-configured

set_defaults(defaults)

Update defaults to contain the defaults specific to this daemon

startup_line

Return the corresponding startup_line for this daemon

class ipmininet.router.config.RADVD(node, template_lookup=<mako.lookup.TemplateLookup object>, **kwargs)

Bases: ipmininet.router.config.base.RouterDaemon

The class representing the radvd daemon, used for router advertisements

Parameters:
  • node – The node for which we build the config
  • template_lookup – The TemplateLookup object of the template directory
  • kwargs – Pre-set options for the daemon, see defaults()
KILL_PATTERNS = ('radvd',)
NAME = 'radvd'
build()

Build the configuration tree for this daemon

Returns:ConfigDict-like object describing this configuration
cleanup()

Cleanup the files belonging to this daemon

dry_run

The startup line to use to check that the daemon is well-configured

set_defaults(defaults)
Parameters:debuglevel – Turn on debugging information. Takes an integer between 0 and 5, where 0 completely turns off debugging, and 5 is extremely verbose. (see radvd(8) for more details)
startup_line

Return the corresponding startup_line for this daemon

class ipmininet.router.config.AdvPrefix(prefix=(), valid_lifetime=86400, preferred_lifetime=14400)

Bases: ipmininet.router.config.utils.ConfigDict

The class representing advertised prefixes in a Router Advertisement

Parameters:
  • prefix – the list of IPv6 prefixes to advertise
  • valid_lifetime – corresponds to the AdvValidLifetime in radvd.conf(5) for this prefix
  • preferred_lifetime – corresponds to the AdvPreferredLifetime in radvd.conf(5) for this prefix
class ipmininet.router.config.AdvConnectedPrefix(valid_lifetime=86400, preferred_lifetime=14400)

Bases: ipmininet.router.config.radvd.AdvPrefix

This class forces the advertisement of all prefixes on the interface

Parameters:
  • valid_lifetime – corresponds to the AdvValidLifetime in radvd.conf(5) for this prefix
  • preferred_lifetime – corresponds to the AdvPreferredLifetime in radvd.conf(5) for this prefix
class ipmininet.router.config.AdvRDNSS(node, max_lifetime=25)

Bases: ipmininet.router.config.utils.ConfigDict

The class representing an advertised DNS server in a Router Advertisement

Parameters:
  • node – Either the IPv6 address of the DNS server or the node name
  • max_lifetime – corresponds to the AdvValidLifetime in radvd.conf(5) for this dns server address
class ipmininet.router.config.PIMD(node, *args, **kwargs)

Bases: ipmininet.router.config.zebra.QuaggaDaemon

This class configures a PIM daemon to responds to IGMP queries in order to setup multicast routing in the network.

DEPENDS = (<class 'ipmininet.router.config.zebra.Zebra'>,)
KILL_PATTERNS = ('pimd',)
NAME = 'pimd'
build()

Build the configuration tree for this daemon

Returns:ConfigDict-like object describing this configuration
set_defaults(defaults)
Parameters:
  • debug – the set of debug events that should be logged
  • multicast_ssm – Enable pim ssm mode by default or not
  • multicast_igmp – Enable igmp by default or not
class ipmininet.router.config.RIPng(node, template_lookup=<mako.lookup.TemplateLookup object>, **kwargs)

Bases: ipmininet.router.config.zebra.QuaggaDaemon

This class provides a simple configuration for an RIP daemon. It advertizes one network per interface (the primary one), and set interfaces not facing another L3Router to passive

Parameters:
  • node – The node for which we build the config
  • template_lookup – The TemplateLookup object of the template directory
  • kwargs – Pre-set options for the daemon, see defaults()
DEPENDS = (<class 'ipmininet.router.config.zebra.Zebra'>,)
KILL_PATTERNS = ('ripngd',)
NAME = 'ripngd'
build()

Build the configuration tree for this daemon

Returns:ConfigDict-like object describing this configuration
static is_active_interface(itf)

Return whether an interface is active or not for the OSPF daemon

set_defaults(defaults)
Parameters:
  • debug – the set of debug events that should be logged (default: []).
  • redistribute – set of RIPngRedistributedRoute sources (default: []).
  • split_horizon – the daemon uses the split-horizon method (default: False).
  • split_horizon_with_poison – the daemon uses the split-horizon. with reversed poison method. If both split_horizon_with_poison and split_horizon are set to True, RIPng will use the split-horizon with reversed poison method (default: True).
  • update_timer – routing table timer value in second (default value:30).
  • timeout_timer – routing information timeout timer (default value:180).
  • garbage_timer – garbage collection timer (default value:120).
class ipmininet.router.config.STATIC(node, template_lookup=<mako.lookup.TemplateLookup object>, **kwargs)

Bases: ipmininet.router.config.zebra.QuaggaDaemon

Parameters:
  • node – The node for which we build the config
  • template_lookup – The TemplateLookup object of the template directory
  • kwargs – Pre-set options for the daemon, see defaults()
DEPENDS = (<class 'ipmininet.router.config.zebra.Zebra'>,)
KILL_PATTERNS = ('staticd',)
NAME = 'staticd'
build()

Build the configuration tree for this daemon

Returns:ConfigDict-like object describing this configuration
set_defaults(defaults)
Parameters:
  • debug – the set of debug events that should be logged
  • static_routes – The set of StaticRoute to create
class ipmininet.router.config.StaticRoute(prefix, nexthop, distance=1)

Bases: object

A class representing a static route

Parameters:
  • prefix – The prefix for this static route
  • nexthop – The nexthop for this prefix, one of: <IP address, interface name, null0, blackhole, reject>
  • distance – The distance metric of the route
class ipmininet.router.config.OpenrDaemon(node, template_lookup=<mako.lookup.TemplateLookup object>, **kwargs)

Bases: ipmininet.router.config.base.RouterDaemon

The base class for the OpenR daemon

Parameters:
  • node – The node for which we build the config
  • template_lookup – The TemplateLookup object of the template directory
  • kwargs – Pre-set options for the daemon, see defaults()
NAME = 'openr'
STARTUP_LINE_EXTRA
build()

Build the configuration tree for this daemon

Returns:ConfigDict-like object describing this configuration
dry_run

The OpenR dryrun runs the daemon and does not shutdown the daemon. As a workaround we only show the version of the openr daemon

set_defaults(defaults)
Parameters:
  • logfile – the path to the logfile for the daemon
  • routerid – the router id for this daemon
startup_line

Return the corresponding startup_line for this daemon

class ipmininet.router.config.Openr(node, *args, **kwargs)

Bases: ipmininet.router.config.openrd.OpenrDaemon

This class provides a simple configuration for an OpenR daemon.

DEPENDS = (<class 'ipmininet.router.config.openrd.OpenrDaemon'>,)
KILL_PATTERNS = ('openr',)
NAME = 'openr'
build()

Build the configuration tree for this daemon

Returns:ConfigDict-like object describing this configuration
static is_active_interface(itf)

Return whether an interface is active or not for the OpenR daemon

set_defaults(defaults)

Updates some options of the OpenR daemon to run a network of routers in mininet. For a full list of parameters see OpenrDaemon:_defaults in openrd.py

class ipmininet.router.config.OpenrDomain(domain, routers=(), links=(), **props)

Bases: ipmininet.overlay.Overlay

An overlay to group OpenR links and routers by domain

Parameters:
  • domain – the domain for this overlay
  • routers – the set of routers for which all their interfaces belong to that area
  • links – individual links belonging to this area
apply(topo)

Apply the Overlay properties to the given topology

domain
ipmininet.router.config.AF_INET(*args, **kwargs)

The ipv4 (unicast) address family

ipmininet.router.config.AF_INET6(*args, **kwargs)

The ipv6 (unicast) address family