Computer gets IP from DHCP server but has no internet connection

20,086

Everything is working now. It turned out to be a DNS problem; changing the option routers to option routers 192.168.1.1 fixed the issue. Pings must have been blocked somewhere in the network as responses never came through, but surfing in the browser to a specific IP-address was possible, which made me realise that DNS was the problem. Thanks everyone for your help.

Share:
20,086

Related videos on Youtube

user2611216
Author by

user2611216

Updated on September 18, 2022

Comments

  • user2611216
    user2611216 almost 2 years

    I've installed an isc-dhcp-server on Ubuntu 12.10 and I'm trying to setup a DHCP server on a head node for six worker computers in the local network. The head node itself is a DHCP client receiving the IP-address 192.168.20.1 (on eth0) from an other computer in the network.

    IPv4 IP forwarding is enabled on the head node. In /etc/sysctl.conf the following line was added:

    net.ipv4.ip_forward = 1
    

    The following rules are set in /etc/rc.local:

    /sbin/iptables -P FORWARD ACCEPT
    /sbin/iptables --table nat -A POSTROUTING -o eth0 -j MASQUERADE
    

    Furthermore, INTERFACES="eth0" is set in /etc/default/isc-dhcp-server.

    The dhcpd.conf file contains (for the moment only one worker computer is in the file):

    ddns-update-style none;
    
    default-lease-time 3600;
    max-lease-time 7200;
    
    authoritative;
    
    subnet 192.168.20.0 netmask 255.255.255.0 {
      range 192.168.20.2 192.168.20.200
      host hostName {
        hardware ethernet macOfHost;
        fixed-address 192.168.20.20;
      }
      option subnet-mask 255.255.255.0;
      option broadcast-address 192.168.20.255;
      option routers 192.168.20.1;
    }
    

    The worker node effectively gets the IP address 192.168.20.20, but it has no internet connection. A ping to 192.168.20.1 is successful, as well as a ping to the computer that serves as a DHCP server for the head node (a ping to 192.168.1.1). The problem doesn't seem to have something to do with DNS as a ping to an IP-address (such as 8.8.4.4) fails.

    Update

    The network topology is as follows. There is switch connecting a computer (with internet access and running a DHCP server, IP address 192.168.1.1) and 7 other computers. One of these 7 computers gets an IP from the 192.168.1.1 computer. The IP it gets is 192.168.20.1 and the internet on that computer works fine. Now we have a DHCP server running on 192.168.20.1 in order to provide internet access to the other 6 computers, but that fails. They get IP addresses but have no internet access. We are not allowed to modify anything on the 192.168.1.1 node so it should be feasible to make internet work with this setup.

    Does someone know what the problem could be?

    Output of /sbin/route -n on the client:

    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    0.0.0.0         192.168.20.1    0.0.0.0         UG    0      0        0 eth1
    169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 eth1
    192.168.20.0    0.0.0.0         255.255.255.0   U     1      0        0 eth1
    

    Output of sudo iptables -L -v -n: Chain INPUT (policy ACCEPT 2146 packets, 1551K bytes) pkts bytes target prot opt in out source destination

    Chain FORWARD (policy ACCEPT 59 packets, 3762 bytes)
     pkts bytes target     prot opt in     out     source               destination         
    
    Chain OUTPUT (policy ACCEPT 1908 packets, 213K bytes)
     pkts bytes target     prot opt in     out     source               destination
    

    Output of ip ro sh default via 192.168.1.1 dev eth0 proto static 169.254.0.0/16 dev eth0 scope link metric 1000 192.168.0.0/16 dev eth0 proto kernel scope link src 192.168.20.1 metric 1

    • umläute
      umläute almost 11 years
      just to be sure: can your router (192.168.20.1) ping the outside world?
    • user2611216
      user2611216 almost 11 years
      Yes, it can. (10 characters)
    • Doon
      Doon almost 11 years
      what is subnet mask on the 192.168.1.x network? if you are getting an ip of 192.168.20.1 from that network the subnet mask is probably 255.255.0.0? and it looks like you are trying to nat with overlapping subnets. if you change your downstream dhcp config to use a different set of RFC1918 IPS does it work (10.10.0.0/24 for example).
    • user2611216
      user2611216 almost 11 years
      The subnet mask of that network is indeed 255.255.0.0.
    • user2611216
      user2611216 almost 11 years
      @umläute: I've posted the output in my question.
    • Doon
      Doon almost 11 years
      also you can't have 2 dhcp servers giving out different information on the same Layer 2 network Just doesn't work and int looking at your config are you trying to NAT on the same interface, it will not work. what I would do is this. move the 6 worker nodes to a different layer 2 network, and hook them into eth1 on the head node. Give them a different RFC 1918 address (10.x ) and then all of your stuff above would work. BUt with only 1 interface and the overlapping subnets/ 2 dhcp servers it will not work.
    • Doon
      Doon almost 11 years
      sorry missed the eth1 above. The problem is your ip scheme (and that you have 192.168.20.1 on both eth0 and eth1). Change your subnet on eth1 and you should work fine.
  • user2611216
    user2611216 almost 11 years
    IP forwarding was already enabled. I've made this more clear in my question now.
  • umläute
    umläute almost 11 years
    as i said in my answer, just having the line in the config-file will not enable ip-forwarding until the machine is rebooted. what does sysctl net.ipv4.ip_forward output? can the router see the internet?
  • user2611216
    user2611216 almost 11 years
    The machine has already been rebooted many times since that line was added. The head node (192.168.20.1) can see the internet, the DHCP client of the DHCP server running on that computer cannot.
  • ALex_hha
    ALex_hha almost 11 years
    Could you show output of the iptables -L -v -n and ip ro sh ?
  • user2611216
    user2611216 almost 11 years
    I've put the output in my question.