Friday, July 29, 2005

changing ips

Changing IPs

The computer I use in my office at school has this habit of renewing its IP every time it reboots. It's not the computers fault, it's network services fault for not giving static IPs to the computers. My biggest problem with that is I can never figure out what the new IP is without a little bit of work. Well, no more! It's easy from here on out.

The solution was simple. Have the computer email me the new IP every time it reboots itself. And since it's emailed to me, I can access that from anywhere as well. Here's how it's done.

I wanted to edit/create the S99local script in /etc/rc2.d
In my case, I had to create it.

> ls /etc/rc2.d

comes up with a whole lot of S* scripts. I didn't see the S99local so I created it.

> sudo emacs /etc/rc2.d/S99local

and wrote the following
------
#!bin/sh
ifconfig | grep inet | mail -s "new IP for work computer" myEmailAddress@theHost.something
end
------

The above is a shell script, that's why it starts with #!bin/sh and the rest is kind of self explanitory. And if not, just know that it does work.

I then changed the file via

> sudo chmod a+x S99local

so it can be run by the shell. Now every time the system restarts it emails the new IP to my gmail account. That makes it a lot easier than how I was doing it. I used to scan the whole university computer system looking for computers with an open ssh port 22. I'd pipe the information to a text file and pull out entries with 'open ssh' and try to SSH my account on there. That took a while because there are a lot of computers on the system with an open port 22.

-Much easier now

No comments:

Followers