ip-restriction
Allows or denies connections by client IP address or CIDR range.
ip-restrictionPriority 3000What it does
ip-restriction lets a connection go on to the stream route's backend or refuses it by the client's address. With Allow these addresses every address outside Whitelist is refused, with Deny these addresses every address on Blacklist.
A refused connection is closed. Unlike the HTTP plugin of the same name, it has no status code and no message to set.
When to use it
- A database port that only the network of your application servers,
10.0.0.0/8for example, may open. - MQTT brokers that accept devices from your internal networks only,
10.0.0.0/8and192.168.0.0/16. - A network that misuses a port, for example
203.0.113.0/24, kept out with Deny these addresses while every other address connects. - An IPv6 network kept out by its prefix, for example
2001:db8::/32.
Not for refusing HTTP requests by address on a route — see ip-restriction (Allows or denies clients by IP address or CIDR range) or capping how many connections one address keeps open — see limit-conn (Limits concurrent connections per key).
Set it up
Accept connections from the internal networks only
Choose Allow these addresses and fill Whitelist as in the JSON below.
{
"whitelist": [
"10.0.0.0/8",
"192.168.0.0/16"
]
}
More scenarios
Refuse connections from one network while accepting every other
Choose Deny these addresses and fill Blacklist as in the JSON below.
{
"blacklist": [
"203.0.113.0/24"
]
}
Things to know
- Whitelist — A connection from an address outside the list is closed: with
10.0.0.0/8and192.168.0.0/16listed, a client of neither network is not let through. - Blacklist — A connection from an address on the list is closed.
- Whitelist — An entry is one address,
10.0.0.1for example, or a network written with its prefix length,10.0.0.0/8. An entry that is neither,10.0.0.0/33for example, is refused when you save. - The two lists do not go together: a plugin that carries both is refused when you save.
- The
response_codethe HTTP plugin carries does not exist here: aresponse_codeof404is refused when you save. - AdviceFor a client whose address is not fixed, a device on a mobile network for example, a list of networks is no lock.
Settings
The fields as the console shows them, section by section.
Choose one:
Allow these addresses
whitelistarray of stringsRequiredDeny these addresses
blacklistarray of stringsRequired