Setting up Auto IP for KVM (Updated 19th Apr 2017: OVH support)

***NEW Method***: with the new Auto Scripts Template feature you can now perform Linux/unix KVM Template Auto IP without the need of DHCP, for sample scripts check forum topic: https://modulesfactory.com/forum/index.php?/topic/23-set-networksh/


 Auto IP for KVM is managed through installing Third Party DHCP software on Proxmox Nodes. DHCP is configured to Listen on the Bridge Interface that KVM will belong to, and in WHMCS configure IP Pool inside that subnet and specify the pool and related bridge inside the KVM Templates under Auto provisioning area.

Proxmox Module will auto add the new KVMs to this bridge and auto add static MAC to IP mapping inside the DHCP server.


Proxmox Node Setup:

  • Install DHCP server package on Proxmox Node : apt-get install isc-dhcp-server
  • Create the Bridge Type interface that you plan to use for KVM in Proxmox GUI, let's assume vmbr0 and make sure to give it an IP from the subnet netmask that will be used.
  • Also depend on your setup you might need to add routes, whether globally or let interface manage it: vi /etc/network/interfaces
auto vmbr0
iface vmbr0 inet static
address 192.168.0.4
netmask 255.255.255.224
gateway 192.168.0.5
bridge_ports none
bridge_stp off
bridge_fd 0
up ip route add 192.168.0.5/32 dev eth0
down ip route del 192.168.0.5/32 dev vmbr0
  • Configure DHCP server to listen on this interface in file vi /etc/default/isc-dhcp-server  example:
    #Defaults for dhcp initscript
    #sourced by /etc/init.d/dhcp
    #installed at /etc/default/isc-dhcp-server by the maintainer scripts
    #
    #This is a POSIX shell fragment
    #
    #On what interfaces should the DHCP server (dhcpd) serve DHCP requests"
    #Separate multiple interfaces with spaces, e.g. “eth0 eth1".
    INTERFACES="vmbr0"
  • Now configure your IP subnet, no need to specify ranges, this will be managed by module, just use 0.0.0.0 to accomodate all subnets on same bridge and assuming below my gateway is 192.168.0.5, in  vi /etc/dhcp/dhcpd.conf  example:

ddns-update-style none;
default-lease-time 600;
max-lease-time 7200;
log-facility local7;
option rfc3442-classless-static-routes code 121 = array of integer 8;
option ms-classless-static-routes code 249 = array of integer 8;

subnet 0.0.0.0 netmask 0.0.0.0 {
authoritative;
default-lease-time 21600000;
max-lease-time 432000000;
option routers 192.168.0.5;
option domain-name-servers 8.8.8.8,4.2.2.1;
option rfc3442-classless-static-routes 32, 192, 168, 0, 5, 0, 0, 0, 0, 0, 192, 168, 0, 5;
option ms-classless-static-routes 32, 192, 168, 0, 5, 0, 0, 0, 0, 0, 192, 168, 0, 5;
  #vmbr0ipv4
 }
  • note in my example above "#vmbr0ip4" this is very important, as Module use this note to know where to insert the Static MAC to IP Mapping, if IPv6 is used, then the note under the subnet6 will be "#vmbr0ipv6", the note contains the bridge name and ip4 or 6, must be inserted before closing the subnet braces "}"
  • More info about configuring DHCP server can be found here : http://askubuntu.com/questions/140126/how-do-i-configure-a-dhcp-server
  • By default ip4 is supported, to support ipv6, more steps is needed in DHCP server, refer to https://wiki.ubuntu.com/DHCPv6
  • once confg is done, restart the DHCP service :  service isc-dhcp-server restart
  • you might need to enable proxy_arp 
echo 1 > /proc/sys/net/ipv4/conf/vmbr0/proxy_arp

If Using OVH based nodes

  • First thing in OVH manager generate Virtual MAC on all IPs
  • Copy those MAC and put them in the list of MAC=IP and Head to IP Pools and Add/Edit IP Pool of type IP list and in the IP list add.
02:00:00:a6:9b:sb=192.168.0.20
02:00:00:a6:9b:ds=192.168.0.21
  • your gateway will be your proxmox node ip but instead of last octet will be .254 so if my proxmox node ip is 192.168.0.5 then gateway will be 192.168.0.254, set in IP pool the gateway and subnet:
  • That's it. Now module auto give MAC to new VMs and dhcp will assign IP to it and the default route/gateway and OVH mac to IP bind will allow it internet.

 

WHMCS SSH Setup:

  • Module use SSH to alter the DHCP configurations on Service Activation and Termination.
  • Proxmox Nodes need to be configured in WHMCS using root pam user login, you can alter this for current configured nodes in WHMCS > Setup > Products & Services > Servers, edit the present nodes and modify username/password/accesshash to root/<password>/pam
  • Starting Module version 1.3.2.1, this step is optional, if on older version then You need to have PHP-ssh2 installed and activated inside of PHP on the WHMCS server, check for Steps on how to configure/install PHP-ssh2 on different platforms  https://modulesfactory.com/knowledgebase/5/Installing-PHP-SSH2-for-KVM-Auto-IP.html


Proxmox KVM Template:

  • if using kvm template then before converting your vm to be a templae, make sure interfaces has no network id, mac or ip specified, for linux should like this:

    DEVICE=eth0 
    BOOTPROTO=dhcp 
    ONBOOT=yes
  • you might better create ifcfg-eth1 as well eith same config above but device=eth1
  • once done shutdown VM and convert it to template
  • Head to the new template in proxmox gui and delete the network interface, you do not need proxmox to have same interface for every single clone, Module will be adding new interfaces automatically with unique mac and ip 

WHMCS Proxmox Module Config:

  1. Nodes need to be added using user Root on PAM, to be sure head to WHMS > AdminArea > Setup > Products & Services > Servers, edit the proxmox nodes and make sure the username/password is for root and Accesshash is pam.
  2. Create the IP ranges/blocks in WHMCS > AdminArea > Addons > Proxmox Manager > IP Pools, you can create both IP list or IP Range type of IP Pools.
  3. Head to Auto Provisioning and Add/Edit KVM Templates, in Network Tab, click "Add new Network" and check the Bridge Check box.
  4. Choose the Bridge interface we created on Proxmox node, in our example vmbr1, and choose the IP pool we just configure.
  5. Save...That's it give it some test to check if KVMs are getting the assigned IPs in WHMCS and also trace connectivity on VPS to check if any more routes need to be added or all is set.
  • 3 Users Found This Useful
Was this answer helpful?

Related Articles

Getting error Could not poll for Version while configuring

Symptoms:Error: Could not poll for Version while configuringProblem:To be able to solve this...

Proxmox Backup Notifications Failing

Problem:   After Enabling Mailto feature for backup notificatins, no backup completion...

KVM arbitrary arqument usage

writing in progress

Installing PHP-SSH2 for KVM Auto IP

**Only Required FOR MODULE VERSION 1.3.1 or LOWER, STARTING 1.3.2.1 this is optionaal as WE USE...

OpenVZ Console not Progressing

Symptoms:Error: unable to write `random state`Error: ,Error: nothing showing on new Console, only...

Powered by WHMCompleteSolution