Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

E-Mailing ppp address

Status
Not open for further replies.

ManagerJay

IS-IT--Management
Jul 24, 2000
302
US
I am currently setting up a server at a remote site that will be used to masquerade users connections to our corporate VPN.

The server will be utilizing a dial-up Internet connection to the local ISP.

What I would like to do is have the server e-mail me its IP address each time a new dial-up connection is made, so I can perform any maintenance on the server that might be needed.

Is this possible, and if so how do I need to configure Sendmail since I do not have a registered domain name for this server?

The server is a RedHat 6.2 Linux box running Sendmail 8.9.3.

Any help would be greatly appreciated. Thanks in advance for your assistance.



Jay
 
Hi there, you happen to be in luck!

I have JUST finnished writing a few scrips that do exactly what you want. Basicaly my server collects it mail every morning then comes online using a dialup isp, mails me its ip address (to my work), i can then collect mail, do web admin stuff ect. I set it up to say online for 30 mins then kill the ppp connection.

Part two of this procedure is this.. i have a intranet at home (windows) and have setup a web page that runs a script on my unix box to bring it online, (so my partner does not have to use windows dialup), the window pc's then use this connetcion as a default gatway to the internet.

Problem - I needed to be able to monitor the line status, cos my partner said the box was comming online in the middle of the day - leaving the phone useless, plus i needed to know if/when she was on the internet so i could also connect to the box at any other time it came up. so i created an infinite loop that did this ..

loop begin
if the line up ( does tun0.pid exist)
mail me info (runs mailer scrip with '&')
sleep 30 mins
else
sleep 60 secs (wait before re-trying)
end loop

It crude, but it works.

The other script, called mailer, creates a mail and adds this line in there ...

ifconfig | grep netmask | grep ">" >> to mailfile.

you get something like ...

inet 213.48.181.201 --> 192.168.0.2 netmask 0xffffff00

then i do ...

sendmail me@work.com < mailfile

The first script runs in the background (&) when the server starts, the second is only called when the box is online.

Of course there is one obvious problem - after it has mailed me the ip it will sleep for 30 mins before checking again. This could mean that if the line was up for longer than this i would recive mails every half hour!

But as my box is not needed to be up any longer than this there is no need in my case.

I can mail you the scrips if you would like to use them, but you may find diferences in file locations and shell cos i'm using FreeBSD, but feel free to edit them if you wish (i assume you have a good knowlege of shell/perl scripts, i only have basic knowledge as i am still learning!)

however i cannot mail them to you now as i am at work and do not have access to my box at this time! Bus if you send me your email address i will gladly sen you all script over the weekend.

Regards,

Jaybot
mailto:Jaybot@jamsoftcorp.co.uk &quot;Always know what you say, but don't always say what you know!&quot;
 
Thank you very much for your help.

I basically, followed your example, but made some changes so it will do exactly what I want it to do.

Since the server is providing a dial-up connection to several users, I added the following lines to my /etc/ppp/ip-up.local script.

echo &quot;Server Name is now up.&quot; >Mailfile
ifconfig >>Mailfile
sendmail email@address <Mailfile

This way if the connection should time out, or be dropped for any reason, as soon as the ppp link is re-established, I am sent the new TCP/IP addrss.

Additionally, I have scheduled a job to run at 7:00 pm every evening so I am ensured of having a maintenance window.

Thanks again for all your help.



Jay


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top