How to get IP of computer assigned by DHCP?

I have a computer at work with no control over the network settings. We have to pay for a static IP so that won't happen. I'm running an SSH server so I can connect back and analyze data when I'm sitting in boring classes.

I want to know how to get the IP of this machine when I'm on the same network.

Previously what I would do is either grab it before I leave the office, or I set up a script in mail that would email me the IP address if I sent a very specific e-mail to myself.

I'm not very good with networking, and to make matters worse, I'm on an iPad with no true access to a console.

No, this is not illegal, I'm friends with the IT guy on the floor, and he says it's perfectly fine. However, I don't think running a network scan would go unnoticed.

So, what is the best way to do this? My e-mail script only works if the computer isn't asleep, and it especially doesn't work if I forget what to e-mail myself.

Any help?

I could potentially connect to my home server, VPN into the network, then run a bash script that looks for my server but... I don't think that's a great idea.

I'm not really sure what this bit means. Why would it be asleep? Are you thinking of a Windoze server hibernating?

Try ifconfig -a or get the output of hostname and from your remote client, use nslookup the-hostname or even just ssh the-hostname

Does that help, or have I missed the point somewhere?

Robin
UK

You could use a free DDNS service and register the ip you get served during DHCP...then you should not care about the actual IP.

If you're looking for the external IP, yes, dynamic DNS is a good way to do this. You can use a free DNS service like no-ip.com, to host a URL like mycomputer.bounceme.net, and run an updater client on your computer to keep mycomputer.bounceme.net pointing to the correct IP. There might be an occasional bit of lag between IP and DNS but it's pretty good for the most part. This is how we manage our crummy ISP's IP at work.

Of course, nothing's going to work if your computer's asleep!

Maybe you can get your work computer's IP and host name with

host `hostname`

or

getent hosts `hostname`

Then you can pipe this to mail, for example

host `hostname` | mail yourmail@youraddress

I think if I "ssh 'hostname" that might work. I guess I could check through the vpn.

For those of you confused here is what's going on.

I have a Mac desktop that I use for my day to day work. Sometimes I want to ssh into it from my iPad over wifi to do some data analysis, so I have an ssh server running. Just the standard ssh server that ships with os X, nothing special. Only I have permission etc.

However, the intranet at work is DHCP based. I cannot request a static IP because it costs money (stupid I know.)

Sometimes I forget to grab my IP before I leave the office, so if I want to ssh into the computer I can't, because of DHCP. So my original question was what is the best way to get that IP if I am not currently in front of the computer.

I did not know you could use the hostname of a computer as the address essentially. As I stated before, I'm terrible at networking.

With that said, it iSSH on the ipad does not like using the hostname over a VPN (I'm testing it from home currently), but using the IP works perfectly.

Putty on XP says "host does not exist" when connected through the VPN even when I copy and paste the hostname from the result of the "hostname" command. Putting the IP into putty works just fine.

---------- Post updated 01-15-14 at 12:34 PM ---------- Previous update was 01-14-14 at 10:08 PM ----------

Sorry for the double post, I thinking I found some more hints about my problem.

My ip when I'm on the wireless network is aaa.bbb.100.### and the ip of the server is aaa.bbb.185.### where aaa and bbb are the same. So, in my limited knowledge of networking, I'd say that whenever I feed my ipad a hostname to try to connect to, it doesn't know where it is because it's on a slightly different network, but when I give it an ip, the ipad knows exactly where to look for the computer to find it.

I think I may be able to fix it by adding another DNS server in my network settings? But I don't know what to put. Or it has something to do with the hostname. The hostname I am using is something-computer.local. Can the .local be changed to tell the ipad to look somewhere else?

We know, and gave several answers.

Dynamic DNS remains a good option I think. It amounts to leaving a little client program running on your computer to update the IP address mycomputer.bounceme.net points to, where mycomputer.bounceme.net is a free domain name hosted by no-ip. There are many free services like this for exactly this purpose.

You could see if your server has an entry in /etc/resolv.conf (note it is not /etc/resolve.conf ) for other nameservers to add in to your clients list.

Of course, if your primary nameserver rejects the name, it may not try another. I've never tried this, so no promises!

Robin

I realize that Dynamic DNS are good, I have one running on my server at home but will they work for intranets? None of these IPs are external IPs, they are all internal to the work network.