4 ms·
To choose an ip address from 127.0.0.0/8 subnet randomly in Python 3: >>> import ipaddress >>> import random >>> ipaddress.IPv4Address('127.0.0.1') + ran
by d0mine 10y ago
To choose an ip address from 127.0.0.0/8 subnet randomly in Python 3:
>>> import ipaddress
>>> import random
>>> ipaddress.IPv4Address('127.0.0.1') + random.randrange(2**24 - 2)
IPv4Address('127.23.181.175')
- wcarron27 10y agoHey, I know I'm a bit late to the party. But I'm looking to protect my company's redis instance from these attacks and your approach looks very promising. Things is, I don't know what to do now that I've written a similar script. Where should I use this code? In the redis.conf file? Bear in mind, I'm a front end developer, so this is absolutely not my forte. Thanks for the help.
- deleted 10y ago[deleted]
- fizzbatter 10y agoI really appreciate this code example. I've been using 127.0.0.1 for all my local dev stuff, relying on ports. This is pretty awesome!
- _RPM 10y agoNice use of __add__ operator over loading here