Skip to content

Commit 2dab9da

Browse files
authored
[config load_mgmt_config] add default route (sonic-net#123)
1 parent 52dd13e commit 2dab9da

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

config/main.py

+5
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,13 @@ def load_mgmt_config(filename):
145145
hostname = config_data['DEVICE_METADATA']['localhost']['hostname']
146146
_change_hostname(hostname)
147147
mgmt_conf = netaddr.IPNetwork(config_data['MGMT_INTERFACE'].keys()[0][1])
148+
gw_addr = config_data['MGMT_INTERFACE'].values()[0]['gwaddr']
148149
command = "ifconfig eth0 {} netmask {}".format(str(mgmt_conf.ip), str(mgmt_conf.netmask))
149150
run_command(command, display_cmd=True)
151+
command = "ip route add default via {} dev eth0 table default".format(gw_addr)
152+
run_command(command, display_cmd=True)
153+
command = "ip rule add from {} table default".format(str(mgmt_conf.ip))
154+
run_command(command, display_cmd=True)
150155
command = "[ -f /var/run/dhclient.eth0.pid ] && kill `cat /var/run/dhclient.eth0.pid` && rm -f /var/run/dhclient.eth0.pid"
151156
run_command(command, display_cmd=True)
152157
print "Please note loaded setting will be lost after system reboot. To preserve setting, run `config save`."

0 commit comments

Comments
 (0)