Enable multiply public ips for redundant router

Also solve duplicate mac issue.
This commit is contained in:
Sheng Yang 2011-06-01 11:05:45 -07:00
parent 7462aa8539
commit 2973ab5ef5
2 changed files with 7 additions and 9 deletions

View File

@ -37,7 +37,6 @@ add_nat_entry() {
local ipNoMask=$(echo $1 | awk -F'/' '{print $1}')
sudo ip link show $ethDev | grep "state DOWN" > /dev/null
local old_state=$?
sudo ip link set $ethDev up
sudo ip addr add dev $ethDev $pubIp
sudo iptables -D FORWARD -i $ethDev -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -D FORWARD -i eth0 -o $ethDev -j ACCEPT
@ -45,16 +44,16 @@ add_nat_entry() {
sudo iptables -A FORWARD -i $ethDev -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i eth0 -o $ethDev -j ACCEPT
sudo iptables -t nat -I POSTROUTING -j SNAT -o $ethDev --to-source $ipNoMask ;
sudo arping -c 3 -I $ethDev -A -U -s $ipNoMask $ipNoMask;
if [ $? -gt 0 -a $? -ne 2 ]
then
logger -t cloud "$(basename $0):Failed adding nat entry for ip $pubIp on interface $ethDev"
return 1
fi
logger -t cloud "$(basename $0):Added nat entry for ip $pubIp on interface $ethDev"
if [ $old_state -eq 0 ]
if [ $old_state -ne 0 ]
then
sudo ip link set $ethDev down
sudo ip link set $ethDev up
sudo arping -c 3 -I $ethDev -A -U -s $ipNoMask $ipNoMask;
fi
return 0
@ -87,13 +86,12 @@ add_an_ip () {
sudo ip link show $ethDev | grep "state DOWN" > /dev/null
local old_state=$?
sudo ip link set $ethDev up
sudo ip addr add dev $ethDev $pubIp ;
sudo arping -c 3 -I $ethDev -A -U -s $ipNoMask $ipNoMask;
if [ $old_state -eq 0 ]
if [ $old_state -ne 0 ]
then
sudo ip link set $ethDev down
sudo ip link set $ethDev up
sudo arping -c 3 -I $ethDev -A -U -s $ipNoMask $ipNoMask;
fi
return $?

View File

@ -2,6 +2,6 @@
ifconfig eth2 down && \
ifconfig eth2 hw ether [ETH2MAC] && \
ifconfig eth2 [ETH2IP] && \
ifconfig eth2 up && \
ip route add 0/0 via [GATEWAY] && \
service dnsmasq restart