Addressing a machine in a DHCP environment
I've got a couple of Linux machines, a Windows XP machine, and my daughter's Mac here at the house. We get our IPs from an AT&T router/gateway, and of course they're always the same IPs; except when I go experimenting with bridging etc. So, my question is: How can I address all these DHCP clients by name, so that I don't have to just go look to see what address they've gotten? Would I somehow use Windows networking to get to it? Is there some way to tell the DHCP server what my machines names are? What am I missing about a DHCP environment?
Added: As an example of what I want, suppose I want to rsync to one of the machines. What do I type if I don't want to go take a look a the machine to see what it's address is, but I know it's name? |
One way to approach this could be to forget the DHCP server and just give all the boxes a secondary static IP. Then in the /etc/hosts files you put whatever names you want for the boxes like linux1.example.net, linux2.example.net, windows.example.net, mac.example.net, etc. The /etc/hosts file might look like:
Code:
192.168.1.101 linux1.example.net |
Yeah, I understand that, but then I have to replicate the /etc/hosts file among all my machines, which of course is why we have DNS. I have no intention of setting up a private DNS for four machines.
Is there a way through a shell script that I could use windows networking to get an ip for a machine in a windows workgroup? example: Code:
rsync -av quakeboy@`myscript hedgehog`:/fromsomewhere /tosomewhere |
Quote:
Quote:
I see now that you're not, that's fine. Quote:
Regarding the OP, do you know what DHCP daemon the device runs? Knowing that can help someone tell you how to get client IDs to work with it so that your boxes always get the same hostname regardless of IP. BTW, is it giving you public or private IPs? |
Quote:
|
Quote:
Telling a DHCP server to always give you a certain client IP and/or hostname should be really easy (unless your ISP has restricted administration options on the device, or if it lacks them). But if the device doesn't come with a DNS daemon then you're gonna have to bind the hostname to the IPs in some other way, such as installing dnsmasq or something. |
I always get the same IP unless I fool it with something I have going on here, such as turning off the wireless card and plugging into a wireless bridge. We wanted to backup some 35GB of data from my daughter's Mac and via wireless just wasn't cutting it, so I strung a wire and then tried to route through her bridge. Other things like that tend to change my IP on this machine. We don't do that stuff on the others so they're stable. I don't see any way into the device, itself. There are some maintenance items when I point firefox at it, but I don't really want to try to get into the thing.
BTW, I've got dbndns (debian vsn of djbdns) running on my Linux machines. I don't try to tell my daughter what to do on her Mac ;), and the XP box is just turned on to serve the printers in the other room. Oh, and the reason I don't want to run DNS is because I'd be compelled to leave one or two machines running to serve it. Not such a good limitation in a home environment. I'll have to research how to get the IP for a samba device. Maybe there's an answer there. |
Have you considered buying something like a WRT54G? I think they're like less than 40 bucks now and you can install a nice firmware GNU/Linux distro on it (Tomato, for example) which will let you handle all of this stuff for your network with great convenience. I think even the stock firmware does what you want.
|
I just found "nmblookup" and it kind of does what I want, but the output is noisy. Maybe I could do some awk magic on it and clean it up enough to use.
Code:
nmblookup -B -L hedgehog Code:
querying hedgehog on 192.168.0.255 |
What are trying to get it to look like?
Like this: Code:
192.168.1.69 hedgehog If so, this would do it: Code:
nmblookup -B -L hedgehog | tail -n 1 | awk '{print $2 $1}' | awk -F"<00>" '{print $2 " " $1}' |
I just want a script that I can enter the samba machine name and get the ip address out. If the machine isn't connected or turned on, I suppose null would be appropriate. What I was thinking of was to be able to rsync without having to remember what the ip address was. Something like this:
Code:
rsync -av quakeboy@`myscript hedgehog`:/fromhere /tothere Code:
rsync -av quakeboy@192.168.1.69:/fromhere /tothere |
Replace the "hedgehog" in the command I posted with a $1 and stick it in a text file.
Edit the awk part so that only the IP is output. Code:
#!/bin/sh |
Quote:
BTW, I now see that you posted the answer already, but I just didn't see it on the page. Did I forget to scroll down? Dang. Sorry about that. |
Cool, let me know if the script works.
|
Quote:
Thanks again! Added: Yes it works. :) |
Quote:
Code:
#!/bin/sh |
Good idea, but I think I'd need:
Code:
#!/bin/sh |
Haha, word! I'd completely forgot about the directory paths! :)
|
Quote:
In file /etc/dhcp3/dhclient.conf Code:
change this line: |
All times are GMT -5. The time now is 10:54 AM. |