Project

General

Profile

Download (2.24 KB) Statistics
| Branch: | Tag: | Revision:
1 cbe4111f Ermal Luçi
#!/bin/sh
2 ac24dc24 Renato Botelho
#
3
# ppp-linkdown
4
#
5
# part of pfSense (https://www.pfsense.org)
6 38809d47 Renato Botelho do Couto
# Copyright (c) 2004-2013 BSD Perimeter
7
# Copyright (c) 2013-2016 Electric Sheep Fencing
8 402c98a2 Reid Linnemann
# Copyright (c) 2014-2023 Rubicon Communications, LLC (Netgate)
9 ac24dc24 Renato Botelho
# All rights reserved.
10
#
11 b12ea3fb Renato Botelho
# Licensed under the Apache License, Version 2.0 (the "License");
12
# you may not use this file except in compliance with the License.
13
# You may obtain a copy of the License at
14 ac24dc24 Renato Botelho
#
15 b12ea3fb Renato Botelho
# http://www.apache.org/licenses/LICENSE-2.0
16 ac24dc24 Renato Botelho
#
17 b12ea3fb Renato Botelho
# Unless required by applicable law or agreed to in writing, software
18
# distributed under the License is distributed on an "AS IS" BASIS,
19
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
# See the License for the specific language governing permissions and
21
# limitations under the License.
22 2c27096c Renato Botelho
23
IF="${1}"
24 6c452777 David Wood
PROTOCOL="${2}"
25 2c27096c Renato Botelho
LOCAL_IP="${3}"
26
27
if [ -f /tmp/${IF}up ] && [ -f /conf/${IF}.log ]; then
28
	seconds=$((`date -j +%s` - `/usr/bin/stat -f %m /tmp/${IF}up`))
29
	/usr/local/sbin/ppp-log-uptime.sh $seconds ${IF} &
30 63292199 gnhb
fi
31 766cd450 jim-p
32 b9a40f9b sven
if echo "${IF}" | /usr/bin/egrep -qv "ppp[0-9]+"; then
33 97d53173 Sven Auhagen
	/etc/rc.kill_states ${IF} ${LOCAL_IP}
34
fi
35 46e27ea7 Renato Botelho
36 6df89ece David Wood
if [ "${PROTOCOL}" == "inet" && -s "/tmp/${IF}_defaultgw" ]; then
37 def432e6 Renato Botelho
	GW=`head -n 1 /tmp/${IF}_defaultgw`
38 2efb39d0 jim-p
	DGW=`/sbin/route -n get -inet default | /usr/bin/awk '/gateway:/ {print $2}'`
39
	# Only remove the default gateway if it matches the gateway for this interface. See redmine #1837
40
	if [ "${GW}" = "${DGW}" ]; then
41
		/sbin/route -q delete default ${GW}
42
	fi
43 04c528e7 Ermal
fi
44 2efb39d0 jim-p
45 6c452777 David Wood
if [ "${PROTOCOL}" == "inet6" ]; then
46
	/usr/local/sbin/ppp-ipv6 ${IF} down
47
fi
48 cbe4111f Ermal Luçi
# delete the node just in case mpd cannot do that
49 2c27096c Renato Botelho
/usr/sbin/ngctl shutdown ${IF}:
50
if [ -f "/var/etc/nameserver_${IF}" ]; then
51 f7ea0505 Ermal
	# Remove old entries
52 2c27096c Renato Botelho
	for nameserver in `cat /var/etc/nameserver_${IF}`; do
53 f7dfd39f David Wood
		/sbin/route -q delete ${nameserver} >/dev/null 2>&1
54 f7ea0505 Ermal
	done
55 2c27096c Renato Botelho
	/bin/rm -f /var/etc/nameserver_${IF}
56 f7ea0505 Ermal
fi
57 b439dc01 Ermal
# Do not remove gateway used during filter reload.
58 719da3ee jim-p
59
if [ -f "/tmp/${IF}_router" ]; then
60
	/bin/mv /tmp/${IF}_router /tmp/${IF}_router.last
61
fi
62 7610a397 Viktor G
63
# cleanup all VIPs, see https://redmine.pfsense.org/issues/11629
64
while
65
	aliases=$(/sbin/ifconfig ${IF} | /usr/bin/grep netmask)
66
	if [ -z "${aliases}" ]; then
67
		break
68
	fi
69
do ifconfig ${IF} -alias ;  done
70
71 2c27096c Renato Botelho
/bin/rm -f /tmp/${IF}up
72
/bin/rm -f /tmp/${IF}_ip
73 0ae6daf8 Ermal
/usr/local/sbin/pfSctl -c 'service reload dns'