Mininet (lightweight software defined network and test platform) III

Source: Internet
Author: User

Mininet-3

Required Mounting Kit:
sudo apt-get install bridge utils

Basic instructions:
brctl addbr br0New Bridge (Brctl = Bridge Control)
brctl addif br0 eth0Add 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

    1. echo 1 > /proc/sys/net/ipv4/ip_forwardStart the routing feature
    2. ip rotue add default via 192.168.10.254 dev h2-eth0Setting up a default router

Execution results

xterm s0Open the switch to see the br0 set above

Mininet (lightweight software defined network and test platform) III

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.