关于elasticsearch:利用iptables实现简单的ES-http端口访问限制

6次阅读

共计 750 个字符,预计需要花费 2 分钟才能阅读完成。

一、梳理容许拜访的 IP 地址
1、ES 客户端 IP 地址

192.168.32.120
192.168.32.121

2、集群中节点的 IP 地址

192.168.32.122
192.168.32.123
192.168.32.124

二、登录 ES 主机 (ubantu 为例),执行以下命令

# 创立 iptables 策略保留门路
mkdir -p /etc/iptables/iptables.rule

# 禁止所有 IP 拜访本机 9200 端口
iptables -I INPUT -p tcp –dport 9200 -j REJECT
# 容许集群内主机 IP 拜访本机 9200 端口

iptables -I INPUT -s 192.168.32.123 -p tcp –dport 9200 -j ACCEPT
iptables -I INPUT -s 192.168.32.124 -p tcp –dport 9200 -j ACCEPT
# 容许 ES 客户端 IP 地址拜访本机 9200 端口
iptables -I INPUT -s 192.168.32.120 -p tcp –dport 9200 -j ACCEPT
iptables -I INPUT -s 192.168.32.121 -p tcp –dport 9200 -j ACCEPT

# 查看已增加的 iptables 规定
iptables -L -n --line-numbers
# 删除已增加的某条 iptables 规定
iptables -D INPUT 1

#保留已增加的 iptables 规定到本地文件门路
iptables-save > /etc/iptables/iptables.rule
#从已保留的文件中复原 iptables 规定
iptables-restore < /etc/iptables/iptables.rules
#配置开机后主动执行加载 iptables 策略文件
/etc/rc.d/rc.local
正文完
 0