Hozard
Hozard

Reputation: 195

How can I connect Open vSwitch port and virtual ethernet interface?

What I want to do is send a packet to the server through the Open vSwitch in bare metal PC, not on the VM.

For doing that, I'm thinking of following structure.

Server PC
 -----------------------------
|     ------                  |
|    |SERVER|                 |
|     ------                  |
|       |veth2 (192.168.0.152)|
|       |                     |
|       |veth1                |
|     -----------             |
|    | OVS (br0) |            |
|     -----------             |
|       |eth0 (192.168.0.157) |
 -------|---------------------
        |
 -------|--------
|   Client PC    |
 ----------------

For making above environment


, I did below commands.

  1. create ovs bridge
ovs-vsctl add-br br0
  1. make eth0 as a ovs port
ovs-vsctl add-port br0 eth0
  1. create veth link
ip link add veth1 type veth peer name veth2
ifconfig veth1 up
ifconfig veth2 up
  1. Finally, I set client ARP table statically because ovs port (eth0) cannot send ARP reply

After that, I tried to do TCP connection between client and server.

I checked that SYN packet of client is sent to veth2. However, server cannot receive that packet.

I cannot guess what is wrong and how I can make above environment.

Upvotes: 2

Views: 9280

Answers (1)

Hozard
Hozard

Reputation: 195

I found a solution.

By using a network namespace, I can make logical network stack.

http://man7.org/linux/man-pages/man8/ip-netns.8.html http://blog.scottlowe.org/2013/09/04/introducing-linux-network-namespaces/

  1. create ovs bridge
ovs-vsctl add-br br0
  1. make eth0 as a ovs port
ovs-vsctl add-port br0 eth0
  1. create veth link
ip link add veth1 type veth peer name veth2
  1. create a network namespace
ip netns add ns1
ip link set veth2 ns1
  1. set ip and mac of veth2 in ns1 as those of eth0

After doing that, I can get the below structure

Server PC
 -------------------------------
|     -----------------------   |
|    |          ns1          |  |
|    |   ------              |  |
|    |  |SERVER|             |  |
|    |   ------              |  |
|    | veth2|(192.168.0.157) |  |
|     -----------------------   |
|           |                   |
|           |                   |
|           |veth1              |
|       -----------             |
|      | OVS (br0) |            |
|       -----------             |
|       eth0|(192.168.0.157)    |
 -----------|-------------------
            |
      ------|--------
     |   Client PC   |
      ---------------

Upvotes: 6

Related Questions