Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

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

default-lease-time 600;
max-lease-time 7200;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.10.255;
option routers 192.168.10.254;
option domain-name-servers 192.168.10.1, 192.168.10.2;
subnet 192.168.10.0 netmask 255.255.255.0 {
range 192.168.10.10 192.168.10.100;
}

/etc/default/isc-dhcp-server

INTERFACES="eth1"

/etc/network/interfaces

auto lo
iface lo inet loopback
auto eth1
iface eth1 inet static
address 192.168.10.1
netmask 255.255.255.0
gateway 192.168.10.1
broadcast 192.168.10.255 

/etc/sysctl.conf

net.ipv4.ip_forward=1

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...

share|improve this question
    
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
add comment

1 Answer

up vote 1 down vote accepted

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
address 192.168.10.1
netmask 255.255.255.0
network 192.168.10.0

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 192.168.10.1;
#8.8.8.8 is google's public DNS server (this is optional)
#Include the DNS IP addresses in your /etc/resolv.conf file
option domain-name-servers 8.8.8.8, (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.

share|improve this answer
    
its working for me Thanks –  Sumant Mar 15 '12 at 7:30
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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