Configure dhcp
From MythDora
DHCP is a protocol and a service (program) that is used to transmit important network information to a computer while it is starting up.
Since most private networks use a router, wireless access point, cable/xDSL modem to provide DHCP for the network already, why setup a MythDora backend to provide this service? Like anything else, the current provider of DHCP does offer the customization that is needed for special setups. These setups include but are not limited to:
- Diskless workstations for remote frontends.
- Using the Hauppauge MediaMVP as a remote frontend.
- Installing MythDora over the network if the frontend does not have a CD/DVD drive.
Contents |
Disable DHCP on the Current DHCP Server
For this to work, the current device that provides DHCP must have DHCP disabled. This howto does not address this process as it is unique to each device and sometimes different devices from the same vendor. Look for the manufacturer and model number of your modem, wireless access point, or router. Then find the manufacturer's web site and look for the manual for your device and follow the instructions there. After you have disabled DHCP on your providing device, think about sharing that with the MythDora community and write a step-by-step howto and post it to this wiki.
Note: if a computer other than the MythDora backend is to be used for the rest of this howto, make sure you start it before disabling DHCP, otherwise it may not be able to start.
Configure and Enable DHCP on the MythDora Backend
The fine folks at MythDora have included DHCP in version 4 so there is no need to install any packages. Make sure you send them a big thank you and consider a donation to keep this project alive. (Note: the author is not a developer of MythDora, just an open source software enthusiast and believes that the authors of such deserve renumeration for their work)
The following commands are entered using a keyboard/monitor/TV attached directly to the MythDora backend, or you can establish an SSH session from a remote computer.
If you are at the keyboard/monitor of the MythDora backend, and the backend is running as a frontend, at the main menu select MythDora Tools|Launch Xterm and skip the next step.
If you are using a remote computer on the same network as the backend, start the SSH session now and login as the user mythtv with the password mythtv.
Enter the following commands or use copy/paste them into the terminal window
To determine the address of your network enter
ifconfig
There should be two sections, one labeled eth0 and the other labeled lo. Look at the information in the eth0 section. Find the headings inet address and Mask. Associated with these headings is a set of four numbers separated by periods. For each number in the Mask that is 255, write down the associated number in the inet address. Ignore the numbers in the inet address that have a zero associated with them in the Mask. For example:
- inet addr:192.168.0.254 Mask:255.255.255.0 Write down 192.168.0
- inet addr:172.18.0.254 Mask:255.255.0.0 Write down 172.18
- inet addr:10.0.0.254 Mask:255.0.0.0 Write down 10
- inet addr:10.1.2.3 Mask:255.255.255.0 Write down 10.1.2
Now add enough periods and zeros to make an address that is 4 numbers long.
- 192.168.0 becomes 192.168.0.0
- 172.18 becomes 172.18.0.0
- 10 becomes 10.0.0.0
- 10.1.2 becomes 10.1.2.0
This new address is the network address. Also record the Mask address and the Bcast address.
Enter the following commands
su -
Enter the password for the root user when prompted. This is the substitute user command and elevates permission status to that of root.
nano /etc/dhcpd.conf
This starts the full screen editor nano and loads the configuration file for DHCP.
Enter the following. While in nano, enter all the characters including the # sign:
#
#DHCP Server Configuration file.
#see /usr/share/doc/dhcp*/dhcpd.conf.sample
#
authoritative;
option routers 192.168.0.1;
option domain-name-servers 192.168.0.1;
option broadcast-address 192.168.0.255;
default-lease-time 259200; # 72 hours
max-lease-time 777600; # 216 hours
subnet 192.168.0.0 netmask 255.255.255.0 {
range 192.168.0.2 192.168.0.150;
option subnet-mask 255.255.255.0;
}
The directives option routers and option domain-name-servers are likely the address of your router/modem/access point. The option broadcast-address is the Bcast recorded earlier.
For the subnet and netmask directives, use the network address and mask address from above.
The directive range 192.168.0.2 192.168.0.150 defines how many host addresses can be handed out and managed by the DHCP server. You must make sure that the first host address (192.168.0.2 here) and the last host address (192.168.0.150) and all the addresses between are not used by another computer on the network. If you have no idea what to use here, then replace 192.168.0 with the network address found above and add 2 and 150 respectively for the first and last host address.
Double check what you have done in the file to make sure all is well. Specifically, look for semi-colons and braces missing as these are the cause of most problems. Hold down Ctrl and press X to exit. When prompted, enter y to save the file.
Test and Start DHCP
At the terminal prompt (and still as root) enter:
chkconfig dhcpd on
to make sure DHCP starts every time the computer boots.
Now, run a test on the configuration file you created above. Enter
service dhcpd configtest grep dhcpd /var/log/messages | less
If you see this message
Not searching LDAP since ldap-server, ldap-port, ldap-username, ldap-password and ldap-baes-dn were not specified in the config file.
and nothing else, all is good and you can continue. If you see additional messages, see the Troubleshooting section. Since all is well, press q to exit the log file display.
Start the DHCP service with the command
service dhcpd start
If you see the message
Starting dhcpd: [OK]
congratulations, your MythDora backend is now managing DHCP on your network. Enter
exit
To close the terminal window.
If you don't see this message, see the Troubleshooting section.
Troubleshooting
Troubleshooting and debugging is done at a terminal window as root.a
Display the log file with
grep dhcpd /var/log/messages | less
and scroll through the file with the up and down arrow keys. Look for messages like this
(date/time/servername) dhcpd: /etc/dhcpd.conf line n: semicolon expected.
(date/time/servername) mythserver dhcpd: option
(date/time/servername) mythserver dhcpd: ^
The n in line n above represents the line number of the problem. Open /etc/dhcpd.conf in nano and move to line n. Next, look at the end of the line above line n. Is there a semicolon at the end? Probably not. Add the semicolon, exit and save the file, and retest the configuration file. Be sure to look at /var/log/messages to see if the error is gone. If so and no other errors are present, start the service and exit the terminal window as above.
Another error that may appear in the file is
(date/time/servername) mythserver dhcpd: /etc/dhcpd.conf line n: unexpected end of file
(date/time/servername) mythserver dhcpd:
(date/time/servername) mythserver dhcpd: ^
Again, line n in the above example is the line number in dhcpd.conf where the error is located. Open dhcpd.conf and move to the line number displayed above. Most likely this is the end of the file and is not the real location of the problem. What gives? This error is normally the result of a missing opening brace { or closing brace }. Carefully scan the file and make sure that you did not leave out any braces from the example above. If so, enter them in the file, exit and save the file, and retest the configuration file. Be sure to look at /var/log/messages to see if the error is gone. If so and no other errors are present, start the service and exit the terminal window as above.
Any other problems are going to take some more research. Try googling the error message or post a message to the MythDora forum.
References
- Internet Systems Consortium home page for DHCP http://www.isc.org/index.pl?/sw/dhcp
- Linux Home Server Howto by Miles Brennan http://www.brennan.id.au/10-DHCP_Server.html
- DHCP documentation included with MythDora (Fedora Core 6) /usr/share/doc/dhcp* in the MythDora filesystem.
