15
1. ETH=$1
2. LATENCY=$2
3. LOSS=$3
4. JITTER=$4
5. BW=$5
6. sudo /sbin/tc qdisc del dev eth0 root
7. sudo /sbin/tc qdisc add dev eth0 root handle 1: netem delay $LATENCY $JITTER 
8. sudo /sbin/tc qdisc add dev eth0 parent 1:1 handle 10: netem loss $LOSS
9. sudo /sbin/tc qdisc add dev eth0 parent 10:1 handle 20: htb default 1
10.sudo /sbin/tc class add dev eth0 parent 20: classid 0:1 htb rate $BW ceil $BW
11.sudo /sbin/tc qdisc show

The above code results in:

RTNETLINK answers :No such file or directory

error on line 8,9,10 upon execution.

3
  • 1
    duplicate of stackoverflow.com/questions/4803069/… ? Commented Apr 26, 2013 at 10:59
  • Have you tried using tc qdisc list to see what is in effect? This error sometimes means you are referring to a non-existent entry.
    – Neil
    Commented Nov 14, 2013 at 17:45
  • For anyone else who gets this on tc qdisc del dev ... and runs acress this question, the problem can also be that everything was already deleted.
    – Cel Skeggs
    Commented Jul 8, 2015 at 21:10

5 Answers 5

12

The problem is with missing kernel modules and/or kernel support. Make sure you can run

modprobe sch_netem

I also had to rebuild the kernel after I enabled because there's something built-in that is enabled after you enable network emulation.

See also http://forums.fedoraforum.org/showthread.php?t=285408 and http://www.linuxfoundation.org/collaborate/workgroups/networking/netem

3
  • 22
    BTW, in my case I was also getting a frustrating error that looks identical to this one. But I was trying to use tc qdisc change... when I meant to use tc qdisc add.... The error message is the same. Go figure. Commented Apr 26, 2013 at 15:27
  • 2
    I can run modprobe sch_netem command, it doesn't give any errors. Also lsmod | grep -i sch_netem returns sch_netem 17306 0. But still qdisk change command gives me error: RTNETLINK answers :No such file or directory Commented Aug 10, 2015 at 12:14
  • 1
    @DavidDombrowsky, thanks for spotting it, I was just trying the second example line from linuxfoundation.org/collaborate/workgroups/networking/netem, which "change"s instead of "add"ing. Commented Aug 31, 2015 at 23:33
6

RTNETLINK answers :No such file or directory comes for 2 reason.

  • Executing tc qdisc with wrong options
  • Or Kernel module sch_netem is missing

So check first sch_netem is installed in your machine by using command lsmod -l. If it is missing install using command modprobe sch_netem.

Even after installing sch_netem, if you get this same error means you are executing with wrong option. For example you can add a impairment on a network interface using ip qdisc add dev .... Similarly for removing this you can do ip qdisc delete dev.... If you are trying to delete an impairment without any prior add means, then also you get this error. And also for wrong options also you get this error.

1
  • 1
    I ran into this and a missing module was indeed the culprit. In my case I needed restart after kernel upgrade had cleared out all the modules for the kernel verison I was currently running (this was on raspbian).
    – morganwahl
    Commented Feb 23, 2019 at 17:37
2

Your handles and parent handles don't match. e.g change to:

7. sudo /sbin/tc qdisc add dev eth0 root handle 1:1 netem delay $LATENCY $JITTER 
8. sudo /sbin/tc qdisc add dev eth0 parent 1:1 handle 10:1 netem loss $LOSS
9. sudo /sbin/tc qdisc add dev eth0 parent 10:1 handle 20:1 htb default 1
10.sudo /sbin/tc class add dev eth0 parent 20:1 classid 0:1 htb rate $BW ceil $BW

and it should work.

0
2

I am running Fedora Core 27. In order to get the module installed, I had to use

sudo dnf install install kernel-modules-extra

That's not intuitively obvious.

1
  • Just want to add that it is yum install -y kernel-modules-extra on rhel8.
    – Qiang Xu
    Commented Apr 28 at 22:12
0

It's an old question, but the problem still occur, so.

To understand more about the problem you can check this link and this .

As a workaround to solve the problem, flush the interface config with :

Please read this before executing the command, you maybe locked when you are remotely connecting through the interface you are working on.

sudo ip addr flush dev eth0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.