# # sudo ifconfig dummy0 up # sudo tc qdisc del dev dummy0 root handle 1: prio sudo tc qdisc add dev dummy0 root handle 1: prio # All traffic originating from eth0 will be accounted # by the action sudo tc filter add dev dummy0 protocol ip pref 1 parent 1: \ u32 match u32 0 0 \ classid 1:1 indev eth0 \ action ok # # All traffic originating from lo will be accounted # by the action sudo tc filter add dev dummy0 protocol ip pref 2 parent 1: \ u32 match u32 0 0 \ classid 1:2 indev lo \ action ok #-- catch all if we screwed up --- sudo tc filter add dev dummy0 protocol ip pref 3 parent 1: \ u32 match u32 0 0 \ classid 1:3 \ action ok # # sudo tc qdisc del dev eth0 ingress sudo tc qdisc add dev eth0 ingress sudo tc qdisc del dev lo ingress sudo tc qdisc add dev lo ingress # sudo tc filter add dev lo parent ffff: protocol ip \ u32 match ip protocol 1 0xff \ flowid 1:1 \ action skbedit mark 1 \ action mirred egress mirror dev dummy0 # # sudo tc filter add dev eth0 parent ffff: protocol ip \ u32 match ip src 8.8.8.8/32 \ flowid 1:11 \ action skbedit mark 1 \ action mirred egress mirror dev dummy0 # ping -c 1 127.0.0.1 # ping -c 1 8.8.8.8 # Then lets make sure all stats are correct sudo tc -s actions ls action skbedit sudo tc -s actions ls action mirred sudo tc -s actions ls action gact sudo tc -s filter ls dev dummy0 parent 1: protocol ip sudo tc -s filter ls dev eth0 parent ffff: protocol ip sudo tc -s filter ls dev lo parent ffff: protocol ip # #