With nftables one can create filters based on meta data.
Meta data is data that is available but which are not part of the traffic flowing between two hosts on the Internet.
This includes detail about the hardware (e.g. the interface through which the traffic flows)
It also includes detail about the time when the traffic is flowing.
With these meta data filters that is available we formulated the options that you can select when adding a rule to a Firewall Profile.
One aspect which makes our implementation unique is the fact that we work on layer two and not layer three.
The reason for this is that MESHdesk and APdesk allows you to create bridged networks where the IP Address management (DHCP) can be done by another device on the network.
By working on layer two it allows us to formulate rules without the requirement to know the IP Address of a device or Exit Point to which the Firewall Profile is associated with.
You will need the compulsory kmod-nft-bridge nftable module.
Make sure it is included with the OpenWrt based firmware.
The adv_meshdesk bridge table is where things are happening.
You can inspect the table using the following command nft -e -a list table bridge adv_meshdesk.
nft -e -a list table bridge adv_meshdesk
table bridge adv_meshdesk { # handle 2
set YouTube { # handle 4
type ipv4_addr
flags interval
elements = { 172.217.0.0/16 comment "Block YouTube" }
}
set md_lan { # handle 5
type ipv4_addr
flags interval
elements = { 10.0.0.0/8, 172.16.0.0/12,
192.168.0.0/16 comment "Private IP Addr LAN" }
}
set md_internet_not { # handle 6
type ipv4_addr
flags interval
elements = { 10.0.0.0/8, 172.16.0.0/12,
192.168.0.0/16 comment "Private IP Addr Excl For Internet" }
}
chain forward { # handle 1
type filter hook forward priority 0; policy accept;
meta day { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday" } meta hour "07:00"-"17:00" iif "zero0" ip daddr @YouTube counter packets 0 bytes 0 drop comment "DROP ON zero0," # handle 8
}
chain input { # handle 2
type filter hook input priority 0; policy accept;
meta day { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday" } meta hour "07:00"-"17:00" iif { "one0", "two1" } ip daddr @YouTube counter packets 0 bytes 0 drop comment "DROP ON two1,one0," # handle 11
}
chain output { # handle 3
type filter hook output priority 0; policy accept;
}
}
Here you can see the rules which were generated for the Youtube Block Firewall Profile which we defined and applied on a NAT/DHCP and also a bridged exit point.
The forward chain rule is for the bridged exit point.
The input chain rule is for the NAT/DHCP exit point.
As you can see our time of day and also the days to apply is in the meta day and meta hour parts respectively.