Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash -e
#this script requires a routing table named $IFACE (ie. bond0) exists in /etc/iproute2/rt_tables
#the $IFACE routing table is used to place the default route in for the source routing table
#ip route list table $IFACE will list the routing table for this interface
set -x
set_netinfo() {
NETWORK=$(ip route show dev $IFACE | grep -v default | head -n 1 | awk '{print $1}')
GATEWAY=$(ip route show dev $IFACE default | head -n 1 | awk '{print $3}')