Posts Tagged ‘iproute2’

SalixOS, OpenVPN and iproute2

Tuesday, June 25th, 2013

I have an OpenVPN server through which its clients get some routes. One client with SalixOS had an error while connecting to the server:
Linux ip link set failed: could not execute external program
The reason is that OpenVPN client sets the routes with the ‘ip’ command. But Salix doesn’t install the iproute2 package by default. Install it and the connection will be finished.

Shaping in Slackware

Thursday, January 17th, 2013

An ‘iproute2’ package (description) must be installed. Let’s imagine that we use a default kernel in which ‘everything is included but the kitchen sink’. :)

FIRST. Create /etc/rc.d/rc.shaper with the following code:


#!/bin/bash
shaper_start() {
tc qdisc add dev eth1 root handle 1:0 htb default 254

tc class add dev eth1 parent 1:0 classid 1:1 htb rate 0.5mbit
tc class add dev eth1 parent 1:0 classid 1:2 htb rate 3.3mbit
tc class add dev eth1 parent 1:0 classid 1:254 htb rate 256kbit

tc filter add dev eth1 protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.0.2 flowid 1:1
tc filter add dev eth1 protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.0.3 flowid 1:2
}

shaper_stop() {
tc qdisc del dev eth1 root
}
shaper_restart() {
shaper_stop
sleep 1
shaper_start
}

case "$1" in
'start')
shaper_start
;;
'stop')
shaper_stop
;;
'restart')
shaper_restart
;;
*)
echo "usage $0 start|stop|restart"

SECOND. Make it executable: chmod +x /etc/rc.d/rc.shaper

THIRD. Add to /etc/rc.d/rc.inet2 these lines:


if [ -x /etc/rc.d/rc.shaper ]; then
/etc/rc.d/rc.shaper start
fi

Now type /etc/rc.d/rc.shaper start. After that your client with 192.168.0.2 IP address will have a 0.5 mbit/s bandwidth and 192.168.0.3 one will have 3.3 mbit/s. Any other IPs will have 256 kbit/s only, as it is set in the default shaping rule.