#!/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 ID=$(wc -l < $RT_TABLES) echo $((ID+1)) $TABLE >> $RT_TABLES if [ -n "$SUBNET" ]; then ip rule add iif $VLAN table $TABLE ip route add $SUBNET dev $VLAN table main ip route add $SUBNET dev $VLAN table $TABLE if [ -n "$GATEWAY" ]; then ip route add default via $GATEWAY dev $VLAN table $TABLE fi arptables -A OUTPUT -o $VLAN --opcode request -j mangle --mangle-ip-s $ARP_IP echo 1 > /proc/sys/net/ipv4/conf/all/forwarding echo 1 > /proc/sys/net/ipv4/conf/$VLAN/proxy_arp fi if [ -n "$SUBNET6" ]; then ip -6 rule add iif $VLAN table $TABLE ip -6 route add $SUBNET6 dev $VLAN table main ip -6 route add $SUBNET6 dev $VLAN table $TABLE if [ -n "$GATEWAY6" ]; then ip -6 route add default via $GATEWAY6 dev $VLAN table $TABLE fi echo 1 > /proc/sys/net/ipv6/conf/all/forwarding echo 1 > /proc/sys/net/ipv6/conf/$VLAN/proxy_ndp fi