In this article, we would like to bridge a Mininet environments to the Internet.


The host OS in this article refers to the machine running Mininet. The simulated host in Mininet will be refered as Mininet host

  • You have a Mininet environment with OVS s1 and the default interface of the host OS is eth0
  • IP address of eth0 is

Problem Description

We could simply use ovs-vsctl add-port s1 eth0 to attach s1 to the Internet. However, the host OS will be disconnected immediately after you add eth0 to s1.


The host OS should use s1 instead of eth0 as its default gateway. That is, after adding eth0 to s1, we need to:

  1. Remove the IP configuration on eth0
  2. Add the IP address to s1
  3. Reconfigure default route of the host OS

This can be done by following commands:

# this will attach Mininet switch s1 to the Internet
ovs-vsctl add-port s1 eth0
ifconfig eth0 0
ip route del 0/0
ifconfig s1
ip route add 0/0 via dev s1
# this will dettach Mininet switch s1 from the Internet
ovs-vsctl del-port s1 eth0
ifconfig s1 0
ip route del 0/0
ifconfig eth0
ip route add 0/0 via dev eth0

If you are using Mininet through an SSH session, you need to finish these commands at once. Otherwise you will be disconnected during the process. This can be easily done by writing and using above-mentioned shell scripts.


Thank Ta-Ching Chen for the solution.