From f3490cefd3f29f8a1972589c4e11312b28394f8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20W=20Baul=C3=A9?= Date: Fri, 22 Apr 2022 23:53:45 -0300 Subject: [PATCH 1/2] Remove PREFIX from iptables rules Add verification to lease that is a "*" this is the case, when the hostname don't exist in leases file, but is there. --- iptmon/src/usr/sbin/iptmon | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/iptmon/src/usr/sbin/iptmon b/iptmon/src/usr/sbin/iptmon index 9fbe6f4..6ed011c 100755 --- a/iptmon/src/usr/sbin/iptmon +++ b/iptmon/src/usr/sbin/iptmon @@ -104,6 +104,9 @@ reverse_lookup() { if [[ "${host}x" = "x" ]] ; then host=$(nslookup ${ip} | grep 'name = ' | sed -E 's/^.*name = ([a-zA-Z0-9-]+).*$/\1/') fi + if [[ "${host}" = "*" ]] ; then + host=${ip} + fi printf "%s" ${host} } @@ -142,7 +145,7 @@ dnsmasq_add() { IFS=$'\n'; for rule in $EXISTING; do eval "$IPTABLES -t mangle $rule"; done IFS=$OLD_IFS fi - $IPTABLES -t mangle -A $chain $SRC_DST $ip -j RETURN -m comment --comment "${PREFIX}_${host}" + $IPTABLES -t mangle -A $chain $SRC_DST $ip -j RETURN -m comment --comment "${host}" done printf "added iptmon entry for %s %s\n" "${ip}" "${host}" @@ -174,7 +177,7 @@ dnsmasq_del() { esac if $IPTABLES -t mangle -nL $chain | grep -q "${ip}" ; then - $IPTABLES -t mangle -D $chain $SRC_DST "${ip}" -j RETURN -m comment --comment "${PREFIX}_${host}" + $IPTABLES -t mangle -D $chain $SRC_DST "${ip}" -j RETURN -m comment --comment "${host}" printf "deleted IPv%d %s entry for %s %s\n" $FAMILY $PREFIX "${ip}" "${host}" fi done @@ -252,4 +255,4 @@ case $1 in *) usage ;; -esac \ No newline at end of file +esac From 32decfd9afea6aff1f8e1b058fbd0d95b12ece38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20W=20Baul=C3=A9?= Date: Wed, 25 May 2022 20:06:06 -0300 Subject: [PATCH 2/2] Missing escape --- iptmon/src/usr/sbin/iptmon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iptmon/src/usr/sbin/iptmon b/iptmon/src/usr/sbin/iptmon index 6ed011c..b8b3ecb 100755 --- a/iptmon/src/usr/sbin/iptmon +++ b/iptmon/src/usr/sbin/iptmon @@ -104,7 +104,7 @@ reverse_lookup() { if [[ "${host}x" = "x" ]] ; then host=$(nslookup ${ip} | grep 'name = ' | sed -E 's/^.*name = ([a-zA-Z0-9-]+).*$/\1/') fi - if [[ "${host}" = "*" ]] ; then + if [[ "${host}" = "\*" ]] ; then host=${ip} fi printf "%s" ${host}