0

I have existing ipset mylist, which I created with this command:

ipset create mylist hash:net 

Now, I would like to be able, from my python script, to add IPs to this list. This is the command I would use to do it manually from the commandline:

ipset add mylist 45.254.246.0/24

how can I do the same from python script?

I found the netaddr module has IPSet support, but this seems to be just internal structure, not a module to interact with my iptables.

1 Answer 1

0

Assuming the path to ipset is /usr/sbin/ipset:

import os
os.system('/usr/sbin/ipset add mylist 45.254.246.0/24')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.