Configuring DHCP and DNS on OpenWrt This page contains an overview on how to configure DHCP and DNS on a Linksys WRT54GS running OpenWrt. Introducto...
8 downloads
27 Views
183KB Size
Configuring DHCP and DNS on OpenWrt This page contains an overview on how to configure DHCP and DNS on a Linksys WRT54GS running OpenWrt.
Introductory Information The OpenWrt build includes a dnsmasq, a lightweight package which provides a caching DNS server and DHCP server. The DHCP server integrates with the DNS server, allowing it resolve hostnames for DHCPallocated addresses, if desired. A single instance of dnsmasq can be configured to provide different DNS and DHCP services on separate network interfaces.
Configuring DNSMasq Edit Configuration File Edit /etc/dnsmasq.conf and change the configuration to suit your environment. I am using dnsmasq to provide DHCP and DNS services to the LAN ports, as well as to the WAN port (which I am using as an administrative interface only, with no routed access to the LAN / WLAN ports for any clients connected to the WAN port). Note that the example below is for a WRT where the bridge has been broken, ie, the WLAN and LAN ports are not bridged, but have separate IPs, with the WRT routing traffic between them. The contents of /etc/dnsmasq.conf on my WRT is similar to this: # filter what we send upstream domainneeded boguspriv filterwin2k # allow /etc/hosts and dhcp lookups via *.lan local=/lan/ domain=houwels.sgnet.wafreenet # enable dhcp (start,end,netmask,leasetime) dhcpauthoritative # dhcp range for LAN ports 10.60.68.16/29 = 10.60.68.1710.60.68.22 dhcprange=vlan0,10.60.68.18,10.60.68.22,255.255.255.248,48h # dhcp range for WAN port 192.168.1.0/24 dhcprange=vlan1,192.168.1.2,192.168.1.10,255.255.255.0,5m # dhcp lease file dhcpleasefile=/tmp/dhcp.leases # use /etc/ethers for static hosts; same format as dhcphost # [] readethers # default gateway and dns for LAN ports dhcpoption=vlan0,3,10.60.68.17 dhcpoption=vlan0,6,10.60.68.17
The IP address of the LAN interface on my WRT is 10.60.68.17, so it is used as the default gateway and DNS by all clients connected to the LAN interfaces. Specifying Static DHCP IP Addresses If desired, details for any static DHCP IP addresses are specified in /etc/ethers, in the following format: # desktop xx:xx:xx:xx:xx:xx 10.60.68.18 # laptop xx:xx:xx:xx:xx:xx 10.60.68.19 # another desktop xx:xx:xx:xx:xx:xx 10.60.68.20 Note that you need to specify the actual MAC addresses in /etc/ethers, but I've replaced the MAC addresses with xx:xx:xx:xx:xx:xx in the example above for obvious reasons.
Completing Configuration Edit init script The default init script for dnsmasq contains some code to determine the LAN interface name, as well as the IP address and netmask, and assumes DHCP will only be active on the LAN interface. We don't need these smarts in the init script, as everything is fully defined in the configuration file. Edit the init script /etc/init.d/S60dnsmasq, and replace the contents with #!/bin/sh /usr/sbin/dnsmasq Restart dnsmasq To make the changed configuration take effect, dnsmasq must be restarted. Restart it using the following: killall dnsmasq /etc/init.d/S60dnsmasq Now the configuration can be tested by connecting a client PC to the LAN and WAN ports, and verify that the client PC can obtain a DHCP IP address, and can communicate with the DNS server.
next page: Scheduling Jobs With cron on OpenWrt
last updated 22 Oct 2013
web by mpot. all content and images are copyright © 20012015 Martin Pot (mpot). all rights reserved. unauthorised duplication, reproduction or distribution is prohibited.
.