Changing Link Quality on Linux Router

Article based on Ubuntu 16.04 on ESXi 6.5
Applications used: netem (pre-installed on Ubuntu 16.04)
Pre-req: Linux Router

Using the netem feature you can set latency, Jitter, and Packet loss on a specific link/interface. netem uses multiple features and changes multiple files at the same time, so the tc qdis command needs to be used for this (Read more here). 

These changes do not stay after a reboot, so you will have to save them in a rc.local script or in the /etc/network/interfaces or just run the command as needed. 

The command below will add an additional 100ms latency onto your link with a 20ms Jitter at a 10% random interval.

tc qdisc change dev ens192 root netem delay 100ms 20ms 10%

For more detailed information on use cases go to:


Create a basic Linux Router

Article is based on Ubuntu 16.04 built on ESXi 6.5

Linux Commands Used:

Create a Multi-NIC Virtual Machine

Configure all interfaces with Separate Networks

Set default route with a metric of 0 for the ‘WAN’ side NIC

Example Command:
sudo route add default gw metric 0

Set default route with metric of 1 point to the WAN NIC

Example Command:
sudo route add default gw metric 1

Set IPtable to NAT traffic to the WAN NIC IP (reference link

Example Command:
iptables -t nat -A POSTROUTING -o ens160 -j MASQUERADE

Set IPtables to allow forwarding

Example Command:

Set network to enable IP forwarding

Temporary command:
systctl -w net.ipv4.ip_forward=1

Permanent method:
– Go to /etc/sysctl.conf
– Uncomment the line for net.ipv4.ip_forward
– Change the value from 0 to 1
– then exit file and run command sysctl -p /etc/sysctl.conf
should show the change made

Test and make sure that a device behind one of the other Links is successfully going through the linux router, if need use tcpdump -i ens192 to look at all traffic flowing through the interface.