Project

General

Profile

Download (1.83 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/bin/sh
2
#
3
# ppp-linkdown
4
#
5
# part of pfSense (https://www.pfsense.org)
6
# Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
7
# All rights reserved.
8
#
9
# Licensed under the Apache License, Version 2.0 (the "License");
10
# you may not use this file except in compliance with the License.
11
# You may obtain a copy of the License at
12
#
13
# http://www.apache.org/licenses/LICENSE-2.0
14
#
15
# Unless required by applicable law or agreed to in writing, software
16
# distributed under the License is distributed on an "AS IS" BASIS,
17
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
# See the License for the specific language governing permissions and
19
# limitations under the License.
20

    
21
IF="${1}"
22
PROTOCOL="${2}"
23
LOCAL_IP="${3}"
24

    
25
if [ -f /tmp/${IF}up ] && [ -f /conf/${IF}.log ]; then
26
	seconds=$((`date -j +%s` - `/usr/bin/stat -f %m /tmp/${IF}up`))
27
	/usr/local/sbin/ppp-log-uptime.sh $seconds ${IF} &
28
fi
29

    
30
/etc/rc.kill_states ${IF} ${LOCAL_IP}
31

    
32
if [ "${PROTOCOL}" == "inet" && -s "/tmp/${IF}_defaultgw" ]; then
33
	GW=`head -n 1 /tmp/${IF}_defaultgw`
34
	DGW=`/sbin/route -n get -inet default | /usr/bin/awk '/gateway:/ {print $2}'`
35
	# Only remove the default gateway if it matches the gateway for this interface. See redmine #1837
36
	if [ "${GW}" = "${DGW}" ]; then
37
		/sbin/route -q delete default ${GW}
38
	fi
39
fi
40

    
41
if [ "${PROTOCOL}" == "inet6" ]; then
42
	/usr/local/sbin/ppp-ipv6 ${IF} down
43
fi
44
# delete the node just in case mpd cannot do that
45
/usr/sbin/ngctl shutdown ${IF}:
46
if [ -f "/var/etc/nameserver_${IF}" ]; then
47
	# Remove old entries
48
	for nameserver in `cat /var/etc/nameserver_${IF}`; do
49
		/sbin/route -q delete ${nameserver} >/dev/null 2>&1
50
	done
51
	/bin/rm -f /var/etc/nameserver_${IF}
52
fi
53
# Do not remove gateway used during filter reload.
54
/bin/rm -f /tmp/${IF}_router
55
/bin/rm -f /tmp/${IF}up
56
/bin/rm -f /tmp/${IF}_ip
57
/usr/local/sbin/pfSctl -c 'service reload dns'
(13-13/23)