OvS-VLAN-Tap Interface-Router-on-stick

Get Open vSwitch/Virtualbox installed on your Ubuntu host

Issue this commands:

  • to create 4 virtual ports (tap0-3),
  • make them active, add OvS bridge SW,
  • make it active,
  • attach tap# to SW and add tag (vlan id) 10 to tap0-1 and 20 to tap2-3,
  • add interfaces (vlan10 and vlan20) set type internal,
  • set ip to vlan10 and to vlan20
  • make SW as trunk port

ip tuntap add name tap0 mode tap
ip tuntap add name tap1 mode tap
ip tuntap add name tap2 mode tap
ip tuntap add name tap3 mode tap
ip link set tap0 up
ip link set tap1 up
ip link set tap2 up
ip link set tap3 up

ovs-vsctl add-br SW
ip link set up dev SW

ovs-vsctl add-port SW tap0 tag=10
ovs-vsctl add-port SW tap1 tag=10
ovs-vsctl add-port SW tap2 tag=20
ovs-vsctl add-port SW tap3 tag=20

ovs-vsctl add-port SW vlan10 tag=10 — set interface vlan10 type=internal
ovs-vsctl add-port SW vlan20 tag=20 — set interface vlan20 type=internal

ip link set dev vlan10 up

ip link set dev vlan20 up
ifconfig vlan10 netmask
ifconfig vlan20 netmask

#ovs-vsctl set port SW trunks=10,20

#Don’t forget to enable IP forwarding at Ubuntu host

echo 1 > /proc/sys/net/ipv4/ip_forwarding

### note that what in blue is necessary when restart that you need to re-issue again or put them into startup script

Now let get two VMs (vm1 and vm2) running (in my case i will use linux core for virtualbox since it is small and just to test basic connection)

Attach vm1 to tap0 and vm2 to tap2 as a separate vlan.

To attach vm1 to tap0, at VirtualBox Manager setting –> go to Network adaptor –> click enable network adapter –> then choose Bridged adapter –> then select tap0

Then start both vm and configure some addressing. For now, I set vm1 with IP with gateway and vm2 with IP with gateway How to assign IP and gateway

Don’t forget to enable IP forwarding at Ubuntu host

echo 1 > /proc/sys/net/ipv4/ip_forwarding

with docker

Create new docker bridge ‘my-bridge’ and create container ‘test1’ attach to it

docker network create -d bridge my-bridge
docker run -d --name test1 --network my-bridge busybox sh -c "while true;do sleep 3600;done"

Attach container ‘test1’ to other docker bridge

docker network connect demo-bridge test1

Also, we can use docker network disconnect demo-bridge test1 to disconnect container test1from network demo-bridge



By vichhaiy Posted in OvS

Type Khmer Unicode on Microsoft Office Word on MacOS [Macbook]

I have spent a lot of time searching and trying and finally, I got an easy tip for you. It works for me and one friend of mine, so I hope it works for you too.

This is a quick video tutorial in Khmer (for you guy not Khmer, I have written a script where you can pause or just follow along with the movement).

[Fixed] Khmer font in Word on Mac

1. Install Khmer Unicode NiDA keyboard

Download and copy Khmer.keylayout to /Users/YourName/Library/Keyboard Layouts You may follow this guide

If you’re familiar with terminal, issue the following command to copy:

cp Where-You-Extra-To/Khmer.keylayout ~/Library/Keyboard\ Layouts/

Then, open “System Preferences“, search for “keyboard layouts“, click plus sign “+“, scroll down and select “Others“, you will see “NiDA Khmer“, select it and click “Add” and you’ve done!

2. Install more Khmer fonts

Download fonts here and extra it, then open “Font Bookwhere you can find by click on “Lauchpad” and search for “Font Book”, right click and choose “Add Fonts …” , browse to folder where you extracted your fonts to, select all, and click “Open” 


Note that some fonts will not display correctly, some of them I found work well are basically “Khmer OS …” font family. I would recommend you to select font before you start your typing 🙂

That’s it!!! Have fun!!! 🙂

Screen Shot 2018-01-03 at 3.11.51 PM

Guide to simple OvS config


We will not cover the VM part like what VM technology to use, how to attach VM1 to vmport1…

Below configure is to accomplish the above task:

#Install OvS
apt-get install openvswitch-switch
#Create a bridge name 'bridge0'
ovs-vsctl add-br bridge0
#Start 'bridge0'
ifconfig bridge0 up
#Attach 'bridge0' to physical interface 'eth0'
ovs-vsctl add-port bridge0 eth0
#Clear IP from 'eth0'
ifconfig eth0 0
#Set automatic address to 'bridge0'
dhclient bridge0
#Create two Linux tap interfaces 'vm1' and 'vm2'
ip tuntap add mode tap vm1
ip tuntap add mode tap vm2
#Start tap interfaces 
ifconfig vmport1 up
ifconfig vmport2 up
#Attach 'vm1' and 'vm2' to 'bridge0'
ovs-vsctl add-port bridge0 vm1
ovs-vsctl add-port bridge0 vm1
# service openvswitch-switch restart

Now you have two interfaces ‘vm1’ and ‘vm2’ available so that you can connect your VM to them. Enjoy!

By vichhaiy Posted in OvS

Build your first Dockerfile

You might experience getting your first docker container with a clean ‘ubuntu’ running without ‘vim or nslookup’ or even ‘ping’ command. So now you want the same fresh machine with those kinds of basic thing installed. Therefore, this tutorial is for you.

First, create a file name ‘Dockerfile’ anywhere you want and edit it as the following. [for this test purpose, I will install ‘vim net-tools iputils-ping’ packages only for my ubuntu image]

vim Dockerfile

FROM ubuntu
RUN apt-get update && apt-get install -y vim net-tools iputils-ping

Second, build your first docker image

docker build .

If it is successful, at the end you will see something like this

Successfully built 4d9a37b50b8b

Note the id 4d9a37b50b8b because you will use it as your based image for your docker container.

Now let run your first docker container for the just built image.

docker run -it -h myvm --name myvm 4d9a37b50b8b /bin/bash

Tata!!! success now, nice day 🙂

Docker container guide for newbies

This guide is for Docker CE (Community Edition) – support Linux container only


Get started with example:

Using docker search, pull, images, create, ps, start, exec

$ docker search ubuntu
$ docker pull ubuntu
$ docker images
$ docker create -it ubuntu /bin/bash
$ docker ps -a (copy the name)
$ docker start some_name; docker attach some_name

or if you don’t want to change to your favorite name:

$ docker rename some_name your_favorite_name
$ docker startyour_favorite_name; docker attach your_favorite_name

If you want to run from another terminal to access the same container machine:

$ docker exec -it your_favorite_name /bin/bash

Till now, if you look at your docker container shell, you will see that it comes with some random name and weird hostname. Now, let start it with an appropriate name:

$ docker create -it -h myubuntu --name=ubuntu_container ubuntu /bin/bash

If you want at the same time to automatically download image (if not exist locally), a create container and run it, you can issue this:

$ docker run -it -h myubuntu --name=ubuntu_container ubuntu /bin/bash

For all cases, it’s always a root user, so you might want to run as other user and use sudo to install or run things, when you get into docker shell as root, then do these:

# apt update
# apt install sudo vim -y
# useradd ubuntu -m
# passwd ubuntu
# vim /etc/sudoers
ubuntu  ALL=(ALL:ALL) ALL #Add this line

Now you should be able to su ubuntu and use sudo to do thing as root privilege

For docker networking stuff, I’ll do it in the next post 🙂

By vichhaiy Posted in docker