• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 210
  • Last Modified:

Email script for ip change.

This is a two part question.
Question 1:
I would like to write a script that would email me telling me if the servers ip address has changed. since the server is on a network that uses dhcp.

Question 2:
I would also like a script to email me when a person logs onto the server as well.

Basic Info. About the Server:
The OS is mandrake 9 I have SSH runining on it. I use the server to store invoices and workorders on it. I set the server up so that a client can logon and retrive their invoices when that need them. The problem I am haveing is that the server has its ip address updated once a week since. so I have to go to the server and do an ifconfig to see the new ip address.
thanks in advance
0
janus1840
Asked:
janus1840
1 Solution
 
akshayxxCommented:
since Server updates its IP address after some intervals, and ur client is connected to the server using that IP address only, then u have a problem.


but there is a solution .. as i can guess your Server is connected to the outer world using that dynamic IP, and my guess is that your other computers are on LAN, so if you dont need your client computers to connect to external world. in that case u can use the LAN ip to connect to your server.
and about sending email .. well tell me how do u check email on your client computers.
The smtp/mail server that they connect to , does it have static IP ? if it doesnt OR if you connect to SMTP server through your SERVER then again your mail setup will also have to be changed.



0
 
jcaldwelCommented:
$host www.experts-exchange.com  | awk '{print $4}'
will return the current ip address for a hostname. You could set up a cron job to build a list of the ips and compare the results with last time (build a file somewhere)

0
 
jcaldwelCommented:
Part 2 of the question:

add this into the /etc/profile script
echo "." | mail -s"login from `whoami` at `date`" myemail@mydomain.com

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
janus1840Author Commented:
Ok Let me explain my self a little better. I have a system that is running mandrake 9. the system has shorewall and ssh running on it. the server is on a cable modem due to the fact that our office is getting remodeled. I have clients that would log on to the server when the server was in my office and they were able to retrive reports and their invoices. but now that the server is not on my network and its at my friends house the server now gets a dynamic ip address. my clients will try to log onto the server to retrive reports or invoices and the servers ip address has changed my clients would then call me up asking whats the servers ip address I then have to call my friend and have him logon to the server and do an ifconfig he then tells me what the ip address is and I then inform my client. I have 57 clients so just think how many calls a day i get about whats the servers ip address.
0
 
janus1840Author Commented:
Ok Let me explain my self a little better. I have a system that is running mandrake 9. the system has shorewall and ssh running on it. the server is on a cable modem due to the fact that our office is getting remodeled. I have clients that would log on to the server when the server was in my office and they were able to retrive reports and their invoices. but now that the server is not on my network and its at my friends house the server now gets a dynamic ip address. my clients will try to log onto the server to retrive reports or invoices and the servers ip address has changed my clients would then call me up asking whats the servers ip address I then have to call my friend and have him logon to the server and do an ifconfig he then tells me what the ip address is and I then inform my client. I have 57 clients so just think how many calls a day i get about whats the servers ip address.
0
 
rdutaCommented:
1) good luck!  since the IP address on the host is probably
derived by DHCP, and is a nonrouted address you may have a really hard time.  If you get a real routed IP address then
www.dyndns.org will work OK.  If not you'll have to resort
to someting more sinister.  Write or find a server/client with a push from the hosts to a central server (CGI for example).

2) I would use someting like swatch or logcheck:
http://www.dlhoffman.com/publiclibrary/RPM/contrib/libc6/i386/logcheck-1.1.1-1.i386.html
or swatch.
0
 
janus1840Author Commented:
thanks for the advice sorry about not replying sooner I was in the middle of remodeling my office.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now