Programatically add TLD's via pmgsh

Someyoung Guy

Active Member
Dec 23, 2018
16
1
43
47
I am trying to figure out how I can programatically add TLD's to the:

Code:
mail filter > what objects > TLD blocking > value

I saw you can use pmgsh in commands like "pmgsh create /config/ruledb/who/2/domain -domain blacklistdomain.example" to block domains but I wanted to block TLD's first.

There doesn't seem to be a way to do this. Does this function exist yet in the api? I tried to use the api viewer and drill down to: config > ruledb > what > {ogroup} > objects...but I guess I just don't understand what I'm looking for. Nothing is obvious.

Anyone have guidance on adding TLD's via the command line? I looked in the manual and online but haven't turned anything up yet.

Thanks!
 
most blocking of tld's works by adding a fitting regular expression to the path:
Code:
pmgsh create /config/ruledb/who/2/regex --regex '.*\.xyz'

also checkout the forum (search for `pmgsh`) there are quite a few threads describing similar questions

additionally the api-viewer might help in navigating the PMG api:
https://pmg.proxmox.com/pmg-docs/api-viewer/index.html

I hope this helps!
 
most blocking of tld's works by adding a fitting regular expression to the path:
Code:
pmgsh create /config/ruledb/who/2/regex --regex '.*\.xyz'

also checkout the forum (search for `pmgsh`) there are quite a few threads describing similar questions

additionally the api-viewer might help in navigating the PMG api:
https://pmg.proxmox.com/pmg-docs/api-viewer/index.html

I hope this helps!

Thanks for the assist but I can't see it in the "TLD Blocking" list I created...I did get output from the command though.

Code:
pmgsh create /config/ruledb/who/2/regex --regex '.*\.test1'
200 OK
118

So...it says "OK"...I'm just not sure where it went LOL.

Edit: I see, it went to the "who objects" > "blacklists". Hope it works!

Any insight would be helpful.
 
Last edited:
Edit: I see, it went to the "who objects" > "blacklists". Hope it works!
I guess this is because the blacklist object is the one with id '2' (from the url)

you can use pmgsh to look around the rules:
`pmgsh get /config/ruledb/who`
 
Oh boy...so, I added all the rules with capitals...AAA, TOP, etc. right...and, I don't think it's blocking ".top" for example in emails because it's not ".TOP".

Now I've got to delete all those entries but can't figure out the -delete syntax for the entries.

Manual deleting hundreds of these TLD's is no fun.

How do you delete them in an automated way?
 
Oh boy...so, I added all the rules with capitals...AAA, TOP, etc. right...and, I don't think it's blocking ".top" for example in emails because it's not ".TOP".
guess the problem is not the case (the matches are all done case-insensitively...
if you add a domain object it only matches the complete domain - i.e. 'top' would only match 'spammer@top' not 'spammer@sometopdomain.top'

if you want to match for TLDs (and all domains below that tld use a WHO Regex (which is also done case-insensitively)

as for the delete - yes it's a bit indirect:
Code:
pmgsh get /config/ruledb/who #from that one you get the id of the who-object
pmgsh get /config/ruledb/who/<ID>/objects #from this you get the ids of the individual entries
pmgsh delete /config/ruledb/who/<ID>/objects/<entryID> #this deletes the entry

check out the API-viewer where the REST-API is laid-out in a browsable way:
https://pmg.proxmox.com/pmg-docs/api-viewer/index.html

I hope this helps!
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!