Login ing the DHCP server and log DHCP logs

Source: Internet
Author: User
Tags syslog network troubleshooting rsyslog

Normally if you have a cable modem or DSL, you get your home PC's IP address dynamically assigned from your service provider. if you install a home cable/DSL router between your modem and home network, your PC will most likely get its IP address at boot time from the Home Router instead. you can choose to disable the DHCP server feature on your home router and set up a Linux box as the DHCP server.

This chapter covers only the configuration of a DHCP server that provides IP addresses. the configuration of a Linux DHCP client that gets its IP address from a DHCP server is covered in chapter 3, "Linux networking", on Linux networking.

Download and install the DHCP package

Most RedHat and Fedora Linux software product packages are available in the RPM format, whereas Debian and Ubuntu Linux use Deb format installation files. when searching for these packages, remember that the filename usually starts with the software package name and is followed by a version number, as in dhcp-3.23.58-4.i386.rpm. (for help on downloading and installing the package, see Chapter 6, "installing Linux software ".)

Managing the DHCP server

Managing the DHCP daemon is easy to do, but the procedure differs between Linux distributions. Here are some things to keep in mind.

  • Firstly, different Linux distributions use different daemon management systems. Each system has its own set of commands to do similar operations. The most commonly used daemon management systems are sysv and systemd.
  • Secondly, the daemon name needs to be known. In this case the name of the daemon isDHCPD.

Armed with this information you can know how:

  • Start your daemons automatically on booting
  • Stop, start and restart them later on during troubleshooting or when a configuration file change needs to be applied.

For more details on this, please take a look at the "Managing daemons" section of chapter 6 "installing Linux software"

Note: If you modify your daemon configuration file remember that the changes won't take effect till you restart the daemon.

Note: Remember to configure your daemon to start automatically upon your next reboot.

DHCPD. conf file

You can define your server configuration parameters in the DHCPD. conf file which may be located in the/etc/DHCPD or/etc/dhcp3 directories depending on your version of Linux.

Note:The skeleton DHCP. CONF file that is created when you install the package may vary in its completeness. in ubuntu/Debian, the skeleton DHCPD. conf file is extensive with most of the commands deactivated with a # sign at the beginning. in fedora/RedHat/centos an extensive sample is also created with activated commands. it is found in the following location which you can always use as a guide.

/usr/share/doc/dhcp*/dhcpd.conf.sample

Note:The DHCPD. conf configuration file formats in Debian/Ubuntu and RedHat/Fedora are identical.

Here is a quick explanation of the DHCPD. conf file: Most importantly, there must be a subnet section for each interface on your Linux box.

