[sonic-cfggen] MGMT Interface configuration (#4280)

update network and broadcast address in /etc/network/interfaces

Before:
root@sonic:/home/admin# ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.28.32.73  netmask 255.255.254.0  broadcast 0.0.0.0 <<<<<

After:
root@sonic:~# ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.28.32.73  netmask 255.255.254.0  broadcast 10.28.33.255 <<<<<

Signed-off-by: Antony Rheneus <arheneus@marvell.com>
This commit is contained in:
arheneus@marvell.com 2020-03-22 02:55:19 +05:30 committed by GitHub
parent 20260ceb1d
commit 94162679bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 1 deletions

View File

@ -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' %}

View File

@ -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)))

View File

@ -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

View File

@ -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