I have two changes to ip route
& sysctl
that disable tcp slow start.
Here’s how I do it
ip route show
Make a note of the line starting with default.
Pick up the IP from the default line and run
sudo ip route change default via $ip_address dev eth0 initcwnd 12
sudo sysctl -w net.ipv4.tcp_slow_start_after_idle=0
How can I create a puppet script out of this? One that can be deployed to many machines of the same type – CentOS 6
Edit: Added bounty to get a working example for
sudo ip route change default via $ip_address dev eth0 initcwnd 12
The
sysctl
side was covered in this post: Set sysctl.conf parameters with Puppet.Puppet's example for networking also leverages Augeas.
Edit: You're on CentOS, so remember that you need to make these routes persistent... Is the safer approach to make the change in a file, verify, then restart the network interface? This assumes
/etc/sysconfig/network-scripts/route-ethX
use since you're usingvia
syntax. Theip route
command seems to be your goal since you want to change the initial congestion window (initcwnd). I would seriously separate that into another option because setting the default gateway by itself should be handled by the OS network scripts/kickstart/build process.Now for a totally different solution:
I like Puppet for some things. Network configs and sysctl values are not among them. With EL6 systems, you have the ability to use the tuned-adm framework to make these system changes on the fly in an easy and consistent manner. The servers I manage sometimes need 30+
sysctl
andsysfs
changes before going into production. I used to manage that manually, then with Puppet... but with EL6, I create a tuned profile with all of the requisite tweaks and scripts, manage the profiles and their distribution with Puppet, and control thetuned
daemon with Puppet.Given that, just move your
ip
script andsysctl
values in a custom profile and go from there. Much cleaner.If you are obtaining your internet address using DHCP (which is suggested by your question), then you can use
/etc/dhcp/dhclient-exit-hooks
to run shell commands afterdhclient
configures your interface. You'll have access to a number of variables provided by dhclient, including$router
. You can use this to run:You would install this script with a normal Puppet
file
resource:And the file contents would probably look something like:
If you're not using DHCP, you can do something similar. The normal
ifup
script runs/sbin/ifup-local
after configuring the interface, and you could use this to run theip
command. In this case, you could get the address of the default gateway simply by sourcing in the interface configuration in/etc/sysconfig/network-scripts/ifcfg-eth0
(and your Puppetfile
resource would install/sbin/ifup-local
).Going off of larsks answer, if you have static ip addresses, place this in /sbin/ifup-local