ddns-update-style interimignore client-updates subnet 192.168.1.0 netmask 255.255.255.0 {    # The range of IP addresses the server   # will issue to DHCP enabled PC clients   # booting up on the network    range 192.168.1.201 192.168.1.220;    # Set the amount of time in seconds that   # a client may keep the IP address  default-lease-time 86400;  max-lease-time 86400;    # Set the default gateway to be used by   # the PC clients    option routers 192.168.1.1;   # Don't forward DHCP requests from this   # NIC interface to any other NIC   # interfaces    option ip-forwarding off;    # Set the broadcast address and subnet mask   # to be used by the DHCP clients   option broadcast-address 192.168.1.255;  option subnet-mask 255.255.255.0;     # Set the NTP server to be used by the   # DHCP clients  option ntp-servers 192.168.1.100;   # Set the DNS server to be used by the   # DHCP clients  option domain-name-servers 192.168.1.100;    # If you specify a WINS server for your Windows clients,   # you need to include the following option in the dhcpd.conf file:  option netbios-name-servers 192.168.1.100;    # You can also assign specific IP addresses based on the clients'   # ethernet MAC address as follows (Host's name is "laser-printer":  host laser-printer {      hardware ethernet 08:00:2b:4c:59:23;     fixed-address 192.168.1.222;   }}## List an unused interface here#subnet 192.168.2.0 netmask 255.255.255.0 {}

There are too more options statements you can use to configure DHCP. these include telling the DHCP clients where to go for services such as finger and IRC. check the DHCP-options man page after you do your install:

[root@bigboy tmp]# man dhcp-options

Note:The host statement seen in the sample DHCPD. CONF file can be very useful. some devices such as network printers default to getting their IP addresses using DHCP, but users need to access them by a fixed IP address to print their documents. this statement can be used to always provide specific IP address to DHCP queries from a predefined a nic mac address. this can help to reduce Systems Administration overhead.

DHCP servers with multiple commands

DHCP servers with multiple interfaces pose two configuration challenges. the first is setting up the correct routing and the second is making sure only the required interfaces are listening to serve DHCP. don't worry, both will be discussed next.

Routing

When a DHCP configured PC boots, it requests its IP address from the DHCP server. It does this by sending a standardized DHCP broadcast request packet to the DHCP server with a source IP address of 255.255.255.255.

If your DHCP server has more than one interface, you have to add a route for this route 255.255.255 address so that it knows the interface on which to send the reply; if not, it sends it to the default gateway. (in both of the next two examples, we assume that DHCP requests will be coming in on interface eth0 ).

Note:More information on adding Linux routes and routing may be found in chapter 3, "Linux networking ".

Note:You can't run your DHCP sever on multiple interfaces because you can only have one route to network route 00000000255. if you try to do it, you'll discover that DHCP serving working on only one interface.

Temporary solution

You can temporarily Add a route to limit 255 using the route add command as seen below.

[root@bigboy tmp]# route add -host 255.255.255.255 dev eth0

If you want this routing state to be maintained after a reboot, then use the permanent solution that's discussed next.

Permanent solution

Create a permanent route to route 0000255. This will vary according to your version of Linux

Fedora/RedHat/centos:Add the route to your/etc/sysconfig/network-scripts/route-eth0 file if the route needs to be added to your eth0 interface.

## File /etc/sysconfig/network-scripts/route-eth0#255.255.255.255/32 dev eth0

Ubuntu/Debian:Add the route to your/etc/Network/interfaces file. In this case the route is added to the eth0 interface.

## File: /etc/network/interfaces#iface eth0 inet static       up route add -host 255.255.255.255 eth0

Simple Linux routing is covered in chapter 3, "Linux networking" and will add more clarity to adding permanent static routes.

Listening

Once you have defined the interface for your DHCP Routing you shoshould also ensure that your DHCP server only listens on that interface and no others. this methodology to do this varies depending on your versión of Linux.

Fedora/RedHat/centos:The/etc/sysconfig/DHCPD file must be edited and the dhcpdargs variable edited to include the preferred interface. In this example interface eth0 is preferred.

# File: /etc/sysconfig/dhcpdDHCPDARGS=eth1

Debian/Ubuntu:The/etc/default/dhcp3-server file must be edited and the interfaces variable edited to include the preferred interface. In this example interface eth0 is preferred.

# File: /etc/default/dhcp3-serverINTERFACES="eth0"

You will be able to verify success in one of two ways. First the netstat command using the-Au options will give the list of interfaces listening on the BOOTP (DHCP) UDP port.

[root@bigboy-f ~]# netstat -au  | grep bootpudp        0     0 192.168.1.100:bootps    *:*[root@bigboy-f ~]#

Secondly, your/var/log/messages file will also reveal the defined interfaces used when the DHCPD Daemon was restarted.

Jan  8 17:22:44 bigboy dhcpd: Listening on LPF/eth0/00:e0:18:5c:d8:41/192.168.1.0/24Jan  8 17:22:44 bigboy dhcpd: Sending on   LPF/eth0/00:e0:18:5c:d8:41/192.168.1.0/24

Success! You can go back to lunch!

Login ing Linux clients to use DHCP

A Linux Nic interface can be configured to obtain its IP address using DHCP with the examples outlined in, "Chapter 3, Linux networking ". please refer to this chapter if you need a quick refresher on how to configure a Linux DHCP client.

Login ing Windows clients to use DHCP

Fortunately windows ults to using DHCP for all its Nic cards so you don't have to worry about doing any reconfiguration.

Using a single DHCP server to serve multiple networks

As stated before, DHCP clients send their requests for IP addresses to a broadcast address which is limited to the local LAN. this wowould imply that a DHCP server is required on each subnet. not so. it is possible to configure routers to forward DHCP requests to a DHCP server route hops away. this is done by inserting the IP address of the router's interface on the DHCP Client's network into the forwarded packet. to the DHCP server, the non-blank router IP address field takes precedence over the broadcast address and it uses this value to provide a DHCP address that is meaningful to the client. the DHCP server replies with a broadcast packet, and the router, which has kept track of the initial forwarded request, forwards it back towards the client. you can configure this feature on Cisco devices by using the IP helper-address command on all the interfaces on which DHCP clients reside. here is a configuration sample that points to a DHCP server with the IP address 192.168.36.25:

interface FastEthernet 2/1  ip address 192.168.1.30 255.255.255.0  ip helper-address 192.168.36.25
Simple DHCP troubleshooting

The most common problems with DHCP usually aren't related to the server; after the server is configured correctly there is no need to change any settings and it therefore runs reliably. the problems usually occur at the DHCP Client's end for a variety of reasons. the following sections present simple troubleshooting steps that you can go through to ensure that DHCP is working correctly on your network.

DHCP clients obtaining 169.254.0.0 addresses

Whenever Microsoft DHCP clients are unable to contact their DHCP
Server they default to selecting their own IP address from
169.254.0.0 network until the DHCP server becomes available again. This
Is frequently referred to as automatic private IP addressing (apipa ).
Here are some steps you can go through to resolve the problem:

  • Ensure that your DHCP server is configured correctly and use
    The pgrep command discussed earlier to make sure the DHCP process is
    Running. Pay special attention to your route 255.255 route, especially
    If your DHCP server has multiple interfaces.
  • Give your DHCP client a static IP address from the same range
    That the DHCP server is supposed to provide. see whether you can ping
    The DHCP server. If you cannot, double-check your cabling and your Nic
    Cards.
  • DHCP uses the BOOTP protocol for its communication between
    Client and server. Make sure there are no firewils blocking this
    Traffic. DHCP servers login CT requests on UDP port 67 and the DHCP
    Clients clients CT responses on UDP port 68. UsetcpdumpOn the server's Nic to verify the correct traffic flows.
Other DHCP failures

If the DHCP server fails to start then use your regular troubleshooting techniques outlined in chapter 4, "simple network troubleshooting", to help rectify your problems.
Most problems with an initial setup are often due:

  • Incorrect settings in the/etc/DHCPD. conf file such as not defining the networks for which the DHCP server is responsible;
  • Firewall rules that block the dhcp bootp protocol on UDP ports 67 and 68;
  • Routers failing to forward the bootp packets to the DHCP server when the clients reside on a separate network.

Always check your/var/logs/messages file for DHCPD errors and
Remember that mandatory keywords in your configuration file may change
When you upgrade your operating system. Always read the release notes
Be sure.

Conclusion

In most home-based networks, a DHCP server isn' t necessary because
The DSL router/firewall usually has DHCP capabilities, but it is
Interesting project to try. Just remember to make sure that the range
IP addresses issued by all DHCP servers on a network doesn't overlap
Because it cocould possibly cause unexpected errors. You might want
Disable the router/firewall's DHCP server capabilities to experiment
With your new Linux server.

A DHCP server may be invaluable in an office environment where
The time and cost of getting a network engineer to get the work done may
Make it simpler for Linux systems administrators to do it
Themselves.

Creating a Linux DHCP server is straightforward and touches all
The major themes in the previous chapters. Now it's time to try
Something harder, but before we do, we'll do a quick refresher on how
Create the Linux users who'll be using because of the Applications
Outlined in the rest of the book.

-----------------------------------------------------------

How to log dhcp logs 

Hello All,How can I configure isc-dhcp-server to 1. Not send log info to /var/log/syslog2. Reduce the amount of info in the log file.In /etc/dhcp/dhcpd.conf I have log-facility local7;In /etc/rsyslog.conf I havelocal7.* /var/log/dhcpd.logWith this config I see dhcp activity in both /var/log/syslogand /var/log/dhcpd.logThanks//Ger

Need to restart both rsyslog and DHCP server:

Sudo service rsyslog stop
Sudo service rsyslog start
Sudo/etc/init. d/ISC-DHCP-server restart

----------------------------------------------------------

How to not log logs to SYSLOG file?

 

Hello,

I have setup the ISC DHCP daemon (v3.0.4) on an Ubuntu feisty server.

In my DHCPD. conf file I have setup logging to a separate file with the line:

Log-facility local0;

I have setup syslog To log local0 to a file/var/log/DHCPD.

This is all working a treat-log entries are being written to/var/log/DHCPD.

The problem is that everything is * Also * being logged to/var/log/syslog. I'm getting everything logged twice.

Can anyone tell me how to stop DHCPD logging to both places? I only want it to log to local0 and thus my/var/log/DHCPD file.

Thanks!

H.

 

 
 


, AM

 

#2

Blackhole54

Senior member registered: Mar 2006 posts: 1,896

REP:

You need to make another change to your/Etc/syslog. confFile. MyEdgy eftSystem has the line

Code:
*.*;auth,authpriv.none          -/var/log/syslog

In It. I believe changing it

Code:
*.*;auth,authpriv.none;local0.none          -/var/log/syslog

Wocould solve your problem. CheckSyslog. conf man pageFor more info, or in case I screwed it up.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.