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

    TinyDNS serving WAN IP

    Scheduled Pinned Locked Moved 2.0-RC Snapshot Feedback and Problems - RETIRED
    1 Posts 1 Posters 1.2k 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.
    • J
      Juel
      last edited by

      Hi,

      I wanted tinydns to always serve my dynamic WAN-IP and just want to share some code
      for people having similar problems. The code is far from perfect and I know this is not the way to go,
      but I needed this running asap - thus didn't go through feature requests or create any ticket.

      So this is in a few steps what you can do:

      Step 1:

      Enable ssh in "System -> Advanced" and connect with your ssh-client.
      Open 2 sessions.

      Step 2:

      On first terminal press 12 - debug console:

      pfSense shell: conf_mount_rw();
      pfSense shell: exec

      On second terminal press 8 - console:

      open: vi /usr/local/pkg/tinydns.inc
      find: function tinydns_create_zone_file()
      insert after:

      
      $fd = fopen("{$g['varrun_path']}/service/tinydns/root/data", "w");      
      if(!$fd) {
      	log_error("Could not open {$g['varrun_path']}/service/tinydns/root/data for writing.");
      	return;
      }
      

      the following code:

      /* replace "wan" by wanip */ 
      for($x=0; $x< count($config['installedpackages']['tinydnsdomains']['config']); $x++) {
      	if(strtolower($config['installedpackages']['tinydnsdomains']['config'][$x]['ipaddress']) == "wan"){
      		$config['installedpackages']['tinydnsdomains']['config'][$x]['ipaddress'] = get_interface_ip("wan");
      	}
      }
      

      Step 3:

      open /etc/inc/services.inc

      insert before function definitions: require_once("/usr/local/pkg/tinydns.inc");
      find: function services_dyndns_configure($int = "")
      insert below:

              /* update tinydns service */
              tinydns_create_zone_file();  
              tinydns_setup_ping_items();
      

      Step 4:

      You might need to restart

      Step 5:

      You now can enter "wan" instead of an ip in
      "Services->DNSServer->Record Data" and it should server your wan-ip.

      I think that Step 2 should be placed in /etc/inc/pfsense-utils.inc at
      function reload_all_sync() - but I couldn't get it to work there.
      Thus I put it in the services_dyndns_configure function, which probably only works with configured dyndns.

      As it serves my needs I'm fine with it - if theres more interest it would definetly be worth opening a
      ticket and having a delevoper doing things right.

      Greets, Juel

      1 Reply Last reply Reply Quote 0
      • First post
        Last post
      Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.