Mar 3, 2025

Open vSwitch: Create TunTap Devices

Learn how to create TunTap devices using Open vSwitch on Ubuntu 20.04. Set up bridges, assign static IPs, and configure NAT for internet access.

Author

Faiz Ahmed FarooquiPrincipal Technical Consultant.
Open vSwitch: Create TunTap Devices

Open vSwitch (OVS) is a multi-layer software switch designed to enable massive network automation and programmability while providing support for standard management protocols.

Apart from its extensive feature set, one of the key advantages of OVS is its support for networking tunnelling protocols, a use case that is widely employed in software-defined networking (SDN) deployments.

In this regard, we will introduce you to the Tun/Tap network devices, which are a key feature of the Linux kernel and are used for creating network bridges. Specifically, this article will guide you on how to create TunTap devices using an Open vSwitch (OVS) bridge and allocate static IPs to the virtual ports.

Creating TunTap Devices

TunTap devices are software network interfaces provided by the Linux kernel. They can be created and managed just like physical network interfaces.

ovs-vsctl add-br br0

Create Network Interface

ovs-vsctl add-port br0 vSwitch0
ovs-vstl set Interface vSwitch0 type=internal

We have two commands above, the first command adds vSwitch0 to the br0 bridge and the second command sets internal type to the vSwitch0 interface.

Add the Physical Network Interface to the Bridge

ovs-vsctl add-port br0 eno1

Traffic will now flow between the physical network interface and the Open vSwitch bridge. Remember to change eno1 with your Physical Network Interface.

Create TunTap device

ip tuntap add mode tap vport0

Attach TunTap to Bridge

ovs-vsctl add-port br0 vport0

You should now have a tap device called vport0 which is part of the br0 OVS bridge.

Allocating Static IP Addresses

Static IP addressing, as opposed to dynamic addressing, is when a device keeps the same IP address every time it connects to the network.

Assign Gateway IP to Bridge's Internal Switch

To assign a Gateway IP address to internal Switch, perform the following steps:

ip addr add 172.168.1.1/24 dev vSwitch0

/24 is a netmask.

Assign Static IP to TunTap device

To assign a static IP address to your newly created vport0 interface, perform the following steps:

Remove the current IP from the device (if any):

ip addr flush dev vport0

Now, you can assign a new IP address. The following command will assign IP 172.168.1.100 to vport0:

ip addr add 172.168.1.100 dev vport0

Up all the Interfaces and TunTaps

ip link set dev vSwitch0 up
ip link set dev vport0 up

These two commands will up all your interfaces. You can verify the same by running ifconfig command.

IP Forwarding & NAT Configuration

Enable IP Forwarding on the Host

IP forwarding is the ability for an operating system to accept incoming network packets on one interface, recognize that it is not meant for the system itself, but that it should be passed on to another network, and then forwards it accordingly.

echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward

Make NAT Configuration for Internt Access

You can use a NAT device to allow resources in private subnets to connect to the internet, other VPCs, or on-premises networks. These instances can communicate with services outside the VPC, but they cannot receive unsolicited connection requests.

iptables -t nat -A POSTROUTING -o eno1 -j MASQUERAGE
iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i vSwitch0 -o eno1 -j ACCEPT

Traffic will now flow between the physical network interface and the Open vSwitch bridge. Remember to change eno1 with your Physical Network Interface.

Conclusion

This guide has walked you through the process of creating TunTap devices using OVS bridge and assigning static IPs to the virtual ports on Ubuntu 20.04.

With this knowledge, you can effectively set up and manage virtual network interfaces in your environment.

Please remember that, as with all things, practice furthers understanding. So, feel free to experiment with different configurations to fully comprehend the flexible nature of Open vSwitch.

Stay tuned for more insightful articles on advanced networking with Open vSwitch!

Source: This blog is authored by Faiz Ahmed, Principal Technical Consultant at GeekyAnts. Originally published on Hashnode: Read here.

Subscribe to Our Newsletter

RELATED ARTICLES

More from the engineering frontline.

Dive deep into our research and insights on design, development, and the impact of various trends to businesses.
The Bug That Doesn't Show Up in Code Review: Why Your Flutter Web App Reloads on Safari
The Bug That Doesn't Show Up in Code Review: Why Your Flutter Web App Reloads on Safari
A real-world look at how oversized images can trigger Safari reloads and iOS crashes in Flutter apps and how smarter image decoding prevents them.
From Prompting to Process: What Changed When Flutter Shipped Agent Skills
From Prompting to Process: What Changed When Flutter Shipped Agent Skills
This blog explores how Flutter Agent Skills improve AI-assisted development by combining official framework workflows with project-specific guidance for more consistent development.
Why Everything Your AI Builds Looks the Same
Why Everything Your AI Builds Looks the Same
This blog explores why AI-generated interfaces often look alike and explains how design systems, product context, and reusable engineering practices help teams build distinctive, scalable
How We Built the Missing Bridge from Code to Figma
Technology

Jul 10, 2026

How We Built the Missing Bridge from Code to Figma
This blog explores how AI-generated React apps get turned into fully editable, designer-ready Figma files by reading React Fiber instead of the DOM.
Building a Resilient Hybrid-Cloud Network with WireGuard HA, Route-Based Failover, and Deep Observability
Technology

Jun 27, 2026

Building a Resilient Hybrid-Cloud Network with WireGuard HA, Route-Based Failover, and Deep Observability
A practical breakdown of building resilient AWS-to-on-premises connectivity with WireGuard HA, active-standby failover, and deep packet-forwarding observability.
We Built a 114-Second AWS-to-Azure Failover. Here’s What We Learned
Technology

Jun 19, 2026

We Built a 114-Second AWS-to-Azure Failover. Here’s What We Learned
A practical guide to building a 114-second multi-cloud disaster recovery failover between AWS and Azure — what we built, what broke, and what we learned.
Cloud-Native and Cloud-Agnostic Are Not Ideologies; They Are Business-Stage Decisions
Technology

Jun 12, 2026

Cloud-Native and Cloud-Agnostic Are Not Ideologies; They Are Business-Stage Decisions
This blog explains how organizations can balance speed, scalability, and operational flexibility as they grow from startup to enterprise scale.

The Right Conversation Can Save You Six Months.

Whether you’re navigating AI adoption, modernizing legacy systems, or scaling a product - we start by listening. No pitch deck. No template. A real conversation.

Open vSwitch: Create TunTap Devices for Virtual Networking - GeekyAnts