Mininet-3
Required Mounting Kit:
sudo apt-get install bridge utils
Basic instructions:
brctl addbr br0
New Bridge (Brctl = Bridge Control)
brctl addif br0 eth0
Add the current interface to the bridge (AddIf = add interface)
Topology diagram:
#!/usr/bin/env pythonfrom mininet.cli Import clifrom mininet.net import mininetfrom mininet.link Import Link,TCLinkif ' _ _main__ ' = = __name__: Net = mininet (link=tclink) h1 = Net.addhost (' H1 ', ip= "192.168.10.1/24", mac= "00:00:00:00:00:01") H2 = Net.addhost (' H2 ', ip= "192.168.10.2/24", mac= "00:00:00:00:00:02") h3 = Net.addhost (' h3 ', ip= "192.168.20.1/24", mac= " 00:00:00:00:00:03 ") R0 = Net.addhost (' r0 ') S0 = Net.addhost (' S0 ') net.addlink (H1,S0) net.addlink (H2,S0) Net.addlink (S0, R0) Net.addlink (R0,H3) net.build () R0.cmd ("Echo 1 >/proc/sys/net/ipv4/ip_forward") r0.cmd (' Ifconfig r0-eth0 192.168.10.254 netmask 255.255.255.0 ') r0.cmd (' ifconfig ro-eth1 192.168.20.254 netmask 255.255.255.0 ') h1.cmd ("IP route Add default via 192.168.10.254 dev H1-eth0 ") h2.cmd (" IP rotue add default via 192.168.10.254 dev H2-eth0 ") h3.cmd (" IP rout E add default via 192.168.20.254 dev H3-eth0 ") s0.cmd (" Brctl addbr br0 ") s0.cmd (" Brctl addif br0 s0-eth0 ") s0.cmd (" Brctl A Ddif br0 s0-eth1 ") s0.cmd (" Brctl addif br0S0-eth2 ") s0.cmd (" Ifconfig br0 Up ") CLI (NET) net.stop ()
Reminders
echo 1 > /proc/sys/net/ipv4/ip_forward
Start the routing feature
ip rotue add default via 192.168.10.254 dev h2-eth0
Setting up a default router
Execution results
xterm s0
Open the switch to see the br0 set above
Mininet (lightweight software defined network and test platform) III