help writing shell script
Okay,
I am hosting a webserver and ssh from my house for a project a friend and I are working on. Being that this is from my house, I have a dynamically assigned IP address. I was trying to find a way to write a shell script that would determine my external IP address, and mail it to him every few hours. I've been messing around with ifconfig but can't figure out how to get the external address. I'm also aware that I will need to use cron for scheduling this script to run. thanks in advance for any advice/pointer you can give -NPC |
What type of internet connection are you using, cable, ADSL etc..? Are you using a router?
Use a free dynamic IP DNS service like www.noip.com. No need to worry if your IP changes. |
Assuming that the computer is directly connected to the ISP (no intervening routers), and that eth0 is the interface being used, you can execute this command:
Code:
/sbin/ifconfig eth0 | grep "inet addr" | cut -f 2 -d ':' | cut -f 1 -d ' ' |
hmm interesting. thanks.
i am using dsl, with a linksys wireless router. i do have the internal ip's static though for port forwarding purposes |
If you don't want to register a name with a DNS and update your changing ip with something ddclient, you could resolve your ip from whatismyipaddress.com by
wget -O - http://www.whatismyipaddress.com 2> /dev/null | grep IP | awk '{print $6}' So, you might try something like the following Code:
#!/bin/bash |
If you are really interested in doing it yourself then search the website.
http://www.linuxquestions.org/questi...address+script |
Quote:
|
All times are GMT -5. The time now is 12:10 AM. |