当前位置:网站首页>对iptables进行常规操作
对iptables进行常规操作
2022-07-06 09:26:00 【一一空】
一、梳理允许访问的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
# 允许集群内主机IP访问本机9200端口
iptables -A INPUT -s 192.168.32.123 -p tcp --dport 9200 -j ACCEPT
iptables -A INPUT -s 192.168.32.124 -p tcp --dport 9200 -j ACCEPT
# 允许ES客户端IP地址访问本机9200端口
iptables -A INPUT -s 192.168.32.120 -p tcp --dport 9200 -j ACCEPT
iptables -A INPUT -s 192.168.32.121 -p tcp --dport 9200 -j ACCEPT
# 禁止除上面策略外的所有IP访问本机9200端口(最后一条)
iptables -A INPUT -p tcp --dport 9200 -j REJECT
# 如果要在以上策略基本上新增iptables策略,使用-I参数
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.rules
#从已保存的文件中恢复iptables规则
iptables-restore < /etc/iptables/iptables.rules
#配置开机后自动执行加载iptables策略文件编辑iptables后
输入完iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080 后
执行iptables-save
注意:iptables-save是连在一起的,是一个命令,不是参数
iptables-save 仅仅是列出当前设置,并不是将配置保存
若你用的是 RedHat 系列,应该使用 service iptables save 保存,用 chkconfig iptables on 实现开机启动启用
若不是 RedHat 系列,可以使用下面方法手动保存/恢复配置
保存
iptables-save > /root/iptables.conf
恢复
iptables-restore < /root/iptables.conf边栏推荐
- Ball Dropping
- 区间和------离散化
- 0-1背包问题(一)
- Es6--- two methods of capturing promise status as failed
- FSM and I2C experiment report
- Learning records: serial communication and solutions to errors encountered
- Cost accounting [16]
- Learning record: STM32F103 clock system overview working principle
- LeetCode#62. Different paths
- Learning record: use stm32f1 watchdog
猜你喜欢

ucorelab4

STM32学习记录:输入捕获应用

MATLAB实例:阶跃函数的两种表达方式

学习记录:理解 SysTick系统定时器,编写延时函数

7-1 懂的都懂 (20 分)

STM32 how to use stlink download program: light LED running light (Library version)

Es6---es6 content details

学习记录:STM32F103 时钟系统概述工作原理

Crawling cat's eye movie review, data visualization analysis source code operation instructions

毕业才知道IT专业大学生毕业前必做的1010件事
随机推荐
LeetCode#237. Delete nodes in the linked list
Research Report of peripheral venous catheter (pivc) industry - market status analysis and development prospect prediction
C语言学习笔记
Learning record: STM32F103 clock system overview working principle
编程到底难在哪里?
ucore lab 2
LeetCode#53. Maximum subarray sum
Learning record: Tim - capacitive key detection
ucorelab3
LeetCode#198. raid homes and plunder houses
Market trend report, technical innovation and market forecast of lip care products in China and Indonesia
STM32如何使用STLINK下载程序:点亮LED跑马灯(库版本)
STM32 learning record: input capture application
JS --- JS function and scope (II)
动态规划前路径问题
Research Report on medical anesthesia machine industry - market status analysis and development prospect prediction
学习记录:STM32F103 时钟系统概述工作原理
学习记录:使用STM32F1看门狗
Flink 使用之 CEP
数据在内存中的存储&载入内存,让程序运行起来