2
###############################################################################
4
# IPFire.org - A linux based firewall #
5
# Copyright (C) 2007-2022 IPFire Team <info@ipfire.org> #
7
# This program is free software: you can redistribute it and/or modify #
8
# it under the terms of the GNU General Public License as published by #
9
# the Free Software Foundation, either version 3 of the License, or #
10
# (at your option) any later version. #
12
# This program is distributed in the hope that it will be useful, #
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15
# GNU General Public License for more details. #
17
# You should have received a copy of the GNU General Public License #
18
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
20
###############################################################################
26
function init_table() {
27
# Check if table does already exist. If not we add it.
28
if (ip rule | grep -q "static" >/dev/null 2>&1); then
32
ip rule add table static
35
function create_all_routes() {
40
ip route flush table static >/dev/null 2>&1
47
# Read all routes from the configuration file and add the enabled ones
49
while IFS=, read status network gateway remark; do
50
[ "${status}" = "on" ] || continue
52
if [ -z "${network}" -o -z "${gateway}" ]; then
53
# Silently skipping invalid routes.
57
ip route add ${network} via ${gateway} table static proto static
61
CONFIGFILE="/var/ipfire/main/routing"
65
boot_mesg "Adding static routes..."
67
# First, initialize the table
71
create_all_routes ${CONFIGFILE}
77
boot_mesg "Removing static routes..."
78
ip route flush table static >/dev/null 2>&1
83
echo "Usage: ${0} {start|stop|reload}"