Skip to content

Commit

Permalink
[config load_mgmt_config] add default route (sonic-net#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
taoyl-ms committed Oct 6, 2017
1 parent 52dd13e commit 2dab9da
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,13 @@ def load_mgmt_config(filename):
hostname = config_data['DEVICE_METADATA']['localhost']['hostname']
_change_hostname(hostname)
mgmt_conf = netaddr.IPNetwork(config_data['MGMT_INTERFACE'].keys()[0][1])
gw_addr = config_data['MGMT_INTERFACE'].values()[0]['gwaddr']
command = "ifconfig eth0 {} netmask {}".format(str(mgmt_conf.ip), str(mgmt_conf.netmask))
run_command(command, display_cmd=True)
command = "ip route add default via {} dev eth0 table default".format(gw_addr)
run_command(command, display_cmd=True)
command = "ip rule add from {} table default".format(str(mgmt_conf.ip))
run_command(command, display_cmd=True)
command = "[ -f /var/run/dhclient.eth0.pid ] && kill `cat /var/run/dhclient.eth0.pid` && rm -f /var/run/dhclient.eth0.pid"
run_command(command, display_cmd=True)
print "Please note loaded setting will be lost after system reboot. To preserve setting, run `config save`."
Expand Down

0 comments on commit 2dab9da

Please sign in to comment.