How to delay some localhost traffic? (the computer is a VM, but hopefully that won't matter)
The following creates a new interface and tries to apply tc to it:
ifconfig lo:1 127.0.10.10 netmask 255.0.0.0 up
tc qdisk add dev lo:1 root netem delay 200ms
This also limited traffic for the normal loopback interface:
$ ping 127.0.0.1
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=400 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=400 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=400 ms
The same delay appeared for 127.0.10.10 and when pinging the device's IP address.
How to delay only a part of localhost traffic? (f.ex. to a specific IP address?)
UPDATE: Removing the tc qdisk, creating a new interface using ip link add link lo name lo30 type dummy and setting tc on it did not delay any traffic. Seems like all traffic to the local computer is automatically routed to lo.