testing dhcp server locally on one physical machine with virtual machine

6,668

Ok, I've found different solution. I use two virtual machines in Internal network. One of them use static IP address and has DHCP server configured. The second VM finds DHCP server and get IP from range.

Share:
6,668

Related videos on Youtube

szemek
Author by

szemek

Updated on September 18, 2022

Comments

  • szemek
    szemek over 1 year

    I'm writing simple program to configure and monitor DHCP server on my Ubuntu 12.04. What I'm trying to achieve that my physical machine will be DHCP server and my VM (virtual machine) get one lease (and I read that information in leases file).

    I use isc-dhcp-server. I turned off network-manager during tests. I use VirtualBox to host VM, network is configured to use bridge adapter. Server starts OK, but when my VM is running I got following messages:

    Jun 16 12:15:59 asus dhcpd: DHCPOFFER on 192.168.1.3 to 08:00:27:15:26:a6 (ubuntu) via eth0
    Jun 16 12:15:59 asus dhcpd: DHCPDISCOVER from 08:00:27:15:26:a6 (ubuntu) via eth0
    Jun 16 12:15:59 asus dhcpd: DHCPOFFER on 192.168.1.3 to 08:00:27:15:26:a6 (ubuntu) via eth0
    Jun 16 12:16:12 asus dhcpd: DHCPDISCOVER from 08:00:27:15:26:a6 (ubuntu) via eth0
    

    VM don't get any DHCPOFFERs at all. Any ideas how to solve this problem? Or different way to test DHCP server locally? I appreciate any help. Thanks in advance.

    ----------------------------

    Here's my DHCP server configuration:

    /etc/network/interfaces

    iface eth0 inet static  
    address 192.168.1.2  
    netmask 255.255.255.0  
    gateway 192.168.1.1  
    broadcast 192.168.1.255
    

    /etc/dhcp/dhcpd.conf

    ddns-update-style none;
    default-lease-time 600;
    max-lease-time 7200;
    
    authoritative;
    allow booting;
    allow bootp;
    
    subnet 192.168.1.0 netmask 255.255.255.0 {
      interface eth0;
      range 192.168.1.3 192.168.1.254;
      option routers 192.168.1.1;
      option subnet-mask 255.255.255.0;
      option broadcast-address 192.168.1.255;
    }
    

    /etc/default/isc-dhcp-server

    INTERFACES="eth0"