DHCP + Static IP for DHCP server on eth1?

23,214

The interface where the DHCP server is listening must have an Static IP of the same subnet you are using in your DHCP configuration.

To do so, edit your /etc/network/interface as follows: (assuming that 192.168.1.1 is your network gateway)

auto eth1
iface eth1 inet static
address 192.168.1.2
netmask 255.255.255.0
gateway 192.168.1.1
broadcast 192.168.1.255

Then, edit your dhcpd.conf, change the range to 192.168.1.3 192.168.1.254 and add the following option line:

option routers 192.168.1.1;

Let me know if it helps.

Regards

Share:
23,214

Related videos on Youtube

Calvin Froedge
Author by

Calvin Froedge

Updated on September 18, 2022

Comments

  • Calvin Froedge
    Calvin Froedge over 1 year

    I'm trying to set up an intranet using DHCP. I'm using Ubuntu 11.04 and a ZyXEL GS2200-24 managed switch. I installed dhcp3-server.

    Here is my configuration for DHCP (/etc/dhcp/dhcpd.conf):

    ddns-update-style none;
    default-lease-time 600;
    max-lease-time 7200;
    
    authoritative;
    
    subnet 192.168.1.0 netmask 255.255.255.0 {
      interface eth1;
      range 192.168.1.2 192.168.1.254;
      option subnet-mask 255.255.255.0;
      option broadcast-address 192.168.1.255;
    }
    

    Here is setting or /etc/default/isc-dhcp-server:

    INTERFACES="eth1"
    

    Here is /etc/network/interfaces config for eth1:

    auto eth1
    iface eth1 inet dhcp
    

    Now, I try to start my server (sudo /etc/init.d/isc-dhcp-server) and I get this error:

    No subnet delcaration for eth1 (no IPv4 addresses). *Ignoring requests on eht1. If this is not what you want, please write a subnet declaration in your dhcpd.conf file for the network segment to which interface eth1 is attached. *

    If I assign eth1 an IP address, (sudo ifconfig eth1 192.168.1.2) I can startup just fine. I have not tried routing DHCP requests to the server yet, but it seems as everything is gravy.

    Am I correct that I just need to permanently assign 192.168.1.2 to eth1, and then I can configure my managed switch to route requests for IP assignment to 192.168.1.2, my DHCP server?

    If so, how can I do that? Do I need to make a config change in /etc/network/interfaces ?

  • Calvin Froedge
    Calvin Froedge over 12 years
    What is the function of my network gateway (192.168.1.1)? What does it do (I read about what it is, that it is used for connection sharing, but I don't know what it means in context), and are there other config changes I must make to support this? Sorry, I'm new to networking = ) By the way, these changes worked great!
  • Calvin Froedge
    Calvin Froedge over 12 years
    Ah - nevermind - I just realized the answer to my own question. 192.168.1.1 is the address for my switch, that's the default gateway = ). Thanks for your help!
  • Paulo Arruda
    Paulo Arruda over 12 years
    Hey Calvin! Good to know I could help :)
  • Paulo Arruda
    Paulo Arruda over 12 years
    Oh, once you set your eth1 interface with a fixed address with the instructions i gave to you, dont forget to add a line: nameserver 192.168.1.1 Inside the file /etc/resolv.conf, if your gateway is also your server for name resolution (DNS), to allow you to use aptitude or apt-get :)
  • Calvin Froedge
    Calvin Froedge over 12 years
    Any idea why I cannot ping 192.168.1.2? from either local terminal or other machines on the network? askubuntu.com/questions/81898/cannot-ping-static-ip-on-eth1
  • Paulo Arruda
    Paulo Arruda over 12 years
    I just added a comment there :)