Hacker News new | past | comments | ask | show | jobs | submit login

It's part of configuring whatever services you're running (or an option in your tcp/ip library if you're programming your own), and will depend on the service. For memcached for example, you can change the listen address with `-l <addr>`. Usually you just have to find the configuration documentation and ctrl-f search for "address," "bind address," "listen address," "IP address," etc. Or scan the page for something networking related.

It's pretty much always a command line flag or config file parameter.

If you're running with docker, it's even more standard. When you expose a port, just use `-p 127.12.12.3:11211:11211` (with your chosen IP address, of course), and docker will set up the forwarding for you, only for that address.




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')


Hey, 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.


Nice use of __add__ operator over loading here


I 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!


Is there a way to make root a requirement for binding to 0.0.0.0 though?


Selinux (semanage port) and iptables (SECMARK?) might help you there.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: