i am configuring a DHCP server using ubuntu 11.10 with 2 lan cards.eth0 is connected to wan on ip address: and eth1 connected to lan is configured with ip: gateway:

i have configured my /etc/dhcp/dhcp.conf as

default-lease-time 600;
max-lease-time 7200;
option subnet-mask;
option broadcast-address;
option routers;
option domain-name-servers,;
subnet netmask {




auto lo
iface lo inet loopback
auto eth1
iface eth1 inet static



after these things i did as

iptables --flush
iptables --table nat --flush
iptables --delete-chain
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -m conntrack --ctstate NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -A FORWARD -i eth1 -j ACCEPT
iptables-save | sudo tee /etc/iptables.sav
sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"

/etc/resolv.conf is getting name server by default all the time.

i am able to use browse internet on this server but not from client side.my dhcp server is running properly from client machine i am able to ping eth1 as well as eth0 but not able to connect to internet is there any thing i am missing here. Please someone help me...

  • You've got damn lots of misprints in your configuration files. First, default configuration file for dhcp is /etc/default/dhcp-server. Second, network configuration file is /etc/network/interfaces. Third, gateway specification keyword is gateway. – mbaitoff Mar 14 '12 at 12:25
  • Also, your gateway address equals to the interface address itself. – mbaitoff Mar 14 '12 at 12:43
  • Do sudo watch -n 1 -d iptables -nvL then try to reach the internet from your client machine while watching the counters. Do they show FORWARD rule increasing? – mbaitoff Mar 14 '12 at 12:46
  • option routers; should probably be option routers; – Wilhelm Erasmus May 10 '15 at 19:21

In /etc/network/interfaces do not specify a broadcast or gateway. This is done with the dhcp lease. You do need to specify a network for the DHCP however. This will configure eth1 to run on the 192.168.10/24 network. eth0 will be your gateway which is connected to your primary DHCP router. Change it to this -->

auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
     pre-up iptables-restore < /etc/iptables_rules
auto eth1
iface eth1 inet static

Then your dhcp.conf file will specify the routers and gateways. Use the DNS IP adresses in your /etc/resolv.conf file. These are known to be suitable in your location with your ISP. Change the routers and DNS settings in your DHCP.conf to this -->

option routers;
# is google's public DNS server (this is optional)
#Include the DNS IP addresses in your /etc/resolv.conf file
option domain-name-servers, (IP addresses in your /etc/resolv.conf)

Note: If you want to save your iptables rules, than after you set them, run this command to save it to a file --> iptables-save > /etc/iptables_rules You can see the placement to load the rules in the /etc/network/interfaces settings I provided. This will happen when the network manager is loaded/reloaded.

Let me know if this helps.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.