Link to home
Start Free TrialLog in
Avatar of janus1840
janus1840

asked on

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
Avatar of akshayxx
akshayxx
Flag of United States of America image

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.



Avatar of jcaldwel
jcaldwel

$host https://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)

Part 2 of the question:

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

Avatar of janus1840

ASKER

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.
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.
ASKER CERTIFIED SOLUTION
Avatar of rduta
rduta

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks for the advice sorry about not replying sooner I was in the middle of remodeling my office.