View previous topic :: View next topic |
Author |
Message |
ycUygB1 Apprentice
Joined: 27 Jul 2005 Posts: 276 Location: Portland, Oregon
|
Posted: Sat Sep 13, 2014 6:48 am Post subject: [SOLVED] Where to put network post-start commands? |
|
|
My ISP has requested that I limit my traffic to 150 mbps, so I executed this command.
Code: | tc qdisc add dev eno1 root tbf rate 150mbit latency 50ms burst 15mb |
The command works fine and the resulting traffic is now flat at 150 mbps. Now I want to
make sure that it is executed every time I restart networking.
My question: In what file should I put such a command? All the Gentoo networking docs I have
found are tutorials that don't mention post_start commands. Reading net.lo, there
is some mention of post_start, but it is not documented that I could see.
The only thing I found by trawling the internet was from lartc.org, where they say:
Quote: | 15.10.4. Making all of the above start at boot
It sure can be done in many ways. In mine, I have a shell script in /etc/init.d/packetfilter that accepts [start | stop | stop-tables | start-tables | reload-tables] it configures qdiscs and loads needed kernel modules, so it behaves much like a daemon. The same script loads iptables rules from /etc/network/iptables-rules which can be saved with iptables-save and restored with iptables-restore. |
Last edited by ycUygB1 on Sat Sep 13, 2014 1:45 pm; edited 1 time in total |
|
Back to top |
|
|
eccerr0r Watchman
Joined: 01 Jul 2004 Posts: 9882 Location: almost Mile High in the USA
|
|
Back to top |
|
|
ycUygB1 Apprentice
Joined: 27 Jul 2005 Posts: 276 Location: Portland, Oregon
|
Posted: Sat Sep 13, 2014 1:39 pm Post subject: |
|
|
Right. That looks good. Just one question. How do you know that this will be executed after the network comes up? Is local always the last thing started? |
|
Back to top |
|
|
eccerr0r Watchman
Joined: 01 Jul 2004 Posts: 9882 Location: almost Mile High in the USA
|
Posted: Sat Sep 13, 2014 1:47 pm Post subject: |
|
|
For systemd it's automatic because you're adding the dependencies in the file.
For openrc, it's run after everything is set up. You can also create your own service and start it much like systemd but I think this is simpler overall. _________________ Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching? |
|
Back to top |
|
|
ycUygB1 Apprentice
Joined: 27 Jul 2005 Posts: 276 Location: Portland, Oregon
|
Posted: Sat Sep 13, 2014 1:53 pm Post subject: |
|
|
Thanks. I was thinking that baselayout would handle it in /etc/conf.d/net, maybe with some line like
tc_eno1 = "some tc command"
but I guess I must have reached baselayout's limits. |
|
Back to top |
|
|
eccerr0r Watchman
Joined: 01 Jul 2004 Posts: 9882 Location: almost Mile High in the USA
|
Posted: Sat Sep 13, 2014 2:52 pm Post subject: |
|
|
You may also be able to add
Code: | postup() {
tc qdisc add dev eno1 root tbf rate 150mbit latency 50ms burst 15mb
} |
in your /etc/conf.d/net ... I haven't tried this, this might be a nicer way that's dependency aware... _________________ Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching? |
|
Back to top |
|
|
ycUygB1 Apprentice
Joined: 27 Jul 2005 Posts: 276 Location: Portland, Oregon
|
Posted: Sat Sep 13, 2014 2:56 pm Post subject: |
|
|
Yeah, that is what I was looking for. I didn't see that documented anywhere.
Regards, |
|
Back to top |
|
|
|