Typo causing firewall to block it all

Hello!

I recently could not figure it out for a while why my router has no network and ‘ping’ returns “operation not permitted” error. Turns out I missed single quite in firewall config:

config zone             
  option name     'wan' 
  list network    'wan' 
  list network    'wan4'
  list network    'wan6he'
  list network    'wan6p'
  list network    'wan6te'
  list network    'wan6r48'
  list network    'wan4u 
  option input    REJECT 
  option output   ACCEPT  
  option forward  REJECT   
  option masq     1       
  option mtu_fix  1      
  option masq6    0  

Can it be more reliable?

It seems that you were directly editing the config files. I personally do the same and I accept the risks that I might make a typo that could 'break' things.

If you use LuCI (web interface) and/or UCI on the command line, things like quotes and the like will always be entered properly. This doesn't stop logical or some types of syntax issues (this is the price of a highly sophisticated and flexible environment), but it will prevent typos of this type from causing you grief.

1 Like

Sure I can use uci or luci. Question is it expected behavior, blocked all network access, including local access to the router just because of a single quote typo? I can’t suggest a solution right now, just raising a question.

Just like a programming language or even regular written languages, a single typo can indeed cause unexpected results.

The config files are a series of instructions with defined syntax and formatting. When there are errors in the syntax/formatting, it can be difficult to predict the resulting behavior.

So while I wouldn't necessarily say that the specific thing you experienced is "expected behavior," I would say that it is "not unexpected." That is to say -- it's not that the system is designed to interpret this type of error and fail in a specific way, but rather that it's encountered an invalid config file that results in undefined behavior.

1 Like

For future debugging: uci show network would like have announced the error for you.

Uci is rather strict with errors.
With most of the config files that is ok, and errors are rather harmless, but with the core services config files it can have effects, like you noticed.

There is the failsafe mode for recovering from this type of errors.

failsafe? I had to use UART to debug the device.

1 Like

Yup. Works on most devices and is much less intrusive than serial.

1 Like

Hint for you:
use an editor that highlights the uci syntax.

E.g. nano-full:

I just committed a change to further improve the coloring on unterminated strings (nano-full 8.7.1-r2):

4 Likes