I am trying to add tc delay packets and bandwidth limit at the same time.
I am thinking can I create multiple virtual network interfaces.
Each virtual network interface would set up one tc qdisc.
But all virtual network interface are the same physical network interface.
Then use ip route routing specific packets to corresponding virtual network interface. Does this structure work ?

I have tried to create virtual network interface but the tc qdisc cannot applied to it.

Thanks for comments.
I have try the solution, but it seems not working for me.
Here is how I tried.

  1. create virtual network interface:

    ip link add link enp0s5 address 56:8A:C0:DD:EE:FF enp0s5.1 type macvlan  
  2. Then run this com ifconfig command:

    ifconfig enp0s5.1 up 
  3. Then run this dhclient command:

    dhclient -v enp0s5.1 

This one is not work for me. Terminal show dhcp and not end the command.
I skipped this.

Then I set up ip route.
$sudo ip route add dev enp0s5.1 is the dst ip address that I want only it sent through virtual network interface to control by tc.

I used tcptrack and found all traffic still went through physical network interface.

Here is my ifconfig

enp0s5    Link encap:Ethernet  HWaddr 00:1c:42:2f:75:56  
          inet addr:  Bcast:  Mask:
          inet6 addr: fe80::2994:3656:3407:9cf1/64 Scope:Link
          inet6 addr: fdb2:2c26:f4e4:0:c84c:b67:c978:3de7/64 Scope:Global
          inet6 addr: fdb2:2c26:f4e4:0:6eef:484:8d65:5d/64 Scope:Global
          RX packets:7325 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6735 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:8443267 (8.4 MB)  TX bytes:518369 (518.3 KB)

enp0s5.1  Link encap:Ethernet  HWaddr 4a:cc:7f:d5:1c:d2  
          inet6 addr: fdb2:2c26:f4e4:0:48cc:7fff:fed5:1cd2/64 Scope:Global
          inet6 addr: fdb2:2c26:f4e4:0:5166:3a98:1373:6ac6/64 Scope:Global
          inet6 addr: fdb2:2c26:f4e4:0:ea16:54e8:230a:f374/64 Scope:Global
          inet6 addr: fdb2:2c26:f4e4:0:9c67:9a60:6408:a301/64 Scope:Global
          inet6 addr: fe80::48cc:7fff:fed5:1cd2/64 Scope:Link
          RX packets:102 errors:0 dropped:0 overruns:0 frame:0
          TX packets:129 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1 
          RX bytes:10407 (10.4 KB)  TX bytes:15425 (15.4 KB)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.