This file is indexed.

/etc/init.d/networking-routes is in ifupdown-extra 0.22.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  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
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#!/bin/sh -e
# Script to add global static routes to the system
#
# 
### BEGIN INIT INFO
# Provides:          networking-routes
# Required-Start:    $network $local_fs
# Required-Stop:     $local_fs
# Default-Start:     S
# Default-Stop:      
# Short-Description: Establish global networking routes for the system
# Description:       Define global network routes for the system using
#                    the configuration defined in /etc/network/routes
#                    Global routes can be either routes for which
#                    the associated interface cannot be determined
#                    beforehand (maybe the device name is not known)
#                    or 'reject' routes to prevent the system from
#                    communicating with remote networks.
### END INIT INFO
#
# Copyright (c) 2011 Javier Fernandez-Sanguino <jfs@debian.org>
#
# Some portions (specifically the code of the run_route() function) are derived
# from the ifup-route script in SuSE's sysconfig package.
# These portions are:
#
# - Copyright (c) 2002 SuSE Linux AG Nuernberg, Germany. All rights reserved.
# -  Author: Christian Zoz <zoz@suse.de>, 2002
# -  Based on rcroute: Burchard Steinbild <bs@suse.de>, 1996
#                Werner Fink <werner@suse.de>, 1996-2000
#
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
# Place, Suite 330, Boston, MA 02111-1307 USA
#

[ -x /sbin/route ] || exit 0
ROUTEFILE="/etc/network/routes"
# Abort (without error) if the configuration file does not exist
[ ! -r "$ROUTEFILE" ] && exit 0

. /lib/lsb/init-functions
# Default value
VERBOSITY=${VERBOSITY:-0}


# Functions to read the route file and process it


run_route() {
	local COMMAND="route $*"
	export LC_MESSAGES=C # We need the return messages to be in english
        RETMESSAGE="$($COMMAND 2>&1)"
        RETVALUE=$?
        if test $RETVALUE -ne 0 ; then
                [ "$VERBOSITY" -eq 1 ] && echo "DEBUG: calling: '$COMMAND' FAILED"
		# Process the messages and omits those that are not
		# relevant.
                case "$RETMESSAGE" in
		# Omit 'File exists' since the route is already there..
                        *File*exists) return ;;
		# 'No such process' is only omitted if the route is being
		# deleted.  If the route is being created, this error message
		# might appear if the gateway is not reachable.
                        *No*such*process) [ "$1" = "del" ] && return ;;
                        *)
                esac
                log_failure_msg "Error while executing:" \
                         "  Command '$COMMAND' returned:  ${RETMESSAGE%%Usage:*}"\
                         "  Configuration line: $LINE"
        else
                [ "$VERBOSITY" -eq 1 ] && echo "DEBUG: calling: '$COMMAND' SUCCEEDED"
        fi



} 

del_global_routes() {
        ret=0
	cat $ROUTEFILE | egrep "^[^#].*any$" | 
	while read network netmask gateway interface ; do
            if [ -n "$interface" ] && [ -n "$network" ] && [ -n "$netmask" ] && [ -n "$gateway" ] ; then
                if [ "$gateway" != "reject" ] ; then
                    [ "$VERBOSITY" -eq 1 ] && echo "DEBUG: Deleting global route for $network / $netmask through gateway $gateway"
                    run_route del -net $network netmask $netmask gw $gateway 
                    [ $? -ne 0 ] && ret=$?
                else
                    [ "$VERBOSITY" -eq 1 ] && echo "DEBUG: Deleting reject route for $network / $netmask"
                    run_route del -net $network netmask $netmask reject
                    [ $? -ne 0 ] && ret=$?
                fi

            else
                echo "ERROR: Incorrect line for global network routes in $ROUTEFILE: '$network $netmask $gateway $interface'"
                ret=1
            fi
	done
        return $ret
}

add_global_routes() {
        ret=0
	cat $ROUTEFILE | egrep "^[^#].*any$" | 
	while read network netmask gateway interface ; do
            if [ -n "$interface" ] && [ -n "$network" ] && [ -n "$netmask" ] && [ -n "$gateway" ] ; then
                if [ "$gateway" != "reject" ] ; then
		    [ "$VERBOSITY" -eq 1 ] && echo "DEBUG: Adding global route for $network / $netmask through gateway $gateway"
        	    run_route add -net $network netmask $netmask gw $gateway
                    [ $? -ne 0 ] && ret=$?
                else
                    [ "$VERBOSITY" -eq 1 ] && echo "DEBUG: Adding global reject route for $network / $netmask"
                    run_route add -net $network netmask $netmask reject
                    [ $? -ne 0 ] && ret=$?
                fi

            else
                echo "ERROR: Incorrect line for global network routes in $ROUTEFILE: '$network $netmask $gateway $interface'"
                ret=1
            fi
	done
        return $ret
}

case "$1" in
start)
	log_action_begin_msg "Configuring network routes"
	if add_global_routes; then
	    log_action_end_msg $?
	else
	    log_action_end_msg $?
	fi
	;;

stop)
	log_action_begin_msg "Deconfiguring network routes"
	if del_global_routes; then
	    log_action_end_msg $?
	else
	    log_action_end_msg $?
	fi
	;;

reload|force-reload|restart)
	log_action_begin_msg "Reconfiguring network routes"
        del_global_routes
	if add_global_routes; then
	    log_action_end_msg $?
	else
	    log_action_end_msg $?
	fi
	;;

*)
	echo "Usage: /etc/init.d/networking-routes {start|stop|restart|reload}"
	exit 1
	;;
esac

exit 0