Hello again!
I'm a little lost on this, have a large list of Aliases and wanted to import to an opnsense (from the dark side of the sense-universe, I must confess).
I see no option to import aliases in the respective drop-down, thought they might be imported with the firewall rules (seems to make sense), but is apparently not the case.
An easy way to get the aliases to be imported?
PS: Found this here:
https://forum.opnsense.org/index.php?topic=10199.0
Maybe someone?
I would like to know that as well as I may need to re-import my aliases that have disappeared from the Firewall-Aliases view. I'm sure there was an import facility before and you could just past in a list.
The documentation mentions an import feature but I can no longer find it:
https://wiki.opnsense.org/manual/aliases.html#import-feature (https://wiki.opnsense.org/manual/aliases.html#import-feature)
You can't even edit an existing Alias, when try to save you get: An alias with this name already exists... :-\
One option would be to edit the aliases directly in the exported config.xml, but I guess vi in BSD is the only editing tool not breaking the file? Or is there sumfink to edit config.xml in Linux?
OK, to answer my own question:
I created all the Aliases I need in the GUI, but added only the first 3 hosts or whatever.
Then I exported the config and opened the .xml in nano and added the other entry for the various keeping exactly the syntax as for the first three entries. Imported the complete config back into sense and had a look: Seemed to work!
After reboot everything looks fine! :-D
Now that Aliases are API enabled you could also add them via API :)
https://docs.opnsense.org/development/how-tos/api.html
Where is the documentation that shows you how to add aliases via the API? I'm struggling to find it.
Seems it's not yet documented. The actions are here:
https://github.com/opnsense/core/blob/master/src/opnsense/mvc/app/controllers/OPNsense/Firewall/Api/AliasController.php
You can grab a different example and try to use the actions in the Api Controller above
Quote from: mimugmail on November 15, 2018, 05:22:02 PM
Now that Aliases are API enabled you could also add them via API :)
https://docs.opnsense.org/development/how-tos/api.html
No idea how to do that! :-D
Aliases can also get copy/pasted from a comma separated list.
Quote from: jschellevis on November 16, 2018, 01:31:32 AM
Aliases can also get copy/pasted from a comma separated list.
Into where? That option has seemed to have disappeared.
Screenshot enclosed ... perhaps it's too easy to find :)
It's non-obvious drag+drop of text into the content field. It also works as "foobar,testing,hello" by doing CTRL+C and CTRL+V into that same field. :)
...I had no commas, so no copy+paste ;-)
I'm going to try adding some aliases via the API this weekend - if I can figure out the PHP code that is ???
Quote from: jschellevis on November 16, 2018, 01:31:32 AM
Aliases can also get copy/pasted from a comma separated list.
I tried this for networks in CIDR notation but couldn't get this to work. It is never separation them but trying to parse the whole sequence as a single IP address. Hence I get the error "is not a valid hostname or IP address.".
Any tips on how to work around this?
I tried carriage return separated and comma separated and nothing works anymore.
One or two versions ago there was the alias import feature which worked perfectly for me.
I just tried it and it works for me. This is a test of what I pasted in
1.1.1.1/32,2.2.2.2/32,3.3.3.3/32
Quote from: mrkev on November 17, 2018, 09:58:42 PM
I just tried it and it works for me. This is a test of what I pasted in
1.1.1.1/32,2.2.2.2/32,3.3.3.3/32
Thanks for the quick reply.
Unfortunately also this doesn't seem to work.
Did you try saving it? I get the error message when trying to save it.
In this case I get again
Entry "1.1.1.1/32,2.2.2.2/32,3.3.3.3/32" is not a valid hostname or IP address.
I just tried it again and saved. Seems to work fine.
Quote from: mrkev on November 17, 2018, 10:26:04 PM
I just tried it again and saved. Seems to work fine.
Ok, thanks. Seems to be a weired bug. I tried again with the same result. See the screenshot attached
Weird. Might be worth trying another browser. You should see a gap between each entry when you press a comma ','
Quote from: mrkev on November 17, 2018, 10:47:55 PM
Weird. Might be worth trying another browser. You should see a gap between each entry when you press a comma ','
Thanks for your help. Now it works. Was something in my browser configuration. Maybe the hardened DOM-storage settings or something like that.
Pressing the comma manually also worked in the other browser config but copy pasting did not.
I had the same problem - is the disabled "dom.event.clipboardevents.enabled" Event in Firefox.
about:config
dom.event.clipboard events.enabled -> true
and it's working again.
You can format the list with the CIDR with notepad++ for example.