aiop-func 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/bin/sh
  2. CONFIG=1
  3. source /usr/sbin/helper.sh
  4. DNSMASQ_CONF=/tmp/etc/dnsmasq.conf
  5. cmd_log () {
  6. #if [ ${1} -ne 0 ]; then
  7. logger "${2}[${1}] - ${3}"
  8. #fi
  9. }
  10. cmd_run () {
  11. CMD=`${2}`
  12. ERRCODE=$?
  13. cmd_log ${ERRCODE} "${1}" "${ERR}: ${2}, ${CMD}"
  14. return ${ERRCODE}
  15. }
  16. iptable () {
  17. IFACE=`echo "${1}"`
  18. local OPT=`echo "${2}"`
  19. shift 2
  20. if [ "${OPT}" = "I" ]; then
  21. iptable "${IFACE}" "D" ${@}
  22. fi
  23. if [ $# -eq 1 ]; then
  24. cmd_run "iptable" "iptables -t nat -${OPT} POSTROUTING -s ${1} -o ${IFACE} -j MASQUERADE"
  25. elif [ $# -eq 2 ]; then
  26. cmd_run "iptable" "iptables -${OPT} ${1} -i ${IFACE} -m state --state NEW -j ${2}"
  27. elif [ $# -eq 3 ]; then
  28. cmd_run "iptable" "iptables -${OPT} ${1} -i ${IFACE} -o ${3} -j ${2}"
  29. else
  30. cmd_log 0 "iptable" "Unknown argument length ${#} (${@})."
  31. fi
  32. }
  33. ebtable () {
  34. if [ "${2}" = "I" ]; then
  35. ebtable "${1}" "D" "${3}"
  36. fi
  37. cmd_run "ebtable" "ebtables -t broute -${2} BROUTING -p ${3} -i ${1} -j DROP"
  38. }