PDA

View Full Version : what are the benefits of dhcp in a LAN?



user unknown
08-18-2004, 08:30 AM
I see a lot of people, using dhcp for their lan, and don't understand the benefits.

I'm used to static IPs.
My example is: I have a /etc/host:
192.168.4.2 desktop
192.168.4.3 laptop

To make a filetransfer, I start

ftpd
on the desktop, and

ftp desktop
on the laptop.

When I use dhcp, will the laptop find the desktop too?
I need a hardware-router for this - or an additional service running permanently in the background, don't I?

Harry Kuhman
08-18-2004, 09:29 AM
I see a lot of people, using dhcp for their lan, and don't understand the benefits.
With DHCP, IP addresses are assigned automagically. Without DHCP you have to assign an unique IP address in your subnet to every computer in your system.

While it might not be that big of a deal to set up a static IP address on a ciouple of computers in a home system, if you are testing other equipment DHCP takes care of this for you. If someone comes over with a notebook and you plug them into your system, DHCP assigns them a unique IP address on your network, even if the IP address they had on their home system is already in use by another of your computers (very handy for a lan party when several people come over). And, of most relavence to a Knoppix forum; if you boot Knoppix from CD and have DHCP available, you will be on the network as soon as you boot, with no set-up needed at all (assuming the boot version of Knoppix has support for your NIC and some evil company that hates Linux hasn't played games with your NIC's EEPROM in a "security update:, but that's another story).



I'm used to static IPs.
My example is: I have a /etc/host:
192.168.4.2 desktop
192.168.4.3 laptop

To make a filetransfer, I start

ftpd
on the desktop, and

ftp desktop
on the laptop.

When I use dhcp, will the laptop find the desktop too?

That's not DHCP exactly, that's Name Resolution. How it works in Linux I'm not sure. Yes, it works that way in Windows just fine, I can talk to my VPN server by telling the VPN client that I want to connect to 192.168.2.100 or that I want to connect to "AMD". I can ping by IP address or by name. And so on. Name resolution should work in a system independent of using DHCP or static addresses (in fact, there is no reason why you can't have a network with some static addresses and some dynamic ones. There are actually some good reasons for doing this if your DHCP server doesn't allow you to permanently lock some computers to dedicated addresses).


I need a hardware-router for this - or an additional service running permanently in the background, don't I?

Well, for DHCP, something has to be a DHCP server. If you have a high speed connection, I personally wouldn't consider runnng it without a router. (Please note: I'm talking about even a mininal $10 home DSL/cable router, not some expensive piece of Cisco equipment.) And certainly this is even more true if you have multiple computers on the network. In fact I'm wondering how you think it is that you are running a network with two computers on the private 192.168.xxx.xxx subnet without a router to provide NAT services (unless that's a completely independent network from the one you access the Internet with). But while a DHCP server needs to be somewhere, there is at least one simple case where you can and do use DHCP without having a router or other hardware or an additional service running in the background: Most high speed cable users connect to their provider and get their IP address from the cable company's DHCP server. So if you are on cable you can usually boot and have Knoppix come right up on the Internet on a computer connected directly to the cable modem (this is not true for cable companies who assign each user a sttatic IP address that they have to configure into their software before connecting, not is it true for DSL users without a router who must run PPPoE to connect to their modem). I certainly don't recommend connecting to the Internet this way, as a router provides an extra and important lever of firewall security as well, but it can and is frequently done.

Harry Kuhman
08-18-2004, 09:56 AM
I'm used to static IPs.
My example is: I have a /etc/host:
192.168.4.2 desktop
192.168.4.3 laptop

One update: rereading your post and seeing that you are manually putting the addresses in the host file to do your name resolution, I do see why you would question this. I don't know if Linux has better ways to deal with resolving these names for you; it's not part of DHCP. Many home routers will let you dedicate an IP address to a MAC adderss, so they can be sure to assign the same IP to a computer whenever the system is rebooted. The Dlink brand of routers that I have seen do this, and I like them for several other reasons too. Unfortunately, some other routers do not assure you that the same IP addresses will be given out to the same MAC addresses each time, particularly on a network where the computers come and go (the SMC router I have, for example, is particularly poor at this, even though it has a feature to make the DHCP lease "forever". Apparently forever starts over after a restart).

So if you do use a router and still want to resolve names with your host file, make sure these addresses don't change (either by using a router that gives out the same IP address by DHCP each time (when you configure it to do so) like the Dlink, or by setting these systems up as you have now with static addresses. Additional computers could still join the network and be assigned an address by DHCP, but they wouldn't have a name in your host file unless you added one. I'm hoping someone else will join in and teach us both if there is a better more automatic way in Linux to do name resolution than editing the host file on every system.

BY the way, there is a good reason to use DHCP to hand out a "permanent" address rather than setting it statically. Consider your laptop. If you configure it with DHCP, when you carry it to work, to an friend's network, to a lan party or to an Internet cafe, you can just plug in and DHCP will configure your IP address for you. When you come back to your home network, DHCP puts things back where they should be. With a static IP set in the laptop, you have to reconfigure things every time you move to a new network (except in the rare case where you have two networks and made sure the same static address will work on each network).

shah
08-18-2004, 10:03 AM
Easy but unsecure ? :roll:

Harry Kuhman
08-18-2004, 10:11 AM
Easy but unsecure ? :roll:
Who's easy? you?

user unknown
08-19-2004, 06:27 AM
Whooo!
Thanks for the long reply.

Well - I should have said that I don't visit lanparties.
I move my laptop sometimes to a friend, and he his laptop to my network.

And I don't work at several places, so the hosts-file keeps permanent small.

And I use pppoe - but get an additional adress for the internet-connection.
So I may start ftp, ssh, and my database, and tell it, which host (ip or name) is allowed to connect.
Therefore I don't see a need for a firewall.
And if I use the internet from both machines (which is seldom), I start a router on one of the linux-machines.
With dhcp I would need to allow access from the whole subnet, to allow the laptop to use the desktop-database, or I would need an additional service, to get the actual IP for the hostname 'desktop' for instance.

I guess under this circumstances, a static IP is a much faster and more easy solution.

But of course if you visit lanparties, an automatic solution is much more easy.

In general I prefer the handmade control over automatic services - which need to be setup too.