12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- #!/bin/sh
- CONFIG=1
- source /usr/sbin/helper.sh
- DNSMASQ_CONF=/tmp/etc/dnsmasq.conf
- cmd_log () {
- #if [ ${1} -ne 0 ]; then
- logger "${2}[${1}] - ${3}"
- #fi
- }
- cmd_run () {
- CMD=`${2}`
- ERRCODE=$?
- cmd_log ${ERRCODE} "${1}" "${ERR}: ${2}, ${CMD}"
- return ${ERRCODE}
- }
- iptable () {
- IFACE=`echo "${1}"`
- local OPT=`echo "${2}"`
- shift 2
- if [ "${OPT}" = "I" ]; then
- iptable "${IFACE}" "D" ${@}
- fi
- if [ $# -eq 1 ]; then
- cmd_run "iptable" "iptables -t nat -${OPT} POSTROUTING -s ${1} -o ${IFACE} -j MASQUERADE"
- elif [ $# -eq 2 ]; then
- cmd_run "iptable" "iptables -${OPT} ${1} -i ${IFACE} -m state --state NEW -j ${2}"
- elif [ $# -eq 3 ]; then
- cmd_run "iptable" "iptables -${OPT} ${1} -i ${IFACE} -o ${3} -j ${2}"
- else
- cmd_log 0 "iptable" "Unknown argument length ${#} (${@})."
- fi
- }
- ebtable () {
- if [ "${2}" = "I" ]; then
- ebtable "${1}" "D" "${3}"
- fi
- cmd_run "ebtable" "ebtables -t broute -${2} BROUTING -p ${3} -i ${1} -j DROP"
- }
|