quota and mac addresses

Report issues relating to bandwith monitoring, bandwidth quotas or QoS in this forum.

Moderator: Moderators

roadhawk
Posts: 14
Joined: Fri Feb 26, 2016 5:37 am
Location: Germany

Re: quota and mac addresses

Post by roadhawk »

No, iptables doesn't accept that syntax. The ! needs to be before --mac-source, not after it, thus:

Code: Select all

iptables -t filter -A lease_mismatch_check  -s  "$ip" -m mac ! --mac-source "$mac"  -j REJECT
Whether it actually does what it is supposed to do is a different matter which I will test in 8 hours.

nworbnhoj
Posts: 916
Joined: Mon Jul 21, 2014 10:08 am
Location: Australia
Contact:

Re: quota and mac addresses

Post by nworbnhoj »

Really!!?
http://linux.die.net/man/8/iptables
mac

--mac-source [!] address
Match source MAC address. It must be of the form XX:XX:XX:XX:XX:XX. Note that this only makes sense for packets coming from an Ethernet device and entering the PREROUTING, FORWARD or INPUT chains.
What am I missing??
Can you help someone else get Gargoyle up and running?
TL-WDR3600 : Gargoyle 1.9.0 : NBN FixedWireless
TL-WR1043ND-V2 : Gargoyle 1.8.0 : 3G Huawei E160E

roadhawk
Posts: 14
Joined: Fri Feb 26, 2016 5:37 am
Location: Germany

Re: quota and mac addresses

Post by roadhawk »

From my raspbian jessie:

Code: Select all


jh@rpi01-jh:~ $man iptables-extensions
.
.
mac
[!] --mac-source address
Match source MAC address. It must be of the form XX:XX:XX:XX:XX:XX. Note that this only makes sense for packets coming from an Ethernet device and entering the PREROUTING, FORWARD or INPUT chains. 
.
.
Strange, because die.net is usually the reference.

nworbnhoj
Posts: 916
Joined: Mon Jul 21, 2014 10:08 am
Location: Australia
Contact:

Re: quota and mac addresses

Post by nworbnhoj »

OK so that is weird - up until now I trusted man *

I have just tested on my TL-WDR3600 and indeed

Code: Select all

iptables -t filter -A lease_mismatch_check  -s  "$ip" -m mac ! --mac-source "$mac"  -j REJECT
Is the only syntax discussed above that does not raise an error from iptables after /etc/init.d/firewall restart

So let's work with this going forward and keep an eye out for errors on other platforms (just in case).

well done @roadhawk
Can you help someone else get Gargoyle up and running?
TL-WDR3600 : Gargoyle 1.9.0 : NBN FixedWireless
TL-WR1043ND-V2 : Gargoyle 1.8.0 : 3G Huawei E160E

Tareq
Posts: 58
Joined: Mon Dec 14, 2015 6:56 am

Re: quota and mac addresses

Post by Tareq »

hi nworbnhoj,

i didn't understand, what can i do exactly to fix my issue ?

Now i use this the original gargoyle_firewall_util.sh file in my router.

Code: Select all

block_static_ip_mismatches()
{
	block_mismatches=$(uci get firewall.@defaults[0].block_static_ip_mismatches 2> /dev/null)
	delete_chain_from_table static_mismatch_check filter
	if [ "$block_mismatches" = "1" ] && [ -e /etc/ethers ] ; then
		local pairs
		pairs=$(cat /etc/ethers | sed '/^[ \t]*$/d' | awk ' { print $1"^"$2"\n" ; } ' )
		if [ -n "$pairs" ] ; then
			iptables -t filter -N static_mismatch_check
			local p
			for p in $pairs ; do
				local mac
				local ip
				mac=$(echo $p | sed 's/\^.*$//g')
				ip=$(echo $p | sed 's/^.*\^//g')
				if [ -n "$ip" ] && [ -n "$mac" ] ; then
					iptables -t filter -A static_mismatch_check  ! -s  "$ip"  -m mac --mac-source  "$mac"  -j REJECT
				fi
			done
			iptables -t filter -I delegate_forward -j static_mismatch_check
		fi
	fi
}

Edit:
I really appreciate your efforts, so thank you.
TP-LINK WR841N. V8.4 | Gargoyle 1.9 | South Yemen

nworbnhoj
Posts: 916
Joined: Mon Jul 21, 2014 10:08 am
Location: Australia
Contact:

Re: quota and mac addresses

Post by nworbnhoj »

Try adding a single line to your gargoyle_firewall_util.sh file

Code: Select all

iptables -t filter -A lease_mismatch_check  -s  "$ip" -m mac ! --mac-source "$mac"  -j REJECT
immediately below the existing similar "iptables" line in your post so that it looks like

Code: Select all

for p in $pairs ; do
   local mac
   local ip
   mac=$(echo $p | sed 's/\^.*$//g')
   ip=$(echo $p | sed 's/^.*\^//g')
   if [ -n "$ip" ] && [ -n "$mac" ] ; then
      iptables -t filter -A lease_mismatch_check  ! -s  "$ip"  -m mac --mac-source  "$mac"  -j REJECT
      iptables -t filter -A lease_mismatch_check  -s  "$ip" -m mac ! --mac-source "$mac"  -j REJECT
   fi
done
and then restart the firewall with

Code: Select all

/etc/init.d/firewall restart
Can you help someone else get Gargoyle up and running?
TL-WDR3600 : Gargoyle 1.9.0 : NBN FixedWireless
TL-WR1043ND-V2 : Gargoyle 1.8.0 : 3G Huawei E160E

Tareq
Posts: 58
Joined: Mon Dec 14, 2015 6:56 am

Re: quota and mac addresses

Post by Tareq »

Hi, nworbnhoj

Thank you man, it works fine.
TP-LINK WR841N. V8.4 | Gargoyle 1.9 | South Yemen

Tareq
Posts: 58
Joined: Mon Dec 14, 2015 6:56 am

Re: quota and mac addresses

Post by Tareq »

Code: Select all

for p in $pairs ; do
   local mac
   local ip
   mac=$(echo $p | sed 's/\^.*$//g')
   ip=$(echo $p | sed 's/^.*\^//g')
   if [ -n "$ip" ] && [ -n "$mac" ] ; then
      iptables -t filter -A lease_mismatch_check  ! -s  "$ip"  -m mac --mac-source  "$mac"  -j REJECT
      iptables -t filter -A lease_mismatch_check  -s  "$ip" -m mac ! --mac-source "$mac"  -j REJECT
   fi
done

This code no longer works in the new update 1.10.0 .

please can you help.
TP-LINK WR841N. V8.4 | Gargoyle 1.9 | South Yemen

Lantis
Moderator
Posts: 6753
Joined: Mon Jan 05, 2015 5:33 am
Location: Australia

Re: quota and mac addresses

Post by Lantis »

What evidence do you have to say it doesn't work? What exactly are you trying to do and what error are you encountering?
http://lantisproject.com/downloads/gargoyle_ispyisail.php for the latest releases
Please be respectful when posting. I do this in my free time on a volunteer basis.

Tareq
Posts: 58
Joined: Mon Dec 14, 2015 6:56 am

Re: quota and mac addresses

Post by Tareq »

Lantis wrote:What evidence do you have to say it doesn't work? What exactly are you trying to do and what error are you encountering?
I'm sorry, it is really work fine without that code.

I have files that I have customized for myself, and when i copied it to new version, i had a problem because i replaced "gargoyle_firewall_ultil.sh" file.

Now it is work fine without replacing that file.

Thank you.
TP-LINK WR841N. V8.4 | Gargoyle 1.9 | South Yemen

Post Reply