LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > *BSD
User Name
Password
*BSD This forum is for the discussion of all BSD variants.
FreeBSD, OpenBSD, NetBSD, etc.

Notices


Reply
  Search this Thread
Old 09-02-2004, 03:32 AM   #1
noir911
Member
 
Registered: Apr 2004
Posts: 682

Rep: Reputation: Disabled
PPP disconnect annoyence


I use PPP dial up and I usually do:

"sudo /location/to/ppp -auto isp1" and it dials and gets back to the prompt.
So, when I want to disconnect I have to do:

"ps -aux | grep ppp" && "kill -9 <PID>"

Does anyone know any quick any around this? Like, putting it in the
background or something? I have tried with "&".

Any ideas?

TIA.
 
Old 09-02-2004, 10:18 AM   #2
frob23
Senior Member
 
Registered: Jan 2004
Location: Roughly 29.467N / 81.206W
Distribution: OpenBSD, Debian, FreeBSD
Posts: 1,450

Rep: Reputation: 48
The easiest way to do what you are doing is to write some scripts to start the connection and stop it for you. On many systems these could be called different things. We'll use ppp-up and ppp-down for the examples.

In ppp-up we want to place:
Code:
#!/bin/sh
sudo /path/to/ppp -auto isp1
The reason we put it there is so you have one simple commend you run and it just works. Now, you just enter your password and away it goes. You might be interested in adding your username to the "network" group (/etc/group) and adding the line "allow user _username_" to the ppp.conf file. If you do that you will be able to avoid the sudo. But that is off-topic.

In ppp-down we want to place:
Code:
#!/bin/sh
kill -9 `cat /var/run/tun?.pid`
This makes use of a little trick... ppp always stores its PID in /var/run/DEVICE.pid. Device is probably going to be tun0 in most cases but we use the ? just in case it starts as tun1 (which would be the wrong thing to do but makes this program kill it anyway).

You could also start up a server from the ppp.conf file by doing something like:
set server /var/run/internet "" 0177

Then you could change ppp-down to use the pppctl command instead. Which will shut it down in a nicer manner.
Code:
#!/bin/sh
exec pppctl /var/run/internet set timeout 300\; close
To learn more about the pppctl option read `man pppctl` -- this page is a lot shorter than ppp's.

EDIT: If you use the pppctl command you are going to want to change the ppp-up script. Since ppp will still be running just disconnected. And we need a ppp-start script to start the whole thing.

ppp-start: (same as our original ppp-up ... minus the -auto switch)
Code:
#!/bin/sh
sudo /path/to/ppp isp1
ppp-up
We don't use the auto switch because we don't want it restarting as soon as we turn it off.

ppp-up:
Code:
#!/bin/sh
exec pppctl /var/run/internet set timeout 300\; dial

Last edited by frob23; 09-02-2004 at 10:23 AM.
 
Old 09-02-2004, 10:51 AM   #3
noir911
Member
 
Registered: Apr 2004
Posts: 682

Original Poster
Rep: Reputation: Disabled
Thanks a bunch!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to link linux ppp client to windows ppp server? cyz Linux - Networking 2 12-11-2008 05:01 AM
Looking for man ppp-on and info ppp-on pages. rvijay Linux - General 1 02-26-2005 08:49 PM
Can't disconnect raysr Linux - Networking 2 05-23-2004 10:00 AM
how to disconnect ppp link to isp checkchan Linux - Newbie 0 08-10-2003 09:21 AM
Can't disconnect!!! Nik Linux - Software 1 12-15-2002 03:32 AM

LinuxQuestions.org > Forums > Other *NIX Forums > *BSD

All times are GMT -5. The time now is 01:14 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration