Network

<< Back to wiki homepage

Table of contents:

Traffic shaping (tc)

Add delay to specific targets

1
2
3
4
5
6
7
8
#!/usr/bin/env sh
sudo tc qdisc del dev eth0 root # Ensure you start from a clean slate
sudo tc qdisc add dev eth0 root handle 1: prio
sudo tc qdisc add dev eth0 parent 1:3 handle 30: netem delay 15000ms # <-- Setting the delay here
sudo tc filter add dev eth0 protocol ip parent 1:0 prio 3 u32 \
   match ip dst ${SOME_IPV4_ADDRESS} flowid 1:3
sudo tc filter add dev eth0 protocol ip parent 1:0 prio 3 u32 \
   match ip6 dst ${SOME_IPV6_ADDRESS} flowid 1:3