Skip to content

Script does not work for my shell #2

Description

@jscottandersonthe1

Looking at the instructions for manually adding and deleting rules and table entries I see that there is a disagreement. Here is what I ended up doing for the mptcp_up. Note that I did not touch the PPP case:

#!/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
else
NUM=`cat /etc/iproute2/rt_tables | grep $DEVICE_IFACE | cut -d\   -f 1`
fi
if [ -n $DHCP4_IP_ADDRESS ]; then
SUBNET=`echo $IP4_ADDRESS_0 | cut -d \  -f 1 | cut -d / -f 2`
ip route add $DHCP4_NETWORK_NUMBER/$SUBNET dev $DEVICE_IFACE scope link table $NUM
ip route add default via $DHCP4_ROUTERS dev $DEVICE_IFACE table $NUM
ip rule add from $DHCP4_IP_ADDRESS table $NUM
else
# PPP-interface
IPADDR=`echo $IP4_ADDRESS_0 | cut -d \ -f 1 | cut -d / -f 1`
ip route add table $DEVICE_IFACE default dev $DEVICE_IP_IFACE scope link
ip rule add from $IPADDR table $DEVICE_IFACE
fi

This script uses the first field of the line on which it finds the interface as the table number.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions