Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    How is "uniqid" for a VIP entry generated

    Scheduled Pinned Locked Moved Development
    4 Posts 3 Posters 636 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • X
      xciter327
      last edited by xciter327

      I am writing a jinja based template engine for initial pfsense configuration. I've done most of the other configuration section and now I want to create the <virtualip> via a template. Could somebody explain how is the "uniqid" entry populated?

      I've taken a look in https://github.com/pfsense/pfsense/blob/master/src/usr/local/www/firewall_virtual_ip_edit.php

      However I don't see it being set or generated in that file.

      What is see is that it's always a alphanumerical field with lowercase letters and a length of 13 characters.

      Could anybody confirm my assumptions?

      Here is code example:

        <vip>
          <mode>carp</mode>
          <interface>wan</interface>
          <vhid>2</vhid>
          <advskew>0</advskew>
          <advbase>10</advbase>
          <password>{{ carp_password }}</password>
          <uniqid>5aa10f2a5b569</uniqid>
          <descr><![CDATA[WAN IPv6 CARP IP]]></descr>
          <type>single</type>
          <subnet_bits>{{ wan_ipv6_network }}</subnet_bits>
          <subnet>{{ wan_carp_ip_ipv6 }}</subnet>
        </vip>
      
      1 Reply Last reply Reply Quote 1
      • jimpJ
        jimp Rebel Alliance Developer Netgate
        last edited by

        http://php.net/manual/en/function.uniqid.php

        Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

        Need help fast? Netgate Global Support!

        Do not Chat/PM for help!

        1 Reply Last reply Reply Quote 0
        • X
          xciter327
          last edited by

          Hi jimp, thaks for the quick reply. So my suspicion is confirmed. 13 characters, alphanumeric.

          1 Reply Last reply Reply Quote 1
          • T
            tkriviradev
            last edited by

            Hello, I came across the same topic, it was very useful for me.

            This is how I decided to implement it in ansible.

            - name: "Generate a virtual ip address uniq id"
              ansible.builtin.debug:
                var: query('community.general.random_string', upper=false, special=false, min_numeric=10, min_lower=3, length=13)
              # Example result: ['202121w730p1q']
            
            1 Reply Last reply Reply Quote 0
            • First post
              Last post
            Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.