# persistent traffic control rules

## o5gmmob8

Hi all,

I have a script I run to configure my traffic control rules.  I was wondering if there is a better way I can write my rules so that they are persistent when my server reboots?  I can write an init script, but wanted to use an existing one if it was already there.

Walter

----------

## khayyam

walterw ...

these are iptables rules? Once the rules are added, save them and have them loaded at boot or the interface being brought up

```
# /etc/init.d/iptables save
```

You can then add iptables to the default runlevel or make them a dependency of net.${IFACE}

```
# rc-update add iptables default
```

or in /etc/conf.d/net

```
rc_need_eth0="iptables"

# or for openrc-0.10.x

#rc_net_eth0_need="iptables"

config_eth0="192.168.1.2/24"

[...]
```

HTH & best ... khay

----------

## o5gmmob8

Hi,

No, they are tc rules which are set per interface.  The only iptables rules I have are already part of iptables via iptables save.  I can only mark packets with iptables, I cannot control flow.

Walter

----------

## khayyam

walterw ...

sorry, what I ment to ask was are the rules intergrated with the iptables rules, so it seems they are seperate, good. OK, please see the qos.htb example provided in the Gentoo wiki QoS page.

You would then have iptables and qos.htb needed for net.${IFACE} ...

```
rc_need_eth0="iptables qos.htb"
```

best ... khay

----------

## o5gmmob8

Hi,

Thanks for your reply.  I have one like that ... I was looking for more of a standard package I could install to provide that init script so I could tweak it.  If I get around to it, I will create a project on github that will provide init scripts and an ebuild and then utilize some sort of configuration file(s).

Walter

----------

## frostschutz

There's htbinit and cbqinit, which do something similar I guess, but neither are particularly useful (or where is hfscinit)

The problem is that you can not use init scripts for traffic control really. This is because there are many cases with dynamic network devices (think ppp0), and traffic control rules are lost as such devices are created and removed. So this is very unlike an init script which is only started once (at boot time).

You really have to hook into the network device creation process itself, be it an if-up.d script or an udev rule or whatever it is that is actually notified as the device comes into existence.

----------

