Advertisement

DHCP

Started by February 12, 2003 09:24 PM
3 comments, last by outRider 21 years, 11 months ago
I''m not the biggest expert when it comes to network programming, but I need to write a DHCP server app to hand out IPs, subnets mask, and default gateways to the machines on my home network (one of which is an XBox). I didn''t do anything with networks before attempting to hook up my gateway, but as far as I understand it... The NIC attached can have any number of IPs, gateways, and subnet masks. It recieves IP, SNM, DG, and DNS info from a DHCP server when I connect to my ISP. It can also have other IPs that are not visible on the internet, but only on the network. Other devices on the network can then request the above info from in the same way. Right now I have the intended server machine using a static internal IP and SNM, and the other machines also use static IPs, the same SNM, and their default gateways are the IP of the intended server. I''m not sure what a subnet mask does, but mine is 255.255.255.0, which I assume works like a bitmask 0xFFFFFF00... I found the following link which appears to describe the communications that go on between DHCP clients and servers. http://support.microsoft.com/?kbid=169289 I''m also assuming I should start looking into Winsock 2 for this. Any starting tips would greatly be appreciated. ------------ - outRider -
Is there any reason why you can''t use an existing DHCP server?

Reinventing a DHCP server sounds like a mess.

Subnet masks are used for bit comparisons with the network address assigned to the machine to determine subnet and network addresses. Hosts use the subnet mask to decide if it should try to locate the destination on it''s local subnet (issue an ARP for the corresponsing MAC) or forward the packet onto it''s gateway (determined by the route table).

Maybe if you explain your scenario in a bit more detail you can get some suggestions on how to build your network. You can probably configure your gateway machine to treat IPs on your physical network loop as across network address spaces (i.e., route them) even though they can see each other locally. To your program, it will still be as if working with a router.

http://www.isc.org/products/DHCP/

Try that link for some more information on DHCP (references to the RFCs and other material on the net). It also has links to the DHCP server implemented on most open source unix platforms. Maybe Linux with DHCPD would be helpful? It''s also open source, so if you decide you need to write your own, you can use that as a starting point, or modify it if you need some odd functions.

But I''m still guessing you can solve your issue without building a new DHCP server =)

Interim
Advertisement
Thanks for the link. I already knew that I could use one of the many programs out there that provided DHCP service. I just figured I might use this as a learning experience.

Anyhow, here''s what''s going on. I''ve got some PCs and an XBox, all connected to a DSL modem via a hub. The PCs network fine using whatever protocol Windows uses to handle local networking. For the XBox I assign it a static IP, likewise with the comp (both IPs on the same subnet), both have the same subnet mask, and the XBox has the PC IP as its gateway. That works fine, I can FTP to the XBox just fine, but for some reason or another which I won''t get into here I need to assign it a dynamic IP. Like I said, I know I can download software that does that, but I figured it might not be too hard, just intercepting packets and finding DHCP requests and responding to them.

------------
- outRider -
You could configure DHCPD with access-list control based on MAC and some other criteria if you just want to server one IP address.

But, if you''re learning that''s great. Definitely read over the RFC web link from the ISC link I passed before. I''d also grab their source code for DHCPD. You can probably use some of their libraries to cut a few corners. Unless you''re a glutton for full punishment, which is also awesome =)

G''luck
Sounds like a fun project. I''d definitely grab the RFC as well as the DHCPD source code. Learning more doesn''t necessarily mean re-writing everything, right? You could probably use a few of their libraries to get it done quicker.

Either way, sounds like a fun project. The DHCPD is pretty good, but I''ve found it still isn''t perfect for some weird scenarios such as multihomed DHCP servers and such. At least when we set up a test environment here at work.

G''luck.

This topic is closed to new replies.

Advertisement