星期六, 4月 30, 2005

DHCP & TFTP Server

Installation & Configuration
1. Prepare the diskette

1. Install syslinux on a computer (Windows or Linux)
2. Format a 1.44" diskette (Linux: format in MS-DOS format, e.g. mformat a:)
3. Install the syslinux bootloader on the diskette
4. Unpack the dhcpdtftpd-x.y.tar.gz archive.
5. Copy the contents of the directory named disk to the diskette with the syslinux bootloader.

Now you have a bootable diskette with the DHCP & TFTP server on it.

2. Configure the server

You have to configure the network and the server settings on the diskette:

1.

Configure the network interface(s) of the server by editing the rc.net file on the diskette. If you are not familiar with Linux networking, just modify the included example according to your network setup.

If you have multiple network cards, repeat step 1 for each card. It is important that a default route is set to every network interface that serves DHCP requests.

The easiest way to find out which ethernet interface corresponds to a network card is to setup all network cards and connect only one network card and ping the server. Connect the cable to all the cards one by one and mark the card where you get an answer to the ping.
2.

Configure the DNS server in resolv.conf. You can specify several nameserver lines for several DNS servers.
3.

Configure the DHCP server in dhcpd.conf. If you are not familiar with the ISC DHCPD, try to modify the example configuration. Read the dhcpd.conf manual, the dhcp-options manual and the dhcpd manual for more information.
4.

The TFTP server is enabled by default and has nothing to configure. Put files to be available via TFTP into the tftp directory on the diskette.
5.

The Web management interface is enabled by default. The htpasswd file contains username/password pairs for the web-server. To disable access control delete this file. The included example defines a user "admin" with password "admin". You can use the standard NCSA htpasswd program to change the password or add users.

To disable the web server (and web management) altogether put a # in front of the line starting with mini-httpd in rc.boot.
6.

rc.boot is the main startup file. It calls rc.net to setup the network and starts the DHCP and TFTP server. Normally there is no need to change anything in it, but you can further adapt the server to your needs in this file (e.g. change the port the web server listens to, disable the interactive shell to prevent people from "playing" around, etc.).

This is all configuration neccessary to get a running DHCP & TFTP server.
3. Debugging and Troubleshooting

By default the DHCP server is started on console 2 and the TFTP server on console 3. Press Alt and a F-Key (e.g. Alt+F2) to switch between consoles. On console 1 (the default console) an interactive shell is started. In this shell you can type commands to get information about the server configuration or troubleshoot it. For real debugging a basic knowledge of Linux networking is neccessary.

* Check the network card setup with ifconfig. Make sure that the packet TX and RX counters are different from 0 (assuming the NIC was connected to something that makes traffick). ifconfig also shows the hardware configuration of the network cards (MAC address, interrupt, io ports ...), make sure that they seem reasonable and match the network cards' setup. Make sure that the IP address, netmask and broadcast address match your network. A typical ifconfig output looks like this:

eth0 Link encap:Ethernet HWaddr 00:A0:C9:C6:5B:05
inet addr:111.11.1.111 Bcast:111.11.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3407251 errors:0 dropped:0 overruns:0 frame:0
TX packets:99120 errors:0 dropped:0 overruns:0 carrier:0
collisions:166
Interrupt:11 Base address:0x6100

eth1 Link encap:Ethernet HWaddr 00:A0:C9:A0:F7:0B
inet addr:111.11.2.111 Bcast:111.11.2.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2810214 errors:0 dropped:0 overruns:0 frame:0
TX packets:139755 errors:0 dropped:0 overruns:0 carrier:0
collisions:41
Interrupt:10 Base address:0x6200

* The routing can be checked with route. Use route -n to disable DNS lookups in case route takes long to produce results. Make sure that there is a default route to each network interface (for DHCP broadcasts). A typical route output looks like this:

Destination Gateway Genmask Flags Metric Ref Use Iface
111.11.1.0 * 255.255.255.0 U 0 0 373 eth0
111.11.2.0 * 255.255.255.0 U 0 0 223 eth1
default * 0.0.0.0 U 0 0 1379 eth0
default * 0.0.0.0 U 0 0 1087 eth1

* The server answers echo requests so that you can ping it to check wether it is available.
* The following Unix commands are available on the server:
df, fromdos, mount, sed, todos, dhcpd, grep, ls, sh, tr, cat, echo, ifconfig, reboot, sleep, umount, cp, fold, mkfs, route, tftpd, uptime

The Workings

The diskette contains a Linux kernel and a small RAM disk with the neccessary programs. The server runs completely in RAM, it does not need a HD (it won't touch any installed HD). The configuration files are read from the diskette during startup and all files on the diskette are exported via TFTP.
System Requirements

Hardware: Minimum 586 with 16MB RAM, network cards (3C905, Intel100, some NE2000), 1.44" diskette drive. The server supports as many network cards as you can fit into the computer.

Software:Windows 9x/NT/2000 or Linux to make diskette, Webbrowser for management (optional). You will need syslinux to create the boot disk. For remote booting with PXE I recommend BpBatch, this is what I made this server for originally (If you don't need the TFTP server, you probably won't need BpBatch either).
The Server Programs

DHCP: The DHCP server is the standard ISC DHCPD server version 2.0pl5.

TFTP: The TFTP server is the extended TFTP server from bootix as mentioned in the Linux Mini-Howto on the BpBatch site.

HTTP: The webserver is the mini_httpd from ACME Labs, a tiny HTTP server with CGI support. The web management is done via 4 shell scripts.
The Diskette

The diskette contains the following files:
bpbatch BpBatch boot loader (not included)
bpbatch.P BpBatch boot loader for extended TFTP (not included)
dhcpd.conf DHCP Server configuration
initrd.gz Linux RAMDISK
rc.boot Startup script
resolv.conf DNS configuration
htpasswd Password for Web management
linux Linux Kernel
rc.net Network setup script
syslinux.cfg Bootload configuration

Only dhcpd.conf, rc.boot, rc.net, htpasswd, resolv.conf need to be changed by the user. The other files do not contain any changable settings.
Sources

In the src directory of the distribution are the sources of some non-standard programs used. All other programs are taken from a vanilla SuSE 6.0 Linux. The kernel is a 2.0.38 kernel

沒有留言: