tc in Rocky
Introduction
Installation
yum install -y tc
Example
Let us ping the site topbicycle.ru
ping www.topbicycle.ru
PING www.topbicycle.ru (87.236.16.208) 56(84) bytes of data. 64 bytes from ssl.kirk.beget.com (87.236.16.208): icmp_seq=1 ttl=63 time=29.8 ms 64 bytes from ssl.kirk.beget.com (87.236.16.208): icmp_seq=2 ttl=63 time=35.3 ms 64 bytes from ssl.kirk.beget.com (87.236.16.208): icmp_seq=3 ttl=63 time=33.3 ms 64 bytes from ssl.kirk.beget.com (87.236.16.208): icmp_seq=4 ttl=63 time=41.0 ms
Ping comes back roughly every 30 ms
We need to find out which network interface is used to connect to the external internet.
This can be done using
iftop
or
nethogs
In this example the required interface is enp0s3
tc -s qdisc ls dev enp0s3
qdisc pfifo_fast 0: root refcnt 2 bands 3 priomap 1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1 Sent 278060 bytes 3193 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0
Let us set a delay of 100 ms
tc qdisc add dev enp0s3 root netem delay 100ms
Now if we run ping, the requests will go 100 ms slower
ping www.topbicycle.ru
PING www.topbicycle.ru (87.236.16.208) 56(84) bytes of data. 64 bytes from ssl.kirk.beget.com (87.236.16.208): icmp_seq=1 ttl=63 time=130 ms 64 bytes from ssl.kirk.beget.com (87.236.16.208): icmp_seq=2 ttl=63 time=129 ms 64 bytes from ssl.kirk.beget.com (87.236.16.208): icmp_seq=3 ttl=63 time=127 ms 64 bytes from ssl.kirk.beget.com (87.236.16.208): icmp_seq=4 ttl=63 time=126 ms
Article author: Andrei Olegovich