Auto IP assgiment from pool to pfSense 2.3.2 on Hyper-V/SCVMM



  • pfSense Experts -

    In SCVMM 2012 R2 it is possible to auto-assign IPs from a static address pool to VM and same works for the latest pfSense 2.3.2 - the new IP becomes ping-able, it is shown on the pfSense dashboard and in the```
    #ifconfig hn1

    
    Despite that, on the respective interface page (/interfaces.php?if=lan) the old IP is still shown as the new one is not recorded in the /etc/config.xml file. Consequently the pfSense Web Configurator UI is not accessible.
    
    **_I would like to know how to automate the update of the /etc/config.xml file upon interface IP change (at least on boot up)._**
    
    One possible solution would be to grab the current IP in a variable and pass it to the pfSense PHP shell:
    
    

    set ip = (ifconfig hn1 | awk '$1 == "inet" {print $2}')

    /usr/local/sbin/pfSsh.php
    $config['interfaces']['wan']['ipaddr'] = $ip  <== Does NOT work!
    parse_config(true);
    write_config();
    exec;

    
    However the pfSense shell does not appear to accept any variables.
    
    Any better ideas?


  • This iw because IP's must be set by pfSense, either using DHCP or static configuration. Don't use some weird non-standard IP "provisioning" thingy, especially not when it's built by a company that's not specialized in networking.



  • @johnkeates:

    This iw because IP's must be set by pfSense, either using DHCP or static configuration. Don't use some weird non-standard IP "provisioning" thingy, especially not when it's built by a company that's not specialized in networking.

    Thanks for the reply John, however it is not helpful.

    The following few points should describe the situation better:

    1. DHCP would not allow us to auto-assign (via script) the 10.X.Y.1 IP to the LAN interface, where X|Y={1-254} are random, to each on-demand provisioned pfSense VM.
    2. Manual, static IP configuration via the console or the Web Configurator connected to a pre-set LAN IP are not acceptable.
    3. The question here is about a script-able deployment with variables, such as LAN IP, hostname, DynDNS FQDN, etc.

    Does the pfSense PHP shell accept variables so we could re-play the configuration commands upon the VM startup?
    If the /etc/config.xml is modified outside of the PHP shell, what is the best way to commit the changes and restart the PHP-FPM?



  • Well, then let me put it in simpler terms: pfSense doesn't 'read' it's IP anywhere else, other can the config file, or DHCP. Data is never flowing the other way around.

    Since you seem to want to preconfigure pfSense boxes, it would probably be better to simply provision the config file instead of trying to use the Hyper-V network interface's uncommon facility to push IP addresses onto machines. I guess they made that for Windows, because on every other OS, it's not supposed to work that way.

    You can probably script the following:

    • MAC adresses for any of the interfaces you want to configure
    • IP addresses for any of the interfaces (identified by their MAC) you want to configure
    • Put them into a proper pfSense configuration XML
    • Put that XML inside a pfSense image
    • Boot the image

    What you really shouldn't do:

    • Hack a script together that reads the IP from the interface and then puts it into the config file

    this is because it completely contradicts the pfSense architecture, not a single component will work well, and all of it will work against you. This is because pfSense as a network system is designed to be the authority on what IP goes where. As soon as you try to invert that, you're going to run into problems.

    pfSense does have a read-config-on-boot option, it has had such functionality for a long time. All you would need to do is script the XML modification and inserting the file into the VM.


Log in to reply