Author

Christopher Marshall (christopherlmarshall@yahoo.com)

A DHCP Example Script

#!/bin/bash
#
# suppose you have one ethernet interface that connects you to the internet 
# and another on which you want to allow other computers to share the internet
# connection.  A common scenario might be a laptop plugged into a DSL
# router through one interface and running a wireless ad-hoc network on
# another.
#
# This script shows how to do that, although you really have to know a lot
# about linux networking to use it, so be warned.

eth_dev=eth1
eth_internet=eth0
(
   echo "ddns-update-style none;"
   echo "subnet 10.0.1.0 netmask 255.255.255.0 {"
   echo "   range 10.0.1.10 10.0.1.20;"
   echo "   option routers 10.0.1.1;"
   echo "   option domain-name \"example.net\";"
   echo "   option domain-name-servers 192.168.1.1;"
   echo "}"
) > dhcpd.conf

touch dhcpd.lease
ifconfig $eth_dev 10.0.1.1 netmask 255.255.255.0 up
iptables -t nat -F
iptables -t nat -A POSTROUTING -o $eth_internet -s 10.0.1.0/24 -j MASQUERADE
dhcpd -cf ./dhcpd.conf -lf ./dhcpd.lease -d -f $eth_dev

hopeless_linux: RawNotes/dhcp/example2 (last modified 2007-07-01 16:01:00)