using-ip-filtering.asciidoc 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. [role="xpack"]
  2. [[ip-filtering]]
  3. == Restricting connections with IP filtering
  4. You can apply IP filtering to application clients, node clients, or transport
  5. clients, remote cluster clients, in addition to other nodes that are attempting to join the cluster.
  6. If a node's IP address is on the denylist, the {es} {security-features} allow
  7. the connection to {es} but it is be dropped immediately and no requests are
  8. processed.
  9. NOTE: Elasticsearch installations are not designed to be publicly accessible
  10. over the Internet. IP Filtering and the other capabilities of the
  11. {es} {security-features} do not change this condition.
  12. [discrete]
  13. === Enabling IP filtering
  14. The {es} {security-features} contain an access control feature that allows or
  15. rejects hosts, domains, or subnets. If the
  16. <<operator-privileges,{operator-feature}>> is enabled, only operator users can
  17. update these settings.
  18. You configure IP filtering by specifying the `xpack.security.transport.filter.allow` and
  19. `xpack.security.transport.filter.deny` settings in `elasticsearch.yml`. Allow rules
  20. take precedence over the deny rules.
  21. IMPORTANT: Unless explicitly specified, `xpack.security.http.filter.*` and
  22. `xpack.security.remote_cluster.filter.*` settings default to
  23. the corresponding `xpack.security.transport.filter.*` setting's value.
  24. [source,yaml]
  25. --------------------------------------------------
  26. xpack.security.transport.filter.allow: "192.168.0.1"
  27. xpack.security.transport.filter.deny: "192.168.0.0/24"
  28. --------------------------------------------------
  29. The `_all` keyword can be used to deny all connections that are not explicitly
  30. allowed.
  31. [source,yaml]
  32. --------------------------------------------------
  33. xpack.security.transport.filter.allow: [ "192.168.0.1", "192.168.0.2", "192.168.0.3", "192.168.0.4" ]
  34. xpack.security.transport.filter.deny: _all
  35. --------------------------------------------------
  36. IP filtering configuration also support IPv6 addresses.
  37. [source,yaml]
  38. --------------------------------------------------
  39. xpack.security.transport.filter.allow: "2001:0db8:1234::/48"
  40. xpack.security.transport.filter.deny: "1234:0db8:85a3:0000:0000:8a2e:0370:7334"
  41. --------------------------------------------------
  42. You can also filter by hostnames when DNS lookups are available.
  43. [source,yaml]
  44. --------------------------------------------------
  45. xpack.security.transport.filter.allow: localhost
  46. xpack.security.transport.filter.deny: '*.google.com'
  47. --------------------------------------------------
  48. [discrete]
  49. === Disabling IP Filtering
  50. Disabling IP filtering can slightly improve performance under some conditions.
  51. To disable IP filtering entirely, set the value of the `xpack.security.transport.filter.enabled`
  52. setting in the `elasticsearch.yml` configuration file to `false`.
  53. [source,yaml]
  54. --------------------------------------------------
  55. xpack.security.transport.filter.enabled: false
  56. --------------------------------------------------
  57. You can also disable IP filtering for the transport protocol but enable it for
  58. HTTP only.
  59. [source,yaml]
  60. --------------------------------------------------
  61. xpack.security.transport.filter.enabled: false
  62. xpack.security.http.filter.enabled: true
  63. --------------------------------------------------
  64. [discrete]
  65. === Specifying TCP transport profiles
  66. <<transport-profiles,TCP transport profiles>>
  67. enable Elasticsearch to bind on multiple hosts. The {es} {security-features} enable you to apply
  68. different IP filtering on different profiles.
  69. [source,yaml]
  70. --------------------------------------------------
  71. xpack.security.transport.filter.allow: 172.16.0.0/24
  72. xpack.security.transport.filter.deny: _all
  73. transport.profiles.client.xpack.security.filter.allow: 192.168.0.0/24
  74. transport.profiles.client.xpack.security.filter.deny: _all
  75. --------------------------------------------------
  76. NOTE: When you do not specify a profile, `default` is used automatically.
  77. [discrete]
  78. === HTTP filtering
  79. You may want to have different IP filtering for the transport and HTTP protocols.
  80. [source,yaml]
  81. --------------------------------------------------
  82. xpack.security.transport.filter.allow: localhost
  83. xpack.security.transport.filter.deny: '*.google.com'
  84. xpack.security.http.filter.allow: 172.16.0.0/16
  85. xpack.security.http.filter.deny: _all
  86. --------------------------------------------------
  87. [discrete]
  88. === Remote cluster (API key based model) filtering
  89. If other clusters connect <<remote-clusters-api-key,using API key
  90. authentication>> for {ccs} or {ccr}, you may want to have different IP filtering
  91. for the remote cluster server interface.
  92. [source,yaml]
  93. --------------------------------------------------
  94. xpack.security.remote_cluster.filter.allow: 192.168.1.0/8
  95. xpack.security.remote_cluster.filter.deny: 192.168.0.0/16
  96. xpack.security.transport.filter.allow: localhost
  97. xpack.security.transport.filter.deny: '*.google.com'
  98. xpack.security.http.filter.allow: 172.16.0.0/16
  99. xpack.security.http.filter.deny: _all
  100. --------------------------------------------------
  101. NOTE: Whether IP filtering for remote cluster is enabled is controlled by
  102. `xpack.security.transport.filter.enabled` as well. This means filtering for
  103. the remote cluster and transport interfaces must be enabled or disabled together.
  104. But the exact allow and deny lists can be different between them.
  105. [discrete]
  106. [[dynamic-ip-filtering]]
  107. === Dynamically updating IP filter settings
  108. In case of running in an environment with highly dynamic IP addresses like cloud
  109. based hosting, it is very hard to know the IP addresses upfront when provisioning
  110. a machine. Instead of changing the configuration file and restarting the node,
  111. you can use the _Cluster Update Settings API_. For example:
  112. [source,console]
  113. --------------------------------------------------
  114. PUT /_cluster/settings
  115. {
  116. "persistent" : {
  117. "xpack.security.transport.filter.allow" : "172.16.0.0/24"
  118. }
  119. }
  120. --------------------------------------------------
  121. You can also dynamically disable filtering completely:
  122. [source,console]
  123. --------------------------------------------------
  124. PUT /_cluster/settings
  125. {
  126. "persistent" : {
  127. "xpack.security.transport.filter.enabled" : false
  128. }
  129. }
  130. --------------------------------------------------
  131. // TEST[continued]
  132. NOTE: In order to avoid locking yourself out of the cluster, the default bound
  133. transport address will never be denied. This means you can always SSH into
  134. a system and use curl to apply changes.