Skip to content
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

[syslog] Add default syslog ip to interfaces.j2 #20340

Merged
merged 5 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
26 changes: 26 additions & 0 deletions files/image_config/interfaces/interfaces.j2
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,19 @@ iface {{ name }} {{ 'inet' if prefix | ipv4 else 'inet6' }} static
{% for route in MGMT_INTERFACE[(name, prefix)]['forced_mgmt_routes'] %}
up ip {{ '-4' if prefix | ipv4 else '-6' }} rule add pref {{ force_mgmt_route_priority }} to {{ route }} table {{ vrf_table }}
{% endfor %}
{% if SYSLOG_SERVER is defined and SYSLOG_SERVER %}
{% for server in SYSLOG_SERVER %}
wen587 marked this conversation as resolved.
Show resolved Hide resolved
{% if server | ipv4 and prefix | ipv4 %}
up ip rule add pref {{ force_mgmt_route_priority }} to {{ server }}/32 table {{ vrf_table }}
{% elif server | ipv6 and prefix | ipv6 %}
up ip -6 rule add pref {{ force_mgmt_route_priority }} to {{ server }}/128 table {{ vrf_table }}
{% endif %}
{% endfor %}
{% else %}
{% if prefix | ipv4 %}
up ip rule add pref {{ force_mgmt_route_priority }} to 10.20.6.16/32 table {{ vrf_table }}
{% endif %}
{% endif %}
{% if prefix | ipv6 and vrf_table == 'default'%}
# IPV6 default table not add to lookup by default, management server need this to access IPV6 address when BGP shutdown
up ip -6 rule add pref {{ force_mgmt_route_priority + 3 }} lookup {{ vrf_table }}
Expand All @@ -99,6 +112,19 @@ iface {{ name }} {{ 'inet' if prefix | ipv4 else 'inet6' }} static
{% for route in MGMT_INTERFACE[(name, prefix)]['forced_mgmt_routes'] %}
pre-down ip {{ '-4' if route | ipv4 else '-6' }} rule delete pref {{ force_mgmt_route_priority }} to {{ route }} table {{ vrf_table }}
{% endfor %}
{% if SYSLOG_SERVER is defined and SYSLOG_SERVER %}
{% for server in SYSLOG_SERVER %}
{% if server | ipv4 and prefix | ipv4 %}
down ip rule delete pref {{ force_mgmt_route_priority }} to {{ server }}/32 table {{ vrf_table }}
{% elif server | ipv6 and prefix | ipv6 %}
down ip -6 rule delete pref {{ force_mgmt_route_priority }} to {{ server }}/128 table {{ vrf_table }}
{% endif %}
{% endfor %}
{% else %}
{% if prefix | ipv4 %}
down ip rule delete pref {{ force_mgmt_route_priority }} to 10.20.6.16/32 table {{ vrf_table }}
{% endif %}
{% endif %}
{% if prefix | ipv6 and vrf_table == 'default'%}
pre-down ip -6 rule delete pref {{ force_mgmt_route_priority + 3 }} lookup {{ vrf_table }}
{% endif %}
Expand Down
2 changes: 2 additions & 0 deletions src/sonic-config-engine/tests/sample_output/py2/interfaces
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ iface eth0 inet static
up ip -4 route add default via 10.0.0.1 dev eth0 table default metric 201
up ip -4 route add 10.0.0.0/24 dev eth0 table default
up ip -4 rule add pref 32765 from 10.0.0.100/32 table default
up ip rule add pref 32764 to 10.20.6.16/32 table default
# management port down rules
pre-down ip -4 route delete default via 10.0.0.1 dev eth0 table default
pre-down ip -4 route delete 10.0.0.0/24 dev eth0 table default
pre-down ip -4 rule delete pref 32765 from 10.0.0.100/32 table default
down ip rule delete pref 32764 to 10.20.6.16/32 table default
iface eth0 inet6 static
address 2603:10e2:0:2902::8
netmask 64
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ iface eth0 inet static
up ip -4 rule add pref 32765 from 10.0.0.100/32 table 5000
up ip -4 rule add pref 32764 to 11.11.11.11 table 5000
up ip -4 rule add pref 32764 to 22.22.22.0/23 table 5000
up ip rule add pref 32764 to 10.20.6.16/32 table 5000
# management port down rules
pre-down ip -4 route delete default via 10.0.0.1 dev eth0 table 5000
pre-down ip -4 route delete 10.0.0.0/24 dev eth0 table 5000
pre-down ip -4 rule delete pref 32765 from 10.0.0.100/32 table 5000
pre-down ip -4 rule delete pref 32764 to 11.11.11.11 table 5000
pre-down ip -4 rule delete pref 32764 to 22.22.22.0/23 table 5000
down ip rule delete pref 32764 to 10.20.6.16/32 table 5000
iface eth0 inet6 static
address 2603:10e2:0:2902::8
netmask 64
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ iface eth1 inet static
up ip -4 route add default via 10.0.10.1 dev eth1 table default metric 201
up ip -4 route add 10.0.10.0/24 dev eth1 table default
up ip -4 rule add pref 32765 from 10.0.10.100/32 table default
up ip rule add pref 32764 to 10.20.6.16/32 table default
# management port down rules
pre-down ip -4 route delete default via 10.0.10.1 dev eth1 table default
pre-down ip -4 route delete 10.0.10.0/24 dev eth1 table default
pre-down ip -4 rule delete pref 32765 from 10.0.10.100/32 table default
down ip rule delete pref 32764 to 10.20.6.16/32 table default
iface eth0 inet static
address 10.0.0.100
netmask 255.255.255.0
Expand All @@ -39,10 +41,12 @@ iface eth0 inet static
up ip -4 route add default via 10.0.0.1 dev eth0 table default metric 201
up ip -4 route add 10.0.0.0/24 dev eth0 table default
up ip -4 rule add pref 32765 from 10.0.0.100/32 table default
up ip rule add pref 32764 to 10.20.6.16/32 table default
# management port down rules
pre-down ip -4 route delete default via 10.0.0.1 dev eth0 table default
pre-down ip -4 route delete 10.0.0.0/24 dev eth0 table default
pre-down ip -4 rule delete pref 32765 from 10.0.0.100/32 table default
down ip rule delete pref 32764 to 10.20.6.16/32 table default
iface eth1 inet6 static
address 2603:10e2:0:abcd::8
netmask 64
Expand Down
2 changes: 2 additions & 0 deletions src/sonic-config-engine/tests/sample_output/py3/interfaces
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ iface eth0 inet static
up ip -4 route add default via 10.0.0.1 dev eth0 table default metric 201
up ip -4 route add 10.0.0.0/24 dev eth0 table default
up ip -4 rule add pref 32765 from 10.0.0.100/32 table default
up ip rule add pref 32764 to 10.20.6.16/32 table default
# management port down rules
pre-down ip -4 route delete default via 10.0.0.1 dev eth0 table default
pre-down ip -4 route delete 10.0.0.0/24 dev eth0 table default
pre-down ip -4 rule delete pref 32765 from 10.0.0.100/32 table default
down ip rule delete pref 32764 to 10.20.6.16/32 table default
iface eth0 inet6 static
address 2603:10e2:0:2902::8
netmask 64
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ iface eth0 inet static
up ip -4 rule add pref 32765 from 10.0.0.100/32 table 5000
up ip -4 rule add pref 32764 to 11.11.11.11 table 5000
up ip -4 rule add pref 32764 to 22.22.22.0/23 table 5000
up ip rule add pref 32764 to 10.20.6.16/32 table 5000
# management port down rules
pre-down ip -4 route delete default via 10.0.0.1 dev eth0 table 5000
pre-down ip -4 route delete 10.0.0.0/24 dev eth0 table 5000
pre-down ip -4 rule delete pref 32765 from 10.0.0.100/32 table 5000
pre-down ip -4 rule delete pref 32764 to 11.11.11.11 table 5000
pre-down ip -4 rule delete pref 32764 to 22.22.22.0/23 table 5000
down ip rule delete pref 32764 to 10.20.6.16/32 table 5000
iface eth0 inet6 static
address 2603:10e2:0:2902::8
netmask 64
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ iface eth0 inet static
up ip -4 route add default via 10.0.0.1 dev eth0 table default metric 201
up ip -4 route add 10.0.0.0/24 dev eth0 table default
up ip -4 rule add pref 32765 from 10.0.0.100/32 table default
up ip rule add pref 32764 to 10.20.6.16/32 table default
# management port down rules
pre-down ip -4 route delete default via 10.0.0.1 dev eth0 table default
pre-down ip -4 route delete 10.0.0.0/24 dev eth0 table default
pre-down ip -4 rule delete pref 32765 from 10.0.0.100/32 table default
down ip rule delete pref 32764 to 10.20.6.16/32 table default
iface eth0 inet6 static
address 2603:10e2:0:2902::8
netmask 64
Expand Down Expand Up @@ -56,10 +58,12 @@ iface eth1 inet static
up ip -4 route add default via 10.0.10.1 dev eth1 table default metric 201
up ip -4 route add 10.0.10.0/24 dev eth1 table default
up ip -4 rule add pref 32765 from 10.0.10.100/32 table default
up ip rule add pref 32764 to 10.20.6.16/32 table default
# management port down rules
pre-down ip -4 route delete default via 10.0.10.1 dev eth1 table default
pre-down ip -4 route delete 10.0.10.0/24 dev eth1 table default
pre-down ip -4 rule delete pref 32765 from 10.0.10.100/32 table default
down ip rule delete pref 32764 to 10.20.6.16/32 table default
iface eth1 inet6 static
address 2603:10e2:0:abcd::8
netmask 64
Expand Down
Loading