Statistics
| Branch: | Tag: | Revision:

root / snf-network-ipless-routing-off @ 8306820f

History | View | Annotate | Download (1.1 kB)

1
#!/bin/bash
2

    
3
source /etc/default/snf-network
4

    
5
source $CONF
6

    
7
if [ ! -e $STATE_DIR/infra ]; then
8
  echo No infra file found!
9
  echo run: snf-network-build-node-infra
10
  exit 1
11
fi
12

    
13
source $STATE_DIR/infra
14

    
15
if [ $# -ne 5 ]; then
16
  echo "Usage: $0 <routing table> <subnet> <gateway> <subnet6> <gateway6>"
17
  exit 1
18
fi
19

    
20
RT_TABLES=/etc/iproute2/rt_tables
21

    
22
TABLE=$1
23
SUBNET=$2
24
GATEWAY=$3
25
SUBNET6=$4
26
GATEWAY6=$5
27

    
28
VLAN=$PUBLIC_VLAN
29

    
30
ARP_IP=$(ipcalc $SUBNET | grep HostMax | awk '{print $2}')
31

    
32
ip link set $VLAN up
33

    
34
if [ -n "$SUBNET" ]; then
35
  arptables -D OUTPUT -o $VLAN --opcode request -j mangle --mangle-ip-s $ARP_IP 
36
  if [ -n "$GATEWAY" ]; then  
37
    ip route del default via $GATEWAY dev $VLAN table $TABLE
38
  fi
39
  ip route del $SUBNET dev $VLAN table $TABLE
40
  ip route del $SUBNET dev $VLAN table main 
41
  ip rule del iif $VLAN table $TABLE
42
fi
43

    
44
if [ -n "$SUBNET6" ]; then
45
  if [ -n "$GATEWAY6" ]; then
46
    ip -6 route del default via $GATEWAY6 dev $VLAN table $TABLE
47
  fi
48
  ip -6 route add $SUBNET6 dev $VLAN table $TABLE
49
  ip -6 route add $SUBNET6 dev $VLAN table main
50
  ip -6 rule add iif $VLAN table $TABLE
51
fi
52

    
53
sed -i 's/.*'"$TABLE"'$//' $RT_TABLES
54