diff --git a/files/image_config/interfaces/interfaces.j2 b/files/image_config/interfaces/interfaces.j2 index dbb2b1f341..0e852a1150 100644 --- a/files/image_config/interfaces/interfaces.j2 +++ b/files/image_config/interfaces/interfaces.j2 @@ -64,6 +64,8 @@ iface {{ port }} inet6 dhcp iface eth0 {{ 'inet' if prefix | ipv4 else 'inet6' }} static address {{ prefix | ip }} netmask {{ prefix | netmask if prefix | ipv4 else prefix | prefixlen }} + network {{ prefix | network }} + broadcast {{ prefix | broadcast }} {% set vrf_table = 'default' %} {% if (MGMT_VRF_CONFIG) and (MGMT_VRF_CONFIG['vrf_global']['mgmtVrfEnabled'] == "true") %} {% set vrf_table = '5000' %} diff --git a/src/sonic-config-engine/sonic-cfggen b/src/sonic-config-engine/sonic-cfggen index 34f5a36f0f..13fc871d77 100755 --- a/src/sonic-config-engine/sonic-cfggen +++ b/src/sonic-config-engine/sonic-cfggen @@ -286,7 +286,7 @@ def main(): env.filters['unique_name'] = unique_name env.filters['pfx_filter'] = pfx_filter env.filters['ip_network'] = ip_network - for attr in ['ip', 'network', 'prefixlen', 'netmask']: + for attr in ['ip', 'network', 'prefixlen', 'netmask', 'broadcast']: env.filters[attr] = partial(prefix_attr, attr) template = env.get_template(template_file) print(template.render(sort_data(data))) diff --git a/src/sonic-config-engine/tests/sample_output/interfaces b/src/sonic-config-engine/tests/sample_output/interfaces index 913fc85314..07fd7a522c 100644 --- a/src/sonic-config-engine/tests/sample_output/interfaces +++ b/src/sonic-config-engine/tests/sample_output/interfaces @@ -12,6 +12,8 @@ auto eth0 iface eth0 inet static address 10.0.0.100 netmask 255.255.255.0 + network 10.0.0.0 + broadcast 10.0.0.255 ########## management network policy routing rules # management port up rules up ip -4 route add default via 10.0.0.1 dev eth0 table default metric 201 @@ -24,6 +26,8 @@ iface eth0 inet static iface eth0 inet6 static address 2603:10e2:0:2902::8 netmask 64 + network 2603:10e2:0:2902:: + broadcast 2603:10e2:0:2902:ffff:ffff:ffff:ffff ########## management network policy routing rules # management port up rules up ip -6 route add default via 2603:10e2:0:2902::1 dev eth0 table default metric 201 diff --git a/src/sonic-config-engine/tests/sample_output/mvrf_interfaces b/src/sonic-config-engine/tests/sample_output/mvrf_interfaces index 7bd664d4a9..633d8aa449 100644 --- a/src/sonic-config-engine/tests/sample_output/mvrf_interfaces +++ b/src/sonic-config-engine/tests/sample_output/mvrf_interfaces @@ -21,6 +21,8 @@ auto eth0 iface eth0 inet static address 10.0.0.100 netmask 255.255.255.0 + network 10.0.0.0 + broadcast 10.0.0.255 vrf mgmt ########## management network policy routing rules # management port up rules @@ -37,6 +39,8 @@ iface eth0 inet static iface eth0 inet6 static address 2603:10e2:0:2902::8 netmask 64 + network 2603:10e2:0:2902:: + broadcast 2603:10e2:0:2902:ffff:ffff:ffff:ffff vrf mgmt ########## management network policy routing rules # management port up rules