#!/bin/bash
update-alternatives --set iptables  /usr/sbin/iptables-legacy

apstatus=`nmcli device status | grep wlan0 | grep Hotspot | awk '{print $3}'`
if  [[ $apstatus != "已连接" && $apstatus != "connected" ]]
then
	echo "please check wlan ap status!"
	exit 0
fi	
int_list=("eth0" "eth1")
for ieth in ${int_list[@]}; do
  status=`nmcli device status | grep $ieth | awk '{print $3 }'`
  if  [[ $status == "已连接" || $status == "connected" ]]
  then
     echo $ieth $status 
     `iptables -t nat -A POSTROUTING -s 10.42.0.1/24 -o $ieth -j MASQUERADE`
     break
  else
     continue
  fi
  echo $status
done

