mirror of
https://github.com/Wojtek242/route0.git
synced 2024-12-22 15:44:39 +01:00
Add README and set up full topology with hosts for two-nodes
This commit is contained in:
parent
c0d76aa9e2
commit
e69abd1767
37
two-nodes/README.md
Normal file
37
two-nodes/README.md
Normal 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
|
@ -25,31 +25,43 @@ def scenario():
|
||||
|
||||
os.system("rm -f /tmp/R*.log /tmp/R*.pid logs/*")
|
||||
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.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)
|
||||
router.cmd("/usr/lib/frr/zebra"
|
||||
" -f two-nodes/zebra/%s.conf"
|
||||
" -d"
|
||||
" -i /tmp/zebra-%s.pid"
|
||||
" > logs/%s-zebra 2>&1"
|
||||
% (router.name, router.name, router.name))
|
||||
router.waitOutput()
|
||||
node.cmd("/usr/lib/frr/zebra"
|
||||
" -f two-nodes/zebra/%s.conf"
|
||||
" -d"
|
||||
" -i /tmp/%s-zebra.pid"
|
||||
" > /tmp/%s-zebra.out 2>&1"
|
||||
% (node.name, node.name, node.name))
|
||||
node.waitOutput()
|
||||
|
||||
# Delete spare loopback address for convenience
|
||||
router.cmd("ip addr del 127.0.0.1/8 dev lo")
|
||||
router.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
|
||||
node.cmd("ip addr del 127.0.0.1/8 dev lo")
|
||||
node.waitOutput()
|
||||
|
||||
CLI(net)
|
||||
net.stop()
|
||||
os.system("killall -9 zebra")
|
||||
os.system("killall -9 zebra staticd")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
7
two-nodes/staticd/h1_1.conf
Normal file
7
two-nodes/staticd/h1_1.conf
Normal 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
|
7
two-nodes/staticd/h2_1.conf
Normal file
7
two-nodes/staticd/h2_1.conf
Normal 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
|
@ -11,12 +11,15 @@ class NetTopo(Topo):
|
||||
# Add default members to class.
|
||||
super(NetTopo, self).__init__()
|
||||
|
||||
# The topology has one router per AS
|
||||
# Add routers
|
||||
r_1 = self.addSwitch('R1')
|
||||
r_2 = self.addSwitch('R2')
|
||||
|
||||
# Setup the links as follows:
|
||||
#
|
||||
# R1 --- R2
|
||||
#
|
||||
# Add hosts
|
||||
h_1_1 = self.addSwitch('h1_1')
|
||||
h_2_1 = self.addSwitch('h2_1')
|
||||
|
||||
# Setup links as shown in README.md
|
||||
self.addLink(r_1, r_2)
|
||||
self.addLink(r_1, h_1_1)
|
||||
self.addLink(r_2, h_2_1)
|
||||
|
@ -8,4 +8,7 @@ interface lo
|
||||
interface R1-eth1
|
||||
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
|
@ -8,4 +8,7 @@ interface lo
|
||||
interface R2-eth1
|
||||
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
|
8
two-nodes/zebra/h1_1.conf
Normal file
8
two-nodes/zebra/h1_1.conf
Normal 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
|
8
two-nodes/zebra/h2_1.conf
Normal file
8
two-nodes/zebra/h2_1.conf
Normal 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
|
Loading…
Reference in New Issue
Block a user