OPNsense
  • Home
  • Help
  • Search
  • Login
  • Register

  • OPNsense Forum »
  • Archive »
  • 18.7 Legacy Series »
  • How to import Aliases?
« previous next »
  • Print
Pages: [1] 2

Author Topic: How to import Aliases?  (Read 9851 times)

chemlud

  • Hero Member
  • *****
  • Posts: 2045
  • Karma: 93
    • View Profile
How to import Aliases?
« on: November 15, 2018, 12:34:56 pm »
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?
« Last Edit: November 15, 2018, 01:31:04 pm by chemlud »
Logged
kind regards
chemlud
____
"The price of reliability is the pursuit of the utmost simplicity."
C.A.R. Hoare

mrkev

  • Newbie
  • *
  • Posts: 20
  • Karma: 1
    • View Profile
Re: How to import Aliases?
« Reply #1 on: November 15, 2018, 02:22:30 pm »
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
Logged

chemlud

  • Hero Member
  • *****
  • Posts: 2045
  • Karma: 93
    • View Profile
Re: How to import Aliases?
« Reply #2 on: November 15, 2018, 03:15:00 pm »
You can't even edit an existing Alias, when try to save you get: An alias with this name already exists... :-\
Logged
kind regards
chemlud
____
"The price of reliability is the pursuit of the utmost simplicity."
C.A.R. Hoare

chemlud

  • Hero Member
  • *****
  • Posts: 2045
  • Karma: 93
    • View Profile
Re: How to import Aliases?
« Reply #3 on: November 15, 2018, 04:41:25 pm »
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
« Last Edit: November 15, 2018, 05:04:05 pm by chemlud »
Logged
kind regards
chemlud
____
"The price of reliability is the pursuit of the utmost simplicity."
C.A.R. Hoare

mimugmail

  • Hero Member
  • *****
  • Posts: 6295
  • Karma: 432
    • View Profile
Re: How to import Aliases?
« Reply #4 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
Logged
Twitter: mimu_muc
WWW: www.routerperformance.net
Support plans: https://www.max-it.de/en/it-services/opnsense/
Commercial Plugins (German): https://opnsense.max-it.de/

mrkev

  • Newbie
  • *
  • Posts: 20
  • Karma: 1
    • View Profile
Re: How to import Aliases?
« Reply #5 on: November 15, 2018, 05:29:55 pm »
Where is the documentation that shows you how to add aliases via the API? I'm struggling to find it.
Logged

mimugmail

  • Hero Member
  • *****
  • Posts: 6295
  • Karma: 432
    • View Profile
Re: How to import Aliases?
« Reply #6 on: November 15, 2018, 05:33:22 pm »
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
Logged
Twitter: mimu_muc
WWW: www.routerperformance.net
Support plans: https://www.max-it.de/en/it-services/opnsense/
Commercial Plugins (German): https://opnsense.max-it.de/

chemlud

  • Hero Member
  • *****
  • Posts: 2045
  • Karma: 93
    • View Profile
Re: How to import Aliases?
« Reply #7 on: November 15, 2018, 06:45:27 pm »
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
Logged
kind regards
chemlud
____
"The price of reliability is the pursuit of the utmost simplicity."
C.A.R. Hoare

jschellevis

  • Administrator
  • Full Member
  • *****
  • Posts: 155
  • Karma: 37
    • View Profile
Re: How to import Aliases?
« Reply #8 on: November 16, 2018, 01:31:32 am »
Aliases can also get copy/pasted from a comma separated list.
Logged

mrkev

  • Newbie
  • *
  • Posts: 20
  • Karma: 1
    • View Profile
Re: How to import Aliases?
« Reply #9 on: November 16, 2018, 07:33:07 am »
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.
Logged

mimugmail

  • Hero Member
  • *****
  • Posts: 6295
  • Karma: 432
    • View Profile
Re: How to import Aliases?
« Reply #10 on: November 16, 2018, 08:08:00 am »
Screenshot enclosed ... perhaps it's too easy to find :)
Logged
Twitter: mimu_muc
WWW: www.routerperformance.net
Support plans: https://www.max-it.de/en/it-services/opnsense/
Commercial Plugins (German): https://opnsense.max-it.de/

franco

  • Administrator
  • Hero Member
  • *****
  • Posts: 13671
  • Karma: 1175
    • View Profile
Re: How to import Aliases?
« Reply #11 on: November 16, 2018, 08:32:44 am »
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. :)
Logged

chemlud

  • Hero Member
  • *****
  • Posts: 2045
  • Karma: 93
    • View Profile
Re: How to import Aliases?
« Reply #12 on: November 16, 2018, 12:23:02 pm »
...I had no commas, so no copy+paste ;-)
Logged
kind regards
chemlud
____
"The price of reliability is the pursuit of the utmost simplicity."
C.A.R. Hoare

mrkev

  • Newbie
  • *
  • Posts: 20
  • Karma: 1
    • View Profile
Re: How to import Aliases?
« Reply #13 on: November 16, 2018, 01:18:40 pm »
I'm going to try adding some aliases via the API this weekend - if I can figure out the PHP code that is   ???
Logged

snowfall

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
    • View Profile
Re: How to import Aliases?
« Reply #14 on: November 17, 2018, 09:02:57 pm »
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.
« Last Edit: November 17, 2018, 09:04:46 pm by snowfall »
Logged

  • Print
Pages: [1] 2
« previous next »
  • OPNsense Forum »
  • Archive »
  • 18.7 Legacy Series »
  • How to import Aliases?
 

OPNsense is an OSS project © Deciso B.V. 2015 - 2023 All rights reserved
  • SMF 2.0.19 | SMF © 2021, Simple Machines
    Privacy Policy
    | XHTML | RSS | WAP2