Skip to content

Instantly share code, notes, and snippets.

@artburkart
Last active June 8, 2018 17:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save artburkart/9a3b0571ce9a41fc468dd97821cb5ce4 to your computer and use it in GitHub Desktop.
Save artburkart/9a3b0571ce9a41fc468dd97821cb5ce4 to your computer and use it in GitHub Desktop.
Persisting advmss across reboots
#!/bin/bash
# This takes advantage of the code in /etc/sysconfig/network-scripts/ifup-routes
# handle_file () {
# . $1
# routenum=0
# while [ "x$(eval echo '$'ADDRESS$routenum)x" != "xx" ]; do
# eval $(ipcalc -p $(eval echo '$'ADDRESS$routenum) $(eval echo '$'NETMASK$routenum))
# line="$(eval echo '$'ADDRESS$routenum)/$PREFIX"
# if [ "x$(eval echo '$'GATEWAY$routenum)x" != "xx" ]; then
# line="$line via $(eval echo '$'GATEWAY$routenum)"
# fi
# line="$line dev $2"
# /sbin/ip route add $line
# routenum=$(($routenum+1))
# done
# }
# NOTE: Only do this if you're not using DHCP for some reason
GW="$(ip route show 0.0.0.0/0 dev eth0 | cut -d\ -f3)"
GATEWAY0="$GW advmss 1380"
NETMASK0=255.255.255.192
ADDRESS0=10.20.101.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment