Statistics
| Branch: | Tag: | Revision:

root / snf-network-masq-on @ 8306820f

History | View | Annotate | Download (539 Bytes)

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 3 ]; then
16
  echo "Usage: $0 <masq bridge> <subnet> <gateway>"
17
  exit 1
18
fi
19

    
20
#TODO include this in infra file
21
MASQ_BRIDGE=$1
22
SUBNET=$2
23
GATEWAY=$3
24

    
25

    
26
NETMASK=$(ipcalc $SUBNET | grep Netmask | awk '{print $4}')
27

    
28
ip addr add $GATEWAY/$NETMASK dev $MASQ_BRIDGE
29
iptables -t nat -A POSTROUTING -s $SUBNET \! -d $SUBNET -j MASQUERADE
30