Last active
November 11, 2021 17:01
-
-
Save rodrigosoares/53ca13f0376ade1fa7b7221328dae3ce to your computer and use it in GitHub Desktop.
Mininet/Mininext network in Python with BGP instance configurations in Quagga DSL.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hostname h1 | |
password routeflow | |
enable password routeflow | |
! | |
router bgp 1000 | |
bgp router-id 172.31.1.100 | |
network 172.10.0.0/16 | |
neighbor 172.36.1.2 remote-as 6000 | |
neighbor 172.37.1.2 remote-as 7000 | |
neighbor 172.31.1.1 remote-as 1 | |
! | |
log file /home/mininet/mininet/custom/configs/h1/bgpd.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hostname h2 | |
password routeflow | |
enable password routeflow | |
! | |
router bgp 2000 | |
bgp router-id 172.31.2.100 | |
network 172.20.0.0/16 | |
neighbor 172.32.1.2 remote-as 5000 | |
neighbor 172.31.2.1 remote-as 1 | |
! | |
log file /home/mininet/mininet/custom/configs/h2/bgpd.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hostname h3 | |
password routeflow | |
enable password routeflow | |
! | |
router bgp 3000 | |
bgp router-id 172.31.3.100 | |
network 172.30.0.0/16 | |
neighbor 172.31.3.1 remote-as 1 | |
! | |
log file /home/mininet/mininet/custom/configs/h3/bgpd.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hostname h4 | |
password routeflow | |
enable password routeflow | |
! | |
router bgp 4000 | |
bgp router-id 172.31.4.100 | |
network 172.40.0.0/16 | |
neighbor 172.33.1.2 remote-as 5000 | |
neighbor 172.31.4.1 remote-as 1 | |
! | |
log file /home/mininet/mininet/custom/configs/h4/bgpd.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hostname h5 | |
password routeflow | |
enable password routeflow | |
! | |
router bgp 5000 | |
bgp router-id 172.50.1.100 | |
network 172.50.0.0/16 | |
neighbor 172.32.1.1 remote-as 2000 | |
neighbor 172.32.1.1 next-hop-self | |
neighbor 172.33.1.1 remote-as 4000 | |
neighbor 172.33.1.1 next-hop-self | |
! | |
log file /home/mininet/mininet/custom/configs/h5/bgpd.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hostname h6 | |
password routeflow | |
enable password routeflow | |
! | |
router bgp 6000 | |
bgp router-id 172.60.1.100 | |
network 172.60.0.0/16 | |
neighbor 172.36.1.1 remote-as 1000 | |
neighbor 172.36.1.1 next-hop-self | |
! | |
log file /home/mininet/mininet/custom/configs/h6/bgpd.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hostname h7 | |
password routeflow | |
enable password routeflow | |
! | |
router bgp 7000 | |
bgp router-id 172.70.1.100 | |
network 172.70.0.0/16 | |
neighbor 172.37.1.1 remote-as 1000 | |
neighbor 172.37.1.1 next-hop-self | |
! | |
log file /home/mininet/mininet/custom/configs/h7/bgpd.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
h1 route add default gw 172.31.1.1 | |
h2 route add default gw 172.31.2.1 | |
h3 route add default gw 172.31.3.1 | |
h4 route add default gw 172.31.4.1 | |
h2 ip addr add 172.32.1.1/30 brd + dev h2-eth1 | |
h5 ip addr add 172.32.1.2/30 brd + dev h5-eth0 | |
h4 ip addr add 172.33.1.1/30 brd + dev h4-eth1 | |
h5 ip addr add 172.33.1.2/30 brd + dev h5-eth1 | |
h2 /etc/init.d/quagga restart | |
h4 /etc/init.d/quagga restart | |
h5 /etc/init.d/quagga restart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
h1 route add default gw 172.31.1.1 | |
h2 route add default gw 172.31.2.1 | |
h3 route add default gw 172.31.3.1 | |
h4 route add default gw 172.31.4.1 | |
h2 ip addr add 172.32.1.1/30 brd + dev h2-eth1 | |
h5 ip addr add 172.32.1.2/30 brd + dev h5-eth0 | |
h4 ip addr add 172.33.1.1/30 brd + dev h4-eth1 | |
h5 ip addr add 172.33.1.2/30 brd + dev h5-eth1 | |
h1 ip addr add 172.36.1.1/30 brd + dev h1-eth1 | |
h6 ip addr add 172.36.1.2/30 brd + dev h6-eth0 | |
h1 ip addr add 172.37.1.1/30 brd + dev h1-eth2 | |
h7 ip addr add 172.37.1.2/30 brd + dev h7-eth0 | |
h1 /etc/init.d/quagga restart | |
h2 /etc/init.d/quagga restart | |
h3 /etc/init.d/quagga restart | |
h4 /etc/init.d/quagga restart | |
h5 /etc/init.d/quagga restart | |
h6 /etc/init.d/quagga restart | |
h7 /etc/init.d/quagga restart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hostname sA | |
password routeflow | |
enable password routeflow | |
! | |
router bgp 1 | |
bgp router-id 172.31.1.1 | |
neighbor 172.31.1.100 remote-as 1000 | |
! | |
log file /var/log/quagga/bgpd.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hostname sB | |
password routeflow | |
enable password routeflow | |
! | |
router bgp 1 | |
bgp router-id 172.31.2.1 | |
neighbor 172.31.2.100 remote-as 2000 | |
! | |
log file /var/log/quagga/bgpd.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hostname sC | |
password routeflow | |
enable password routeflow | |
! | |
router bgp 1 | |
bgp router-id 172.31.3.1 | |
neighbor 172.31.3.100 remote-as 3000 | |
! | |
log file /var/log/quagga/bgpd.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hostname sD | |
password routeflow | |
enable password routeflow | |
! | |
router bgp 1 | |
bgp router-id 172.31.4.1 | |
neighbor 172.31.4.100 remote-as 4000 | |
! | |
log file /var/log/quagga/bgpd.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" rftest_hvx topology | |
author: Rodrigo Soares (rodrigosoares@id.uff.br) | |
Four switches connected in mesh topology plus a host for each switch. | |
A fifth host is connected to two of them. Each host is intended to run | |
a Quagga instance as if each was a different AS. | |
h1 --- sA ---- sB --- h2 | |
| \ | \ | |
| \ | \ | |
| \ | h5 | |
| \ | / | |
| \ | / | |
h3 --- sC ---- sD --- h4 | |
Since switch nomenclature changes depending on the part of the whole | |
system, the following naming association is valid. | |
sA = s5 = rfvmA | |
sB = s6 = rfvmB | |
sC = s7 = rfvmC | |
sD = s8 = rfvmD | |
""" | |
import inspect | |
import os | |
from mininext.topo import Topo | |
from mininext.services.quagga import QuaggaService | |
from collections import namedtuple | |
QuaggaHost = namedtuple('QuaggaHost', 'name ip lo gw') | |
class rftest_hvx(Topo): | |
'RouteFlow demo setup with Havox support for Mininext' | |
def __init__(self): | |
Topo.__init__(self) | |
self_path = os.path.dirname(os.path.abspath( | |
inspect.getfile(inspect.currentframe()) | |
)) | |
quagga_svc = QuaggaService(autoStop=False) | |
quagga_base_config_path = self_path + '/configs/' | |
quagga_hosts = [] | |
quagga_hosts.append(QuaggaHost(name='h1', | |
ip='172.31.1.100/24', | |
lo='10.0.1.1/24', | |
gw='gw 172.31.1.1')) | |
quagga_hosts.append(QuaggaHost(name='h2', | |
ip='172.31.2.100/24', | |
lo='10.0.2.1/24', | |
gw='gw 172.31.2.1')) | |
quagga_hosts.append(QuaggaHost(name='h3', | |
ip='172.31.3.100/24', | |
lo='10.0.3.1/24', | |
gw='gw 172.31.3.1')) | |
quagga_hosts.append(QuaggaHost(name='h4', | |
ip='172.31.4.100/24', | |
lo='10.0.4.1/24', | |
gw='gw 172.31.4.1')) | |
quagga_hosts.append(QuaggaHost(name='h5', | |
ip='172.32.1.2/30', | |
lo='10.0.5.1/24', | |
gw='gw 172.32.1.1')) | |
hosts = {} | |
for host in quagga_hosts: | |
quagga_container = self.addHost(name=host.name, | |
ip=host.ip, | |
defaultRoute=host.gw, | |
hostname=host.name, | |
privateLogDir=True, | |
privateRunDir=True, | |
inMountNamespace=True, | |
inPIDNamespace=True, | |
inUTSNamespace=True) | |
hosts[host.name] = quagga_container | |
self.addNodeLoopbackIntf(node=host.name, ip=host.lo) | |
quagga_svc_config = \ | |
{'quaggaConfigPath': quagga_base_config_path + host.name} | |
self.addNodeService(node=host.name, service=quagga_svc, | |
nodeConfig=quagga_svc_config) | |
sA = self.addSwitch('s5') | |
sB = self.addSwitch('s6') | |
sC = self.addSwitch('s7') | |
sD = self.addSwitch('s8') | |
self.addLink(hosts['h1'], sA) | |
self.addLink(hosts['h2'], sB) | |
self.addLink(hosts['h3'], sC) | |
self.addLink(hosts['h4'], sD) | |
self.addLink(sA, sB) | |
self.addLink(sB, sD) | |
self.addLink(sD, sC) | |
self.addLink(sC, sA) | |
self.addLink(sA, sD) | |
self.addLink(hosts['h2'], hosts['h5'], 1, 0) | |
self.addLink(hosts['h4'], hosts['h5'], 1, 1) | |
topos = {'rftest_hvx': (lambda: rftest_hvx())} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" rftest_hvx topology | |
author: Rodrigo Soares (rodrigosoares@id.uff.br) | |
Four switches connected in mesh topology plus a host for each switch. | |
A fifth host is connected to h2 and h4 and two more hosts are connected to h1. | |
Each host is intended to run a Quagga instance as if each was a different AS. | |
h6 | |
\ | |
h1 --- sA ---- sB --- h2 | |
/ | \ | \ | |
h7 | \ | \ | |
| \ | h5 | |
| \ | / | |
| \ | / | |
h3 --- sC ---- sD --- h4 | |
AS 1 (main) = sA, sB, sC and sD | |
AS 1000 = h1 | |
AS 2000 = h2 | |
AS 3000 = h3 | |
AS 4000 = h4 | |
AS 5000 = h5 | |
AS 6000 = h6 | |
AS 7000 = h7 | |
""" | |
import inspect | |
import os | |
from mininext.topo import Topo | |
from mininext.services.quagga import QuaggaService | |
from collections import namedtuple | |
QuaggaHost = namedtuple('QuaggaHost', 'name ip lo gw') | |
class rftest_hvx(Topo): | |
'RouteFlow demo setup with Havox support for Mininext' | |
def __init__(self): | |
Topo.__init__(self) | |
self_path = os.path.dirname(os.path.abspath( | |
inspect.getfile(inspect.currentframe()) | |
)) | |
quagga_svc = QuaggaService(autoStop=False) | |
quagga_base_config_path = self_path + '/configs/' | |
quagga_hosts = [] | |
quagga_hosts.append(QuaggaHost(name='h1', | |
ip='172.31.1.100/24', | |
lo='10.0.1.1/24', | |
gw='gw 172.31.1.1')) | |
quagga_hosts.append(QuaggaHost(name='h2', | |
ip='172.31.2.100/24', | |
lo='10.0.2.1/24', | |
gw='gw 172.31.2.1')) | |
quagga_hosts.append(QuaggaHost(name='h3', | |
ip='172.31.3.100/24', | |
lo='10.0.3.1/24', | |
gw='gw 172.31.3.1')) | |
quagga_hosts.append(QuaggaHost(name='h4', | |
ip='172.31.4.100/24', | |
lo='10.0.4.1/24', | |
gw='gw 172.31.4.1')) | |
quagga_hosts.append(QuaggaHost(name='h5', | |
ip='172.32.1.2/30', | |
lo='10.0.5.1/24', | |
gw='gw 172.32.1.1')) | |
quagga_hosts.append(QuaggaHost(name='h6', | |
ip='172.36.1.2/30', | |
lo='10.0.6.1/24', | |
gw='gw 172.36.1.1')) | |
quagga_hosts.append(QuaggaHost(name='h7', | |
ip='172.37.1.2/30', | |
lo='10.0.7.1/24', | |
gw='gw 172.37.1.1')) | |
hosts = {} | |
for host in quagga_hosts: | |
quagga_container = self.addHost(name=host.name, | |
ip=host.ip, | |
defaultRoute=host.gw, | |
hostname=host.name, | |
privateLogDir=True, | |
privateRunDir=True, | |
inMountNamespace=True, | |
inPIDNamespace=True, | |
inUTSNamespace=True) | |
hosts[host.name] = quagga_container | |
self.addNodeLoopbackIntf(node=host.name, ip=host.lo) | |
quagga_svc_config = \ | |
{'quaggaConfigPath': quagga_base_config_path + host.name} | |
self.addNodeService(node=host.name, service=quagga_svc, | |
nodeConfig=quagga_svc_config) | |
sA = self.addSwitch('s5') | |
sB = self.addSwitch('s6') | |
sC = self.addSwitch('s7') | |
sD = self.addSwitch('s8') | |
self.addLink(hosts['h1'], sA) | |
self.addLink(hosts['h2'], sB) | |
self.addLink(hosts['h3'], sC) | |
self.addLink(hosts['h4'], sD) | |
self.addLink(sA, sB) | |
self.addLink(sB, sD) | |
self.addLink(sD, sC) | |
self.addLink(sC, sA) | |
self.addLink(sA, sD) | |
self.addLink(hosts['h2'], hosts['h5'], 1, 0) | |
self.addLink(hosts['h4'], hosts['h5'], 1, 1) | |
self.addLink(hosts['h1'], hosts['h6'], 1, 0) | |
self.addLink(hosts['h1'], hosts['h7'], 2, 0) | |
topos = {'rftest_hvx': (lambda: rftest_hvx())} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment