Last active
July 13, 2017 14:46
-
-
Save keylase/991b202d43550fc8518e6d1eff0fa23b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mptcp - ifup: | |
----------------------------------- | |
#!/bin/sh | |
# A script for setting up routing tables for MPTCP in the N950. | |
# Copy this script into /etc/network/if-up.d/ | |
set -e | |
env > /etc/network/if_up_env | |
if [ "$IFACE" = lo -o "$MODE" != start ]; then | |
exit 0 | |
fi | |
if [ -z $DEVICE_IFACE ]; then | |
exit 0 | |
fi | |
# FIRST, make a table-alias | |
if [ `grep $DEVICE_IFACE /etc/iproute2/rt_tables | wc -l` -eq 0 ]; then | |
NUM=`cat /etc/iproute2/rt_tables | wc -l` | |
echo "$NUM $DEVICE_IFACE" >> /etc/iproute2/rt_tables | |
fi | |
if [ $DHCP4_IP_ADDRESS ]; then | |
SUBNET=`echo $IP4_ADDRESS_0 | cut -d \ -f 1 | cut -d / -f 2` | |
ip route add table $DEVICE_IFACE to $DHCP4_NETWORK_NUMBER/$SUBNET dev $DEVICE_IFACE scope link | |
ip route add table $DEVICE_IFACE default via $DHCP4_ROUTERS dev $DEVICE_IFACE | |
ip rule add from $DHCP4_IP_ADDRESS table $DEVICE_IFACE | |
else | |
# static ip | |
IPADDR=`echo $IP4_ADDRESS_0 | cut -d \ -f 1 | cut -d / -f 1` | |
SUBNET=`echo $IP4_ADDRESS_0 | cut -d \ -f 1 | cut -d / -f 2` | |
NETWITHMASK=`/usr/bin/ipcalc 192.168.1.54 | grep Network | cut -d" " -f 4` | |
ip route add table $DEVICE_IFACE to $NETWITHMASK dev $DEVICE_IFACE scope link | |
ip route add table $DEVICE_IFACE default via $IP4_GATEWAY dev $DEVICE_IP_IFACE | |
ip rule add from $IPADDR table $DEVICE_IFACE | |
fi | |
----------------------------------- | |
mptcp-if-down: | |
----------------------------------- | |
#!/bin/sh | |
# A script for setting up routing tables for MPTCP in the N950. | |
# Copy this script into /etc/network/if-post-down.d/ | |
set -e | |
env > /etc/network/if_down_env | |
if [ "$IFACE" = lo -o "$MODE" != stop ]; then | |
exit 0 | |
fi | |
ip rule del table $DEVICE_IFACE | |
ip route flush table $DEVICE_IFACE | |
----------------------------------- | |
install transocsk: | |
https://github.com/cybozu-go/transocks | |
go get -u github.com/cybozu-go/transocks/... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment