Add README and set up full topology with hosts for two-nodes

This commit is contained in:
Wojciech Kozlowski 2019-04-06 14:57:58 +02:00
parent c0d76aa9e2
commit e69abd1767
9 changed files with 111 additions and 23 deletions

37
two-nodes/README.md Normal file
View File

@ -0,0 +1,37 @@
# Two node topology
```
------ ------
| | | |
h1_1 ---|2 R1 1|------|1 R2 2|--- h2_1
| | | |
------ ------
```
## R1
Interface | Name | Address/Subnet
----------|---------|---------------
| lo | 10.0.0.1/32
1 | R1-eth1 | 10.0.1.1/24
2 | R1-eth2 | 10.1.0.254/24
## R2
Interface | Name | Address/Subnet
----------|---------|---------------
| lo | 10.0.0.2/32
1 | R2-eth1 | 10.0.1.2/24
2 | R2-eth2 | 10.2.0.254/24
## h1_1
Interface | Name | Address/Subnet
----------|-----------|---------------
| h1_1-eth1 | 10.1.0.1/24
## h2_1
Interface | Name | Address/Subnet
----------|-----------|---------------
| h2_1-eth1 | 10.2.0.1/24

View File

@ -25,31 +25,43 @@ def scenario():
os.system("rm -f /tmp/R*.log /tmp/R*.pid logs/*") os.system("rm -f /tmp/R*.log /tmp/R*.pid logs/*")
os.system("mn -c >/dev/null 2>&1") os.system("mn -c >/dev/null 2>&1")
os.system("killall -9 zebra > /dev/null 2>&1") os.system("killall -9 zebra staticd > /dev/null 2>&1")
net = Mininet(topo=NetTopo(), switch=Router) net = Mininet(topo=NetTopo(), switch=Router)
net.start() net.start()
for router in net.switches:
# Enable IP forwarding
router.cmd("sysctl -w net.ipv4.ip_forward=1")
router.waitOutput()
for node in net.switches:
# Start Zebra (routing table daemon) # Start Zebra (routing table daemon)
router.cmd("/usr/lib/frr/zebra" node.cmd("/usr/lib/frr/zebra"
" -f two-nodes/zebra/%s.conf" " -f two-nodes/zebra/%s.conf"
" -d" " -d"
" -i /tmp/zebra-%s.pid" " -i /tmp/%s-zebra.pid"
" > logs/%s-zebra 2>&1" " > /tmp/%s-zebra.out 2>&1"
% (router.name, router.name, router.name)) % (node.name, node.name, node.name))
router.waitOutput() node.waitOutput()
if node.name.startswith('h'):
# Start static route daemon
node.cmd("/usr/lib/frr/staticd"
" -f two-nodes/staticd/%s.conf"
" -d"
" -i /tmp/%s-staticd.pid"
" > /tmp/%s-staticd.out 2>&1"
% (node.name, node.name, node.name))
node.waitOutput()
if node.name.startswith('R'):
# Enable IP forwarding
node.cmd("sysctl -w net.ipv4.ip_forward=1")
node.waitOutput()
# Delete spare loopback address for convenience # Delete spare loopback address for convenience
router.cmd("ip addr del 127.0.0.1/8 dev lo") node.cmd("ip addr del 127.0.0.1/8 dev lo")
router.waitOutput() node.waitOutput()
CLI(net) CLI(net)
net.stop() net.stop()
os.system("killall -9 zebra") os.system("killall -9 zebra staticd")
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -0,0 +1,7 @@
! -*- zebra -*-
hostname h1_1
ip route 0.0.0.0/0 10.1.0.254
log file /tmp/h1_1-staticd.log

View File

@ -0,0 +1,7 @@
! -*- zebra -*-
hostname h2_1
ip route 0.0.0.0/0 10.2.0.254
log file /tmp/h2_1-staticd.log

View File

@ -11,12 +11,15 @@ class NetTopo(Topo):
# Add default members to class. # Add default members to class.
super(NetTopo, self).__init__() super(NetTopo, self).__init__()
# The topology has one router per AS # Add routers
r_1 = self.addSwitch('R1') r_1 = self.addSwitch('R1')
r_2 = self.addSwitch('R2') r_2 = self.addSwitch('R2')
# Setup the links as follows: # Add hosts
# h_1_1 = self.addSwitch('h1_1')
# R1 --- R2 h_2_1 = self.addSwitch('h2_1')
#
# Setup links as shown in README.md
self.addLink(r_1, r_2) self.addLink(r_1, r_2)
self.addLink(r_1, h_1_1)
self.addLink(r_2, h_2_1)

View File

@ -8,4 +8,7 @@ interface lo
interface R1-eth1 interface R1-eth1
ip address 10.0.1.1/24 ip address 10.0.1.1/24
log file /tmp/R1.log interface R1-eth2
ip address 10.1.0.254/24
log file /tmp/R1-zebra.log

View File

@ -8,4 +8,7 @@ interface lo
interface R2-eth1 interface R2-eth1
ip address 10.0.1.2/24 ip address 10.0.1.2/24
log file /tmp/R2.log interface R2-eth2
ip address 10.2.0.254/24
log file /tmp/R2-zebra.log

View File

@ -0,0 +1,8 @@
! -*- zebra -*-
hostname h1_1
interface h1_1-eth1
ip address 10.1.0.1/24
log file /tmp/h1_1-zebra.log

View File

@ -0,0 +1,8 @@
! -*- zebra -*-
hostname h2_1
interface h2_1-eth1
ip address 10.2.0.1/24
log file /tmp/h2_1-zebra.log