summaryrefslogtreecommitdiff
path: root/scripts/vyatta-link-detect
blob: f0d0693bc67a9272923efcac9ff19b9a7f3ea6c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#! /bin/bash
#
# Usage: vyatta-link-detect devicename on|off
#

usage() {
    echo "Usage: $0 devicename {on|off}"
    exit 1
}

if [ $# -ne 2 ]; then
    usage
fi

case $2 in
on)	sudo sysctl -w "net.ipv4.conf.$1.link_filter=2"
#	sudo sysctl -w "net.ipv6.conf.$1.link_filter=2"
	cmd="link-detect" ;;
off)    sudo sysctl -w "net.ipv4.conf.$1.link_filter=1"
#	sudo sysctl -w "net.ipv6.conf.$1.link_filter=1"
	cmd="no link-detect" ;;
*)	usage;;
esac

exec vyatta-vtysh -c "configure terminal" -c "interface $1" -c "$cmd"