#!/bin/bash source /etc/default/snf-network source $CONF if [ ! -e $STATE_DIR/infra ]; then echo No infra file found! echo run: snf-network-build-node-infra exit 1 fi source $STATE_DIR/infra if [ $# -ne 5 ]; then echo "Usage: $0 " exit 1 fi RT_TABLES=/etc/iproute2/rt_tables TABLE=$1 SUBNET=$2 GATEWAY=$3 SUBNET6=$4 GATEWAY6=$5 VLAN=$PUBLIC_VLAN ARP_IP=$(ipcalc $SUBNET | grep HostMax | awk '{print $2}') ip link set $VLAN up if [ -n "$SUBNET" ]; then arptables -D OUTPUT -o $VLAN --opcode request -j mangle --mangle-ip-s $ARP_IP if [ -n "$GATEWAY" ]; then ip route del default via $GATEWAY dev $VLAN table $TABLE fi ip route del $SUBNET dev $VLAN table $TABLE ip route del $SUBNET dev $VLAN table main ip rule del iif $VLAN table $TABLE fi if [ -n "$SUBNET6" ]; then if [ -n "$GATEWAY6" ]; then ip -6 route del default via $GATEWAY6 dev $VLAN table $TABLE fi ip -6 route add $SUBNET6 dev $VLAN table $TABLE ip -6 route add $SUBNET6 dev $VLAN table main ip -6 rule add iif $VLAN table $TABLE fi sed -i 's/.*'"$TABLE"'$//' $RT_TABLES