Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision Next revisionBoth sides next revision | ||
| docs:guide-user:firewall:fw3_configurations:fw3_parent_controls [2019/10/07 22:29] – [Web interface] Suggestion for a global Reject rule, and specific Accept rules. In line with hnyman input at https://forum.openwrt.org/t/luci-access-control-why-not-available-in-lede/3401/9 wastuplu | docs:guide-user:firewall:fw3_configurations:fw3_parent_controls [2023/08/30 08:26] – [Blocking services with banIP] vgaetera | ||
|---|---|---|---|
| Line 2: | Line 2: | ||
| {{section> | {{section> | ||
| - | Parental control of internet access can be done in several ways: | + | ===== Introduction ===== |
| - | * Timely restriction | + | * This article describes common methods to perform parental control |
| - | * Restrict / deny / block access | + | * Be sure to apply restrictions |
| - | ===== Block access to certain web pages ===== | + | ===== Restrict / deny / block access to certain web pages ===== |
| - | There are many ways to block access to unwanted websites, many of them void the DNS lookup so, for example, '' | + | ==== Blocking servers |
| - | These can be foiled quite easily | + | Follow: |
| - | The [[packages:pkgdata: | + | [[docs: |
| - | [[docs: | + | |
| - | ===== Timely restriction | + | If a server is running at a single IP or just uses a small set of IPs, blocking these IPs in fw3 is a very efficient way to block this site. |
| - | **Example: | + | It is the quickest and most efficient way of blocking websites and is well supported even in the web interface. |
| + | Assuming OpenWrt operates with a LAN and WAN zone a filter in the FORWARD chain that rejects packets is enough. | ||
| + | ASN lists could be used to block large numbers of IPs belonging to certain | ||
| + | A script would be used to fetch all current IPs assigned to a certain company and this information is used to update the firewall accordingly. | ||
| - | ==== Web interface ==== | + | Drawbacks: |
| - | First, make sure that your router has the right time **and** the right timezone. | + | * To circumvent these IP based restrictions an internet proxy or Tor could be used. |
| + | | ||
| - | <WRAP group> | + | ==== Blocking name resolution (DNS) by Adblockers ==== |
| - | <WRAP half column> | + | Follow: |
| - | - // | + | [[docs: |
| - | - Add name for your rule, e.g. "Kids weeksdays", | + | [[docs: |
| - | - Source zone: lan | + | |
| - | | + | |
| - | - Click //Add and edit// | + | |
| - | - Select //Source MAC address// or //Source address// | + | |
| - | - Set //Action// to be // | + | |
| - | - Select weekdays | + | |
| - | - Select start/stop time | + | |
| - | - Save& | + | |
| - | </ | + | |
| - | <WRAP half column> | + | This method voids DNS lookups so, for example, '' |
| - | {{ :media:docs:howto:firewall_-_parental_control_settings_via_luci.png? | + | Adblock can be used to blacklist certain domain names and prevent the DNS server handing out the right IP. |
| - | </WRAP> | + | Alternatively Dnsmasq can be configured to return a NXDOMAIN answer in case a blacklisted domain name is queried. |
| + | Another option is to use Pi-hole in the LAN and divert DNS requests to Pi-hole. | ||
| + | |||
| + | Drawbacks: | ||
| + | * If the IP of the server is known, it can be reached directly without using DNS altogether. | ||
| + | * These restrictions can be foiled quite easily by using another internet site to lookup the IP address for the site and bypassing DNS altogether. | ||
| + | * If several DNS are in the LAN just changing the local settings to the unfiltered DNS renders this control useless. | ||
| + | |||
| + | ==== Blocking IPs based on their domain names (FQDN, host names) ==== | ||
| + | Follow: | ||
| + | [[docs: | ||
| + | |||
| + | Since OpenWrt in a typical setup with a LAN and WAN zone does the name resolution and the firewall at the same time, all information is there to match domain names, their current IPs as they are handed out to the LAN-hosts and act accordingly in the firewall. | ||
| + | This is essential if a single domain might resolve to several IPs. | ||
| + | For instance websites that operate with a CDN can be blocked by their name instead of finding out each and every IP the CDN might be using. | ||
| + | |||
| + | Drawbacks: | ||
| + | * This will block all sites sharing the same IP with the targeted, so use carefully for domains which rely on [[wp> | ||
| + | * Completely blocking sites that use localized domains is problematic. | ||
| + | |||
| + | ==== Blocking services with banIP ==== | ||
| + | See also: | ||
| + | [[packages: | ||
| + | [[packages: | ||
| + | |||
| + | banIP can block services using IP/CIDR lists, e.g. you can block WhatsApp with [[https:// | ||
| + | |||
| + | <code bash> | ||
| + | opkg update | ||
| + | opkg install banip luci-app-banip | ||
| + | uci set banip.global.ban_enabled=" | ||
| + | uci del_list banip.global.ban_feed=" | ||
| + | uci add_list banip.global.ban_feed=" | ||
| + | uci commit banip | ||
| + | . / | ||
| + | json_init | ||
| + | json_load_file / | ||
| + | json_add_object " | ||
| + | json_add_string " | ||
| + | json_add_string " | ||
| + | HybridNetworks/ | ||
| + | json_add_string " | ||
| + | json_close_object | ||
| + | json_dump > / | ||
| + | / | ||
| + | </ | ||
| + | |||
| + | ==== Blocking sites by using proxy servers ===== | ||
| + | Follow: | ||
| + | [[docs:guide-user:services: | ||
| + | |||
| + | A proxy server like [[docs: | ||
| + | It can check HTTP(S) specific details. | ||
| + | The huge benefit of this option is to have the finest level of control. | ||
| + | It can even distinguish in cases where a single server with a single IP runs for example a blacklisted and whitelisted domain at once. | ||
| + | |||
| + | Squid offers many features like SNI HTTPS based filtering, SSL-bump and splice. However, for typical resource constrained devices, Tinyproxy offers the most important options (filtering websites) as well. For parental control, due to ease of setup and low RAM/Flash requirements, | ||
| + | |||
| + | Drawbacks: | ||
| + | * If not everything else except the proxy is blocked, it can be circumvented. The firewall must block the client-device from accessing the internet directly. | ||
| + | * The clients need to configure the proxy in their browser. | ||
| + | |||
| + | ===== Time restriction of internet access | ||
| + | Block internet access for MAC or IP addresses (or everyone) on week days during specific time interval. | ||
| + | |||
| + | < | ||
| + | * Verify that your router has the correct time and timezone. | ||
| + | * Apply the following workarounds to ensure reliable operation: | ||
| + | * [[docs: | ||
| + | * [[docs: | ||
| </ | </ | ||
| - | More detailed explanations in French: | + | ==== Web interface instructions ==== |
| - | [[https:// | + | Adjust the parameters according to your configuration. |
| - | NB: If your focus is on authorised timeslots, | + | - Navigate to **LuCI -> Network -> Firewall -> Traffic Rules**. |
| + | - Click **Add** and specify: | ||
| + | * Name: '' | ||
| + | * Protocol: Any | ||
| + | * Source zone: '' | ||
| + | * Destination zone: '' | ||
| + | * Action: reject | ||
| + | - (Optional) | ||
| + | * Source MAC address: '' | ||
| + | * Source IP address: '' | ||
| + | - On the **Time Restrictions** tab specify: | ||
| + | * Week Days: Monday, Tuesday, Wednesday, Thursday, Friday | ||
| + | * Start Time: '' | ||
| + | * Stop Time: '' | ||
| + | - Click **Save**, then **Save & Apply**. | ||
| - | ==== Command-line | + | You can add another rule to apply time restrictions on weekend. |
| + | |||
| + | ==== Command-line | ||
| Add a new firewall rule. | Add a new firewall rule. | ||
| Edit the following example code block to suit your needs and then copy-paste it into the terminal. | Edit the following example code block to suit your needs and then copy-paste it into the terminal. | ||
| Line 48: | Line 127: | ||
| <code bash> | <code bash> | ||
| + | # Configure firewall | ||
| uci add firewall rule | uci add firewall rule | ||
| - | uci set firewall.@rule[-1].name=" | + | uci set firewall.@rule[-1].name=" |
| uci set firewall.@rule[-1].src=" | uci set firewall.@rule[-1].src=" | ||
| - | uci set firewall.@rule[-1].src_mac=" | + | uci set firewall.@rule[-1].src_mac=" |
| uci set firewall.@rule[-1].dest=" | uci set firewall.@rule[-1].dest=" | ||
| uci set firewall.@rule[-1].start_time=" | uci set firewall.@rule[-1].start_time=" | ||
| uci set firewall.@rule[-1].stop_time=" | uci set firewall.@rule[-1].stop_time=" | ||
| uci set firewall.@rule[-1].weekdays=" | uci set firewall.@rule[-1].weekdays=" | ||
| - | uci set firewall.@rule[-1].utc_time=" | ||
| uci set firewall.@rule[-1].target=" | uci set firewall.@rule[-1].target=" | ||
| uci commit firewall | uci commit firewall | ||
| Line 62: | Line 141: | ||
| </ | </ | ||
| - | Once the time is reached, | + | ===== Restrict access to Wi-Fi by MAC address ===== |
| - | The rules should be reordered | + | Restrict access to your Wi-Fi by MAC address. |
| + | The primary motivation for this capability | ||
| + | Later you no longer want to allow the person to use your Wi-Fi. | ||
| + | There are several solutions to this problem with decreasing labor and effectiveness. | ||
| + | - The most comprehensive is to create a [[docs: | ||
| + | - Change the passphrase for the interfaces. | ||
| + | - Only allow/deny LAN access for devices with matching MAC addresses. | ||
| + | |||
| + | This section focuses on the last option using the wireless interface MAC filter option. | ||
| + | This is a simple solution that can be invalidated by a smart hacker changing the MAC address of their device. | ||
| + | |||
| + | ==== Web interface instructions ==== | ||
| + | - Navigate to **LuCI -> Network -> Wireless**. | ||
| + | - Click **Edit** on a selected interface. | ||
| + | - On the **MAC Address Filter** tab specify: | ||
| + | * MAC Address Filter: | ||
| + | * Allow listed only | ||
| + | * Allow all except listed | ||
| + | * MAC List: | ||
| + | * '' | ||
| + | * '' | ||
| + | - Click **Save**, then **Save & Apply**. | ||
| + | |||
| + | ==== Command-line instructions ==== | ||
| <code bash> | <code bash> | ||
| - | cat << " | + | # Use allow-type or deny-type filter |
| - | for IPT in iptables ip6tables | + | uci set wireless.@wifi-iface[0].macfilter=" |
| - | do | + | uci set wireless.@wifi-iface[0].macfilter="deny" |
| - | ${IPT}-save -c -t filter | + | |
| - | | sed -e "/ | + | |
| - | /FORWARD.*reject/i $(${IPT}-save -c -t filter \ | + | |
| - | | sed -n -e "/ | + | |
| - | | ${IPT}-restore -c -T filter | + | |
| - | done | + | |
| - | EOF | + | |
| - | uci -q delete firewall.estab | + | # Append the MAC address to the list |
| - | uci set firewall.estab="include" | + | uci add_list wireless.@wifi-iface[0].maclist="11: |
| - | uci set firewall.estab.path="/ | + | uci add_list wireless.@wifi-iface[0].maclist="aa: |
| - | uci set firewall.estab.reload=" | + | |
| - | uci commit | + | # Check settings |
| - | / | + | uci show wireless.@wifi-iface[0] |
| - | </ | + | |
| + | # Save and apply | ||
| + | uci commit | ||
| + | wifi reload | ||
| + | </ | ||
| + | |||
| + | You need to apply this for all wireless interfaces accessible by the user. | ||
| + | Typically the 5 Ghz band is '' | ||