Create a Post
cancel
Showing results for 
Search instead for 
Did you mean: 
Tim_Koopman
Contributor

How do you remove an IP Address from host using API

Hey,

Has anyone found a way where when you have an object with both an IPv4 & IPv6 address and you want to remove/clear one of those, how to do this in the Web API?

I have tried multiple different JSON values like null, "" and specifying the IP you want to keep in ip-address field, and a heap of others but it either processes the request but the result is the IP you are trying to clear is still there, or it complains the the address given is not valid.

Any ideas?

Regards

Tim

0 Kudos
6 Replies
Robert_Decker
Advisor

Robert.

0 Kudos
JozkoMrkvicka
Mentor
Mentor

Hi Robert,

Did you try it ?

It will not delete IPv4 (or IPv6), it will just override it with desired value. I didnt find a way how to delete it using "set host".

But using "dbedit" it is working like a charm:

dbedit
modify network_objects HOST_NAME ipaddr
update HOST_NAME‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
quit‍‍‍‍

or in case you need to delete IPv6:

dbedit
modify network_objects HOST_NAME ipaddr6
update HOST_NAME‍‍‍‍
quit‍‍‍‍‍‍‍‍

Please be aware, that after ipaddr or ipaddr6 there is one space character.

Kind regards,
Jozko Mrkvicka
0 Kudos
Tim_Koopman
Contributor

Hi,

Robert that is what I am using but do matter what you post in those fields it will never clear them. As Jozko said all you can do is change it to a different IP not remove one completely.

Thanks Jozko, thought this may be the case. Was just something that came up while testing new .NET library I am writing and just wanted to make sure there wasn't a way to do it using API. I will just mark it for now and come back to it when the API is updated to allow this.

Thanks

Tim

0 Kudos
Robert_Decker
Advisor

Hi Tim,

I'm back at work this morning and verified this on my machine.

I've to admit that I was surprised to find out that Juzko was correct. The "set-host" command doesn't clear field values.

This is a bug in API and will be fixed for the next version.

Sorry for inconvenience.

Robert.

Tim_Koopman
Contributor

Hi Robert,

Thanks for update. Just so you know, my testing showed, it seems the same thing happens in NAT settings if you would like to fix it there as well.

Regards

Tim

0 Kudos
Robert_Decker
Advisor

No problem Tim.

I've set a development task to go over all API commands and verify the correct behaviour.

Robert.

0 Kudos

Leaderboard

Epsum factorial non deposit quid pro quo hic escorol.

Upcoming Events

    CheckMates Events