modifing alias #786
Unanswered
HenningSvane
asked this question in
Q&A
Replies: 2 comments
-
|
Below is an example of updating an alias. I'd recommend familiarizing yourself with the pfSense object IDs and their dynamic behavior first.
{
"code": 200,
"status": "ok",
"response_id": "SUCCESS",
"message": "",
"data": [
{
"id": 1,
"name": "test_alias",
"type": "host",
"descr": "Example alias",
"address": [
"127.0.0.1"
],
"detail": []
}
]
}
{
"code": 200,
"status": "ok",
"response_id": "SUCCESS",
"message": "",
"data": {
"id": 1,
"name": "test_alias",
"type": "host",
"descr": "Updated alias description",
"address": [
"127.0.0.2"
],
"detail": []
}
}
{
"code": 200,
"status": "ok",
"response_id": "SUCCESS",
"message": "",
"data": {
"applied": false,
"pending_subsystems": [
"aliases"
]
}
}
{
"code": 200,
"status": "ok",
"response_id": "SUCCESS",
"message": "",
"data": {
"applied": true,
"pending_subsystems": []
}
}Hope this helps! |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Hi Jared
Thanks for this example.
Regards
Henning
Fra: Jared Hendrickson ***@***.***>
Sendt: 24. november 2025 17:51
Til: jaredhendrickson13/pfsense-api ***@***.***>
Cc: Henning Svane ***@***.***>; Author ***@***.***>
Emne: Re: [jaredhendrickson13/pfsense-api] modifing alias (Discussion #786)
Below is an example of updating an alias. I'd recommend familiarizing yourself with the pfSense object IDs<https://pfrest.org/WORKING_WITH_OBJECT_IDS/> and their dynamic behavior first.
1. Query<https://pfrest.org/QUERIES_FILTERS_AND_SORTING/> for the ID of the alias you're updating:
curl -k -u admin:pfsense -X GET 'https://localhost/api/v2/firewall/aliases?name=test_alias'
{
"code": 200,
"status": "ok",
"response_id": "SUCCESS",
"message": "",
"data": [
{
"id": 1,
"name": "test_alias",
"type": "host",
"descr": "Example alias",
"address": [
"127.0.0.1"
],
"detail": []
}
]
}
1. Update the alias configuration using a PATCH request containing the id obtained in step 1.
curl -k -u admin:pfsense -X PATCH https://localhost/api/v2/firewall/alias -H 'content-type: application/json' -d '{"id": 1, "descr": "Updated alias description", "address": ["127.0.0.2"]}'
{
"code": 200,
"status": "ok",
"response_id": "SUCCESS",
"message": "",
"data": {
"id": 1,
"name": "test_alias",
"type": "host",
"descr": "Updated alias description",
"address": [
"127.0.0.2"
],
"detail": []
}
}
1. Make a call to POST /api/v2/firewall/apply endpoint to apply the changes. Alternatively, if you are only updating a single alias you could add the apply control parameter<https://pfrest.org/COMMON_CONTROL_PARAMETERS/#apply> to the request body in the PATCH request in step 2 and skip this step.
curl -k -u admin:pfsense -X POST https://localhost/api/v2/firewall/apply
{
"code": 200,
"status": "ok",
"response_id": "SUCCESS",
"message": "",
"data": {
"applied": false,
"pending_subsystems": [
"aliases"
]
}
}
1. (optional) If you want to check the status of the apply action, you can make a call to GET /api/v2/firewall/apply:
curl -k -u admin:pfsense -X GET https://localhost/api/v2/firewall/apply
{
"code": 200,
"status": "ok",
"response_id": "SUCCESS",
"message": "",
"data": {
"applied": true,
"pending_subsystems": []
}
}
Hope this helps!
—
Reply to this email directly, view it on GitHub<#786 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AL44SRXPMCCLPKYN3BM2Q2D36MZPXAVCNFSM6AAAAACM6ZPOFCVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTKMBWGQ4DCMI>.
You are receiving this because you authored the thread.Message ID: ***@***.******@***.***>>
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am trying to update a alias
But I cannot get it to work
curl -k -H "X-API-Key: Key" https://ip-addr/api/v2/firewall/alias/WindowsUpdate
I have also tried firewall/aliases and with smal and big start letters
My idear was to first delete the alias, then create it again with new ip's, and then apply
But I can not get it to work
What is the right way to do it?
Regards
Henning
Beta Was this translation helpful? Give feedback.
All reactions