You are currently browsing the archives for July 2011.
Displaying 1 - 2 of 2 entries.

Knowing your dynamic IP-address

  • Posted on July 25, 2011 at 18:53

The troubling situation
Being a nerd, there is nothing more frustrating than having a dynamic IP-address.
Being a nerd and doing some hosting locally actually makes it even wors!

There’s not much use to running services like Apache or Sendmail with an IP-address that changes at random times.
Random in this particular case means: “When we of Ziggo want it to!”.

Alert by email
So what you basically want is to be alerted whenever you IP has changed.
I wrote some perl-code that does exactly that! And as a bonus, it does some handy logging.
The script can be initiated from command-line, but the best way is making a cronjob of course.

Realworld example
I created two new e-mailadresses; newipkrusjme@gmail.com and newipkrusjme@hotmail.com. Both addresses are now configured on my iPhone to receive all mail automatically,
In the cron, I set it to run as an hourly-job,
And then I did “the Dutch approach“…

Sourcecode
Thanks to Vim it was quite easy to make the sourcecode readable using :TOhtml.
If you love to see the amazing Vim-output or you’re actually seriously interested: You can find the sourcecode here: http://www.krusj.nl/files/newip-2.0.pl.html
Download directly: http://www.krusj.nl/files/newip-2.0.pl

Installing

  • download the script, (for example to /usr/local/bin)
  • change the email-addresses to your preferred ones,
  • change the interface-card, (eth1, eth0 or whatever)
  • mkdir /var/log/newip /var/newip,
  • chmod 755 /usr/local/bin/newip-2.0.pl,

Testing / Forcing
If you want to test it, just run the script from command-line using:
# /usr/local/bin/newip-2.0 --force-mail

Processes and ports

  • Posted on July 19, 2011 at 08:04

Ever wondered which process is behind which port? Well, I do pretty often!
And also pretty often I have to look it up again…
Let’s change that for once and for all!

Here’s a really obvious example with port number 80 in use by Apache. (Such a surprise!)

Netstat: The syntax
# netstat -a -n -p | egrep 'Proto|LISTEN' | grep 80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1840/apache20

 

Forcing open doors
This output shows that Apache2.0 runs with PID 1840 and it’s listening to port 80.

After this I did a ‘ps aux | grep 1840’ and it turned out to be true! 🙂