Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] Where to put network post-start commands?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
ycUygB1
Apprentice
Apprentice


Joined: 27 Jul 2005
Posts: 276
Location: Portland, Oregon

PostPosted: Sat Sep 13, 2014 6:48 am    Post subject: [SOLVED] Where to put network post-start commands? Reply with quote

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
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 7130
Location: almost Mile High in the USA

PostPosted: Sat Sep 13, 2014 1:34 pm    Post subject: Reply with quote

OpenRC:
Create or edit file local.start in /etc/local.d/ that contains your command. This will be executed after normal startup sequence.

Systemd:
http://unix.stackexchange.com/questions/47695/how-to-write-startup-script-for-systemd
_________________
Intel Core i7 2700K@ 4.1GHz/HD3000 graphics/8GB DDR3/180GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
ycUygB1
Apprentice
Apprentice


Joined: 27 Jul 2005
Posts: 276
Location: Portland, Oregon

PostPosted: Sat Sep 13, 2014 1:39 pm    Post subject: Reply with quote

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
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 7130
Location: almost Mile High in the USA

PostPosted: Sat Sep 13, 2014 1:47 pm    Post subject: Reply with quote

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@ 4.1GHz/HD3000 graphics/8GB DDR3/180GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
ycUygB1
Apprentice
Apprentice


Joined: 27 Jul 2005
Posts: 276
Location: Portland, Oregon

PostPosted: Sat Sep 13, 2014 1:53 pm    Post subject: Reply with quote

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
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 7130
Location: almost Mile High in the USA

PostPosted: Sat Sep 13, 2014 2:52 pm    Post subject: Reply with quote

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@ 4.1GHz/HD3000 graphics/8GB DDR3/180GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
ycUygB1
Apprentice
Apprentice


Joined: 27 Jul 2005
Posts: 276
Location: Portland, Oregon

PostPosted: Sat Sep 13, 2014 2:56 pm    Post subject: Reply with quote

Yeah, that is what I was looking for. I didn't see that documented anywhere.

Regards,
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum