This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
access_restrictions [2021/05/30 19:11] – hogwild | access_restrictions [2023/05/10 19:58] – -format-bullet Field 4 days of week hogwild | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Access Restrictions ====== | + | ====== |
- | Access Restriction rules are coded as pipe (|) separated strings and stored in nvram variables named rrule0, rrule1, rrule2 | + | Access Restriction rules are coded as strings separated by pipe ( | ) symbols. These are stored in NVRAM as variables named //rrule0//, //rrule1//, //rrule2// and so on. |
- | < | + | To see what's in the first rule, we can issue the following command at a FreshTomato shell prompt: |
- | The returned string might look something like: | + | \\ |
- | <code> | + | <code -> |
+ | nvram get rrule0 | ||
+ | </ | ||
- | Let us take a closer look at what each of these nine fields separated by pipe (|) means. | + | \\ |
- | The first field shows whether the rule is currently enabled or disabled – 1 means enabled, 0 means disabled. | + | The returned string might look something like this: |
- | The second field gives the start time, i.e. the time to start applying this rule, in minutes elapsed since midnight. In the above example start time is 540 meaning the router should enforce this rule starting at 9am. The third field is the end time, i.e. the time to stop applying this rule, again coded the same way as the start time. Both the second and third fields will be -1 if you select the option //‘All Day’// in the control panel. | + | \\ |
- | The fourth field is the days of week on which the rule should be applied and is coded in binary – 1 for Sunday, 2 for Monday, 4 for Tuesday and so on. For multiple days, add the corresponding numbers for each day. In the above example the fourth field is 62 which is equal to 2+4+8+16+32 – meaning the rule should be active on Mon, Tue, Wed, Thu, and Fri i.e. only on week days. If you had checked the option | + | <code -> |
+ | 1|540|1140|62|||block-site.com$|0|New Rule 1 | ||
+ | </code> | ||
- | The fifth field shows the ip or mac address range in your network for which the rule should be applied – in case you don’t want all the computers on the network to be affected by this rule. The sixth field has the // | + | \\ |
- | The seventh field contains the domains or URLs you want to block and it partially supports regular expressions. In the above example, domain names ending in // | + | Let's look more closely at what each of these fields separated by a pipe ( | ) symbol means. |
- | Now with this basic understanding about how the Access Restriction rules in FreshTomato work, we can write shell scripts to control the rules. Below is the script I wrote to enable or disable a rule. Two values are passed on the command line – the rule number and either a 0 or a 1 to disable or enable the service respectively. If you have **jffs** enabled | + | **Field 1:** indicates whether the rule is currently |
- | < | + | **Field 2:** specifies the start time, (time to start applying this rule), in minutes elapsed since midnight. In this case, start time is 5:40 AM, so the router should enforce this rule starting at 9:00 AM. |
+ | |||
+ | **Field 3:** is the end time, (time to stop applying this rule). This is coded similarly to the start time. Both the second and third fields will be -1 if you select the //‘All Day’// option in the Access Restrictions menu. | ||
+ | |||
+ | **Field 4:** specifies the days on which the rule will be applied. It is coded in binary: | ||
+ | |||
+ | * 1 = Sunday | ||
+ | * 2 = Monday | ||
+ | * 3=Tuesday | ||
+ | * 4=Wednesday | ||
+ | * 5=Thursday | ||
+ | * 6=Saturday | ||
+ | * 6=Sunday | ||
+ | |||
+ | For multiple days, add the corresponding numbers for each day. In the above example the fourth field is 62 which is equal to 2+4+8+16+32 . This means the rule should be active on Mon, Tue, Wed, Thu, and Fri. In other words, only on week days. If you had checked the option // | ||
+ | |||
+ | **Field 5:** shows the IP or MAC Address range on your network for which the rule should be applied. | ||
+ | |||
+ | **Field 6:** has the // | ||
+ | |||
+ | **Field 7:** contains the Domains/ | ||
+ | |||
+ | **Field 8:** stores as a binary coded value if ActiveX, Flash or Java are to be blocked. 1 will block ActiveX, 2 will block Flash and 4 will block Java. | ||
+ | |||
+ | **Field 9:** stores the name that you gave to the above rule. | ||
+ | |||
+ | | ||
+ | |||
+ | \\ | ||
+ | |||
+ | < | ||
#!/bin/sh | #!/bin/sh | ||
Line 64: | Line 98: | ||
===== Credits ===== | ===== Credits ===== | ||
- | + | [[http:// | |
- | [[http:// | + | |