Script to add route after interface get up

Posted on 2005-02-28
Medium Priority
Last Modified: 2010-03-18
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 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:  P-t-P:  Mask:

in this example is

route add -net gw

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
Question by:RosettaStone

Author Comment

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

# 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
                /sbin/route add -net gw
# and flush the mail queue to get their email there asap!
            /usr/sbin/sendmail -q &
# 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 &
# Start the news server (if not already running)
                if [ ! -f /var/lock/subsys/news ]; then
                        /etc/rc.d/init.d/news start &
# 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 &
exit 0


Accepted Solution

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

Community Support Moderator
Experts Exchange

Featured Post

[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

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…
Stellar Phoenix SQL Database Repair software easily fixes the suspect mode issue of SQL Server database. It is a simple process to bring the database from suspect mode to normal mode. Check out the video and fix the SQL database suspect mode problem.
Suggested Courses

601 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