Skip to content

[ntp] Add support for ntp to listen ipv4/ipv6 address depends on server config #20227

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion files/image_config/ntp/ntp.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ leapfile /usr/share/zoneinfo/leap-seconds.list
{# Adding NTP servers. We need to know if we have some pools, to set proper
config -#}
{% set ns = namespace(is_pools=false) %}
{% set ip_ver_ns = namespace(ipv4_server=false, ipv6_server=false) %}
{% for server in NTP_SERVER if NTP_SERVER[server].admin_state != 'disabled' -%}
{% set config = NTP_SERVER[server] -%}
{# Server options -#}
Expand Down Expand Up @@ -56,6 +57,13 @@ config -#}
restrict {{ resolve_as }} kod limited nomodify noquery
{% endif %}

{% if resolve_as | ipv4 -%}
{% set ip_ver_ns.ipv4_server = true %}
{% elif resolve_as | ipv6 %}
{% set ip_ver_ns.ipv6_server = true %}
{% endif -%}


{% endfor -%}

{% set trusted_keys_arr = [] -%}
Expand Down Expand Up @@ -125,9 +133,11 @@ interface listen {{ mgmt_prefix | ip }}
{% endfor %}
{% elif LOOPBACK_INTERFACE %}
{% for (name, prefix) in LOOPBACK_INTERFACE|pfx_filter %}
{% if prefix | ipv4 and name == 'Loopback0' %}
{% if name == 'Loopback0' %}
{% if prefix | ipv4 and ip_ver_ns.ipv4_server or prefix | ipv6 and ip_ver_ns.ipv6_server %}
interface listen {{ prefix | ip }}
{% endif %}
{% endif %}
{% endfor %}
{% else %}
interface listen eth0
Expand Down
Loading