Uploaded image for project: 'CFEngine Community'
  1. CFEngine Community
  2. CFE-1991

sys variable containing default gateway

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Done
    • Priority: Low
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.9.0
    • Component/s: None
    • Labels:
      None

      Description

      Hello,

      Could you please discover the default gateway on the system and provide it as a system variable?

      In 3.9.0

      sys.inet[default_gateway]
      

      This would be useful for inventory and also my client wants to record the default route in /etc/sysconfig/network to simplify life for their operators (right now their VMs and physical servers get the default route in different files because provisioning is different).

      On IRC, Ted pointed out this information is available in /proc/net/route on systems that have procfs.

      Neil said don't forget about IPv6.

      This is how I'm getting this data now:

      vars:
      "ip_route_output"
      string => execresult("/sbin/ip -4 route list 0/0", noshell);
      "split_ip_route_output"
      slist => splitstring( $(ip_route_output), " ", 3);
      "gateway"
      string => nth( "split_ip_route_output", 2 );

      reports:
      "$(gateway)";

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                a10040 Kristian Amlie
                Reporter:
                atsaloli Aleksey Tsalolikhin
              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Summary Panel