Add rc.local example

parent 52752635
#!/bin/bash -x
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
WLAN="wlx485d602d09c8"
WANS="ppp0 ppp1 eth0 eth1 $WLAN"
EXTTUNS="tun600"
ISPS="vanilla rain"
INTLAN="192.168.1.0/24"
MYLANIP="192.168.1.1"
#Set the best governor for CPU
for CPUID in $(grep processor /proc/cpuinfo | awk '{print $3}') ; do
cpufreq-set -r -c $CPUID -g performance
done
# Disable HT as is a shit for routing performances..
for CPU in /sys/devices/system/cpu/cpu[0-9]*; do
CPUID=$(basename $CPU)
echo "CPU: $CPUID";
if test -e $CPU/online; then
echo "1" > $CPU/online;
fi;
COREID="$(cat $CPU/topology/core_id)";
eval "COREENABLE=\"\${core${COREID}enable}\"";
if ${COREENABLE:-true}; then
echo "${CPU} core=${CORE} -> enable"
eval "core${COREID}enable='false'";
else
echo "$CPU core=${CORE} -> disable";
echo "0" > "$CPU/online";
fi;
done;
for WAN in $WANS
do
iptables -t nat -I POSTROUTING -o $WAN -j MASQUERADE
done
# Just a bit of performances
iptables -A FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu
# NOTE: YOU MUST have the tables as per in the $ISPS variable
# configured properly!
# example:
# cat /etc/iproute2/rt_tables
# #
# # reserved values
# #
# 255 local
# 254 main
# 253 default
# 0 unspec
# #
# # local
# #
# #1 inr.ruhep
# 60 catchall
# 58 telkom
# 57 rain
# 50 level7
# 40 vanilla
for ISP in $ISPS
do
ip route add $INTLAN dev br0 scope link src $MYLANIP table $ISP
done
# Change default priority for main so we can add a new table between main and default
ip rule add priority 32765 from all lookup main
ip rule del priority 32766 from all lookup main
# then add a special table catchall
ip rule add priority 32766 from all lookup catchall
ip route flush cache
iptables -t mangle -A POSTROUTING -j CONNMARK --save-mark
iptables -t mangle -A PREROUTING -j CONNMARK --restore-mark
# Shaping policies
setsid /etc/multihome/shaping &
# Deep Packet Inspection
/etc/multihome/dpi > /tmp/dpi.log 2>&1 &
disown
ipset add full_ip 192.168.1.2
ipset add full_ip 192.168.1.3
exit 0
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment