source: projects/initscripts/tags/initscripts-8.91.0/sysconfig/network-scripts/ifup-tunnel @ 2576

Revision 2576, 2.4 KB checked in by daisuke, 13 years ago (diff)

tagging as initscripts-8.91.0

Line 
1#!/bin/bash
2# Copyright (C) 1996-2006 Red Hat, Inc. all rights reserved.
3#
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License, version 2,
6# as published by the Free Software Foundation.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program; if not, write to the Free Software
15# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
16
17# Thanks to:
18#  - Razvan Corneliu C.R. Vilt <razvan.vilt@linux360.ro>
19#  - Aaron Hope <aaron.hope@unh.edu>
20#  - Sean Millichamp <sean@enertronllc.com>
21# for providing the scripts this one is based on
22
23. /etc/init.d/functions
24
25cd /etc/sysconfig/network-scripts
26. /etc/sysconfig/network-scripts/network-functions
27
28CONFIG=$1
29need_config "$CONFIG"
30source_config
31
32if [ "$PEER_OUTER_IPADDR" = "$PEER_INNER_IPADDR" ]; then
33    # Specifying PEER_INNER_IPADDR would automatically add a route to the peer
34    # through the tunnel, redirecting tunnel packets back to the tunnel and
35    # creating a dead loop.
36    unset PEER_INNER_IPADDR
37fi
38
39case "$TYPE" in
40    GRE)
41        MODE=gre
42        /sbin/modprobe ip_gre
43        ;;
44    IPIP)
45        MODE=ipip
46        /sbin/modprobe ipip
47        ;;
48    *)
49        echo $"Invalid tunnel type $TYPE"
50        exit 1
51        ;;
52esac
53
54# Generic tunnel devices are not supported here
55if [ "$DEVICE" = gre0 -o "$DEVICE" = tunl0 ]; then
56    echo $"Device '$DEVICE' isn't supported as a valid GRE device name."
57    exit 1
58fi
59
60# Create the tunnel
61# The outer addresses are those of the underlying (public) network.
62/sbin/ip tunnel add "$DEVICE" mode "$MODE" \
63    ${MY_OUTER_IPADDR:+local "$MY_OUTER_IPADDR"} \
64    remote "$PEER_OUTER_IPADDR" ${TTL:+ttl "$TTL"}
65
66if [ -n "$MTU" ]; then
67    /sbin/ip link set "$DEVICE" mtu "$MTU"
68fi
69
70# The inner address are used mainly for communication between a gateway
71# and a private network.  When the peer is configured with an inner address
72# contained in the peer's private network or identical to it's public address,
73# it need not be specified.
74/sbin/ip addr add "$MY_INNER_IPADDR" dev "$DEVICE" \
75    ${PEER_INNER_IPADDR:+peer "$PEER_INNER_IPADDR"}
76
77/sbin/ip link set dev "$DEVICE" up
78
79exec /etc/sysconfig/network-scripts/ifup-post "$CONFIG" "$2"
Note: See TracBrowser for help on using the repository browser.