Skip to content

Instantly share code, notes, and snippets.

@greencm
Created July 5, 2013 15:25
Show Gist options
  • Save greencm/5935276 to your computer and use it in GitHub Desktop.
Save greencm/5935276 to your computer and use it in GitHub Desktop.
Take a list of IPs and turn into a BPF filter
#!/usr/bin/python
# convert a list of IPs to an OR bpf filter
import sys
if len(sys.argv) == 2 and sys.argv[1] != '-':
f = open(sys.argv[1])
else:
f = sys.stdin
ips = [s.strip() for s in f.readlines()]
bpf = "( host " + " or host ".join(ips) + ")"
print bpf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment