?
Solved

Script to add route after interface get up

Posted on 2005-02-28
2
Medium Priority
?
216 Views
Last Modified: 2010-03-18
Hi!
I have a PPTP daemon that raises up an ppp0 interface whenever an incoming vpn connection arrives.

I want to add a "route add -net 10.0.0.0 gw IP_OF_CLIENT_PPP0"

IP_OF_CLIENT_PPP0 should be the ip of the client that is connecting

ppp0      Link encap:Point-to-Point Protocol
          inet addr:192.168.10.10  P-t-P:192.168.10.21  Mask:255.255.255.255

in this example is 192.168.10.21

route add -net 10.0.0.0 gw 192.168.10.21

the route gets lost when interface gets down
Any ideas ?

if I cannot trigger this when the interface gets up I might as well accept
a cron job that parses ifconfig output and adds route if ppp0 exists.

thanks for your effort
0
Comment
Question by:RosettaStone
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 2

Author Comment

by:RosettaStone
ID: 13427807
Found the answer
in case of pppd   I have to use /etc/ppp/ip-up
here's a sample

#!/bin/bash
#
# Script which handles the routing issues as necessary for pppd
# Only the link to Newman requires this handling.
#
# When the ppp link comes up, this script is called with the following
# parameters
#       $1      the interface name used by pppd (e.g. ppp3)
#       $2      the tty device name
#       $3      the tty device speed
#       $4      the local IP address for the interface
#       $5      the remote IP address
#       $6      the parameter specified by the 'ipparam' option to pppd
#
case "$5" in
# Handle the routing to the Newman Campus server
        202.12.126.1)
                /sbin/route add -net 202.12.126.0 gw 202.12.126.1
# and flush the mail queue to get their email there asap!
            /usr/sbin/sendmail -q &
                ;;
      139.130.177.2)
# Our Internet link
# When the link comes up, start the time server and synchronise to the world
# provided it is not already running
                if [ ! -f /var/lock/subsys/xntpd ]; then
                        /etc/rc.d/init.d/xntpd.init start &
                fi
# Start the news server (if not already running)
                if [ ! -f /var/lock/subsys/news ]; then
                        /etc/rc.d/init.d/news start &
                fi
                ;;
      203.18.8.104)
# Get the email down to my home machine as soon as the link comes up
# No routing is required as my home Ethernet is handled by IP
# masquerade and proxyarp routing.
            /usr/sbin/sendmail -q &
            ;;
        *)
esac
exit 0

0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 13428707
Closed, 500 points refunded.

modulo
Community Support Moderator
Experts Exchange
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have seen several blogs and forum entries elsewhere state that because NTFS volumes do not support linux ownership or permissions, they cannot be used for anonymous ftp upload through the vsftpd program.   IT can be done and here's how to get i…
Note: for this to work properly you need to use a Cross-Over network cable. 1. Connect both servers S1 and S2 on the second network slots respectively. Note that you can use the 1st slots but usually these would be occupied by the Service Provide…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question