rancher / old-vm

(OBSOLETE) Package and Run Virtual Machines as Docker Containers
Apache License 2.0
645 stars 133 forks source link

No address range available for DHCP request #89

Open vk496 opened 6 years ago

vk496 commented 6 years ago

Hello

I try to get work the Metasploitable2 image following the documentation about creating them. However, when I launch it, the VM can't obtain a IP address from the dnsmasq.

# dnsmasq -d
dnsmasq: started, version 2.68 cachesize 150
dnsmasq: compile time options: IPv6 GNU-getopt DBus i18n IDN DHCP DHCPv6 no-Lua TFTP conntrack ipset auth
dnsmasq-dhcp: DHCP, IP range 192.168.251.111 -- 192.168.251.111, lease time 1h
dnsmasq: reading /etc/resolv.conf
dnsmasq: using nameserver 127.0.0.11#53
dnsmasq: read /etc/hosts - 7 addresses
dnsmasq-dhcp: no address range available for DHCP request via br0
dnsmasq-dhcp: no address range available for DHCP request via br0
dnsmasq-dhcp: no address range available for DHCP request via br0

And my Docker compose definition:

  um_metasploitable2:
    image: vk496/metasploitable2
    hostname: metasploitable2
    volumes:
        - /var/lib/rancher/vm:/vm
    cap_add:
        - NET_ADMIN
    devices:
        - /dev/kvm:/dev/kvm
        - /dev/net/tun:/dev/net/tun
    networks:
        red1:
            aliases:
                - metasploitable2.bar.foo
            ipv4_address: 192.168.251.111

Reading in the internet, says that the problem is the IP address of the interface where is serverd. My subnet in Docker Compose is 192.168.251.0/24 but the br0 interface has the following:

root@metasploitable2:/# ifconfig 
br0       Link encap:Ethernet  HWaddr 06:fe:0d:c6:91:de  
          inet addr:193.168.251.111  Bcast:0.0.0.0  Mask:255.255.254.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:99 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:27637 (27.6 KB)  TX bytes:0 (0.0 B)

eth0      Link encap:Ethernet  HWaddr 06:fe:0d:c6:91:de  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:100 errors:0 dropped:0 overruns:0 frame:0
          TX packets:43 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:24071 (24.0 KB)  TX bytes:9666 (9.6 KB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:24 errors:0 dropped:0 overruns:0 frame:0
          TX packets:24 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:2322 (2.3 KB)  TX bytes:2322 (2.3 KB)

tap0      Link encap:Ethernet  HWaddr fe:02:28:a2:f6:ce  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:30 errors:0 dropped:0 overruns:0 frame:0
          TX packets:70 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:8676 (8.6 KB)  TX bytes:20321 (20.3 KB)

If I change the IP address of br0 to one that is in the range, it works and the VM get a IP over DHCP. I read that the option bridge-interface of dnsmasq ignore the IP address of the interface X in favour of other interface, but didn't found anything to ignore completly this behavior.

How it's possible that no previous issues about this?

Salu2

vk496 commented 6 years ago

I solved it with a quick workaround. I assign a second IP to the same interface. With this fix, dnsmasq work properly.

Is possible to try it here: https://github.com/vk496/vm

Or the Docker image vk496/vm-base:0.0.4

buck-ross commented 6 years ago

@vk496 If you've successfully resolved this issue, it might be a good idea to close it.

Also, I'm new to this repo, and out of curiosity, do you know if this project is dead? It doesn't look like any development has occurred in years...