Open vSwith analog gateway for interconnection between different subnets (1)
I. Tutorial Purpose
This experiment uses Mininet to build a subnet and make OVS a gateway to simulate intercommunication between subnets. In the experiment, let's take a look at the process of building a subnet in OVS.
OVS sets the gateway process.
OVS configures the stream table process.
2. Test preparation
We use Mininet to build the experiment environment. We recommend that you download the latest Mininet virtual machine from the Mininet official website. In this experiment, the virtual machine version is a mininet-2.2.1-150420-ubuntu-14.04-server-amd64 or install it by referring to the Native Installation from Source described in the official documentation.
The topology of the experiment is as follows:
Iii. Experiment steps
1. Build a network topology.
Our goal is to allow two hosts in different subnets to communicate with each other. We can first build two hosts and then set different subnets for the hosts. Because the Mininet virtual host belongs to 10.0.0.0/24 by default, you need to set the host network.
Note:
$> Indicates the Linux Command Line input. The permission is root.
Mininet> indicates the Mininet command line mode.
Create Topology
$> mn --topo single,2 --mac
Note:The mac parameter is used to create a host with a simpler MAC address and facilitate subsequent flow table creation.
Query status
mininet> dump
We can see that the default h1 and h2 are in the same network segment and can ping each other.
mininet> h1 ping h2PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.64 bytes from 10.0.0.2: icmp_seq=1 ttl=64 time=1.96 ms64 bytes from 10.0.0.2: icmp_seq=2 ttl=64 time=0.412 ms
Modify network settings
mininet> h1 ifconfig h1-eth0 10.0.0.1/24 netmask 255.0.0.0mininet> h2 ifconfig h2-eth0 20.0.0.1/24 netmask 255.0.0.0
The test network status is as follows:
mininet> h1 ping h2connect: Network is unreachable
As configured, h1 and h2 are no longer in the same network segment. When h1 is pinged to h2, the packet is forwarded to the gateway of the subnet. However, because no gateway is set for the two network segments in the current environment, the final state is inaccessible. In this case, we can set a gateway for the host.
Set Gateway
mininet> h1 route add default gw 10.0.0.254 h1-eth0mininet> h2 route add default gw 20.0.0.254 h2-eth0
The test network status is as follows:
mininet> h1 ping h2PING 20.0.0.1 (20.0.0.1) 56(84) bytes of data.From 10.0.0.1 icmp_seq=1 Destination Host UnreachableFrom 10.0.0.1 icmp_seq=2 Destination Host Unreachable