From 9b8f5c9c9ad757f7504dc5e1afa95a4556655684 Mon Sep 17 00:00:00 2001 From: pavel-shirshov Date: Mon, 7 Oct 2019 07:49:25 -0700 Subject: [PATCH] [ntp]: Use loopback address when we don't have MGMT interface (#3566) Added configuration to use Loopback ip if a switch doesn't have MGMT_PORT. --- files/image_config/ntp/ntp.conf.j2 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/files/image_config/ntp/ntp.conf.j2 b/files/image_config/ntp/ntp.conf.j2 index 1255369773..cef6527fc2 100644 --- a/files/image_config/ntp/ntp.conf.j2 +++ b/files/image_config/ntp/ntp.conf.j2 @@ -27,12 +27,19 @@ filegen clockstats file clockstats type day enable server {{ ntp_server }} iburst {% endfor %} -#only listen on localhost and eth0 ips (default is to listen on all ip addresses) +#only listen on MGMT_INTERFACE, LOOPBACK_INTERFACE ip when MGMT_INTERFACE is not defined, or eth0 +# if we don't have both of them (default is to listen on all ip addresses) interface ignore wildcard {% if MGMT_INTERFACE %} {% for (mgmt_intf, mgmt_prefix) in MGMT_INTERFACE|pfx_filter %} interface listen {{ mgmt_prefix | ip }} {% endfor %} +{% elif LOOPBACK_INTERFACE %} +{% for (name, prefix) in LOOPBACK_INTERFACE|pfx_filter %} +{% if prefix | ipv4 and name == 'Loopback0' %} +interface listen {{ prefix | ip }} +{% endif %} +{% endfor %} {% else %} interface listen eth0 {% endif %}