LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 10-31-2008, 07:11 PM   #1
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,407

Rep: Reputation: 141Reputation: 141
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?

Last edited by Quakeboy02; 10-31-2008 at 07:15 PM.
 
Old 10-31-2008, 08:18 PM   #2
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
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
192.168.1.102 linux2.example.net
192.168.1.103 windows.example.net
192.168.1.104 mac.example.net
 
Old 10-31-2008, 08:28 PM   #3
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,407

Original Poster
Rep: Reputation: 141Reputation: 141
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
 
Old 10-31-2008, 08:48 PM   #4
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by Quakeboy02 View Post
Yeah, I understand that, but then I have to replicate the /etc/hosts file among all my machines
Which on four machines would take like two minutes to set and forget.

Quote:
I have no intention of setting up a private DNS for four machines.
Which is why I figured using /etc/hosts instead might be something you would be interested in.

I see now that you're not, that's fine.

Quote:
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
I'll stand back and let someone familiar with Windows networks answer that.

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?

Last edited by win32sux; 10-31-2008 at 08:52 PM.
 
Old 10-31-2008, 08:58 PM   #5
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,407

Original Poster
Rep: Reputation: 141Reputation: 141
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?
The device itself? No. All I know about it is that it's a 3800HGV-B. It's giving me private IPs in the 192.168.1.x subnet. Oh, and my daughter has some gaming doohickies attached, so we'd need the DHCP in any case, I think.
 
Old 10-31-2008, 09:14 PM   #6
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by Quakeboy02 View Post
The device itself? No. All I know about it is that it's a 3800HGV-B. It's giving me private IPs in the 192.168.1.x subnet. Oh, and my daughter has some gaming doohickies attached, so we'd need the DHCP in any case, I think.
Does it have a DNS daemon on it? What gateway address does its DHCP give you? Is the IP it gives you for DNS servers (look in your /etc/resolv.conf) the same as the gateway address or is it like ISP nameservers? Do you have a control panel on this device?

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.

Last edited by win32sux; 10-31-2008 at 09:18 PM.
 
Old 10-31-2008, 09:23 PM   #7
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,407

Original Poster
Rep: Reputation: 141Reputation: 141
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.
 
Old 10-31-2008, 09:29 PM   #8
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
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.
 
Old 10-31-2008, 10:09 PM   #9
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,407

Original Poster
Rep: Reputation: 141Reputation: 141
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
returns:

Code:
querying hedgehog on 192.168.0.255
querying hedgehog on 192.168.1.255
192.168.1.69 hedgehog<00>
 
Old 10-31-2008, 10:10 PM   #10
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
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}'
BTW, why do you ignore so many of the questions I've asked you?

Last edited by win32sux; 10-31-2008 at 10:17 PM.
 
Old 10-31-2008, 10:16 PM   #11
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,407

Original Poster
Rep: Reputation: 141Reputation: 141
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
would be seen as:
Code:
rsync -av quakeboy@192.168.1.69:/fromhere  /tothere

Last edited by Quakeboy02; 10-31-2008 at 10:17 PM.
 
Old 10-31-2008, 10:23 PM   #12
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
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
nmblookup -B -L $1 | tail -n 1 | awk '{print $1}'
Now the nmblookup will be done for whatever you pass as an argument.

Last edited by win32sux; 10-31-2008 at 10:26 PM.
 
Old 10-31-2008, 10:32 PM   #13
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,407

Original Poster
Rep: Reputation: 141Reputation: 141
Quote:
BTW, why do you ignore so many of the questions I've asked you?
Sorry, I guess I missed a couple. Didn't mean to. If you're referring to the WRT54G, I started to answer that, but then got sidetracked and never got back to it. I've got a WGT624 here, and I'm waiting for OpenWGT to get around to it.

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.
 
Old 10-31-2008, 10:34 PM   #14
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Cool, let me know if the script works.

Last edited by win32sux; 10-31-2008 at 10:37 PM.
 
Old 10-31-2008, 10:37 PM   #15
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,407

Original Poster
Rep: Reputation: 141Reputation: 141
Quote:
Originally Posted by win32sux View Post
Cool, let me know if the script works.
Sweet! I'll have to figure out whether I need to do something different for hosts that aren't there or are typed wrong. But, it gives "name_query" in those cases, so that'll probably work well enough.

Thanks again!

Added:
Yes it works.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to configur DNS & DHCP in real environment mail2azharuddin Red Hat 1 08-12-2008 10:01 AM
How to play a video file on a machine without a desktop environment? lumix Linux - Software 2 05-20-2008 04:28 PM
Dual Boot Machine Fedora 5 / WinXP, XP messes up the IP addressing hferretluv Linux - Newbie 11 06-12-2006 11:47 PM
Multiple DHCP environment MarvinChao Linux - Wireless Networking 1 03-14-2004 12:32 AM
Reinitialising environment variable without restart the machine yenonn Linux - Newbie 7 02-28-2003 11:07 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 04:23 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration