Linux防火墙--iptables--白名单配置
1.服务器22端口和1521端口开通给指定IP
[root@node2 sysconfig]# iptables -t filter -nL INPUT
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22
REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
[root@node2 sysconfig]# iptables -F
[root@node2 sysconfig]# iptables -t filter -nL INPUT
Chain INPUT (policy ACCEPT)
target prot opt source destination
[root@node2 sysconfig]# iptables -I INPUT -s 192.168.222.1 -p tcp -m tcp --dport 22 -j ACCEPT
[root@node2 sysconfig]# iptables -t filter -nL INPUT
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- 192.168.222.1 0.0.0.0/0 tcp dpt:22
[root@node2 sysconfig]# iptables -A INPUT -j REJECT
[root@node2 sysconfig]# iptables -I INPUT -s 192.168.222.1 -p tcp -m tcp --dport 1521 -j ACCEPT
[root@node2 sysconfig]# iptables -t filter -nL INPUT
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- 192.168.222.1 0.0.0.0/0 tcp dpt:1521
ACCEPT tcp -- 192.168.222.1 0.0.0.0/0 tcp dpt:22
REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable
[root@node2 sysconfig]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ]
[root@node2 sysconfig]# service iptables restart
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
iptables: Applying firewall rules: [ OK ]
[root@node2 sysconfig]# iptables -t filter -nL INPUT
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- 192.168.222.1 0.0.0.0/0 tcp dpt:1521
ACCEPT tcp -- 192.168.222.1 0.0.0.0/0 tcp dpt:22
REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable
[root@node2 sysconfig]# iptables -t filter -nL INPUT --line-numbers
Chain INPUT (policy ACCEPT)
num target prot opt source destination
1 ACCEPT tcp -- 192.168.222.1 0.0.0.0/0 tcp dpt:1521
2 ACCEPT tcp -- 192.168.222.1 0.0.0.0/0 tcp dpt:22
3 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable
[root@node2 sysconfig]# iptables -t filter -D INPUT 1
[root@node2 sysconfig]# iptables -t filter -nL INPUT --line-numbers
Chain INPUT (policy ACCEPT)
num target prot opt source destination
1 ACCEPT tcp -- 192.168.222.1 0.0.0.0/0 tcp dpt:22
2 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable
2.注意:每次最后需要添加
iptables -I INPUT -i lo -j ACCEPT
iptables -I INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
3.插入到那一行
先查看当前的行,iptables -nL --line-numbers
插入到指定的行
[root@node2 sysconfig]# iptables -I INPUT 行号 -s 192.168.222.1 -p tcp -m tcp --dport 1521 -j ACCEPT
4.针对某个端口设置白名单机制
[root@node2 ~]# iptables -F
[root@node2 ~]# iptables -I INPUT -p tcp --dport 1521 -j DROP
[root@node2 ~]#
[root@node2 ~]# telnet 192.168.222.11 1521
Trying 192.168.222.11...
^C
[root@node2 ~]# iptables -I INPUT -s 192.168.222.11 -p tcp --dport 1521 -j ACCEPT
[root@node2 ~]# telnet 192.168.222.11 1521
Trying 192.168.222.11...
Connected to 192.168.222.11.
Escape character is '^]'.
Linux防火墙--iptables--白名单配置的更多相关文章
- Linux防火墙iptables学习笔记(三)iptables命令详解和举例[转载]
Linux防火墙iptables学习笔记(三)iptables命令详解和举例 2008-10-16 23:45:46 转载 网上看到这个配置讲解得还比较易懂,就转过来了,大家一起看下,希望对您工作能 ...
- Linux防火墙iptables学习
http://blog.chinaunix.net/uid-9950859-id-98277.html 要在网上传输的数据会被分成许多小的数据包,我们一旦接通了网络,会有很多数据包进入,离开,或者经过 ...
- (转)nginx域名访问的白名单配置梳理
nginx域名访问的白名单配置梳理 原文:http://www.cnblogs.com/kevingrace/p/6086652.html 在日常运维工作中,会碰到这样的需求:设置网站访问只对某些ip ...
- 10.Linux防火墙iptables之SNAT与DNAT
Linux防火墙iptables之SNAT与DNAT 目录 Linux防火墙iptables之SNAT与DNAT SNAT策略及应用 SNAT策略概述 SNAT策略典型应用环境 SNAT策略原理 SN ...
- Linux防火墙(Iptables)的开启与关闭
Linux防火墙(iptables)的开启与关闭 Linux中的防火墙主要是对iptables的设置和管理. 1. Linux防火墙(Iptables)重启系统生效 开启: chkconfig ipt ...
- linux 防火墙iptables简明教程
前几天微魔部落再次遭受到个别别有用心的攻击者的攻击,顺便给自己充个电,复习了一下linux下常见的防火墙iptables的一些内容,但是无奈网上的很多教程都较为繁琐,本着简明化学习的目的,微魔为大家剔 ...
- Linux防火墙iptables简明教程
前几天微魔部落再次遭受到个别别有用心的攻击者的攻击,顺便给自己充个电,复习了一下linux下常见的防火墙iptables的一些内容,但是无奈网上的很多教程都较为繁琐,本着简明化学习的目的,微魔为大家剔 ...
- xinetd黑/白名单配置教程(以telnet为例)
对于诸如telnet等托管于xinetd的服务,当请求到来时由于是通过xinetd进行通知,所以可以直接在xinetd上配置白名单允许和拒绝哪些ip连接服务. 本文主要参考xinetd.conf的ma ...
- Linux将端口设置进防火墙的白名单
1.先检查linux服务器的端口是否被防火墙拦住 `telnet 172.168.1.101 8080后面跟端口号,如果连接上证明是防火墙白名单.如果没有配置 vi /etc/sysconfig/ip ...
- linux 防火墙 iptables实例讲解
端口为例): 显示现有规则: iptables –L -n 清空现有规则表: iptables -F 黑名单:先允许所有数据包通过,后逐条添加黑名单规则. iptables –A INPUT–p tc ...
随机推荐
- shiro框架在springboot项目中的应用
地址:https://blog.csdn.net/taojin12/article/details/88343990 地址2:https://blog.csdn.net/bicheng4769/art ...
- Python---基础---水仙花数和三色球
一.编写一个程序,求100~999之间的所有水仙花数 如果一个3位数等于其各位数字的立方和,则称这个数为水仙花数.例如:153 = 1^3 + 5^3 + 3^3,因此153就是一个水仙花数 for ...
- Jenkins配置git/github 插件的ssh key
参考来源:http://jingyan.baidu.com/article/a65957f4f0acc624e67f9bc1.html 方式一:本地需要生成公私钥文件,git/github中新建ssh ...
- 01-跨域-jsonp原理
jsonp能跨域,并不是因为它发送了ajax请求,而是利用动态创建的script标签. script标签没有收到浏览器同源策略的限制,是可以跨域访问的. 创建的script标签,把其src指向请求的服 ...
- postman与soapui操作
get和post请求的区别? get请求:直接在浏览器里直接调用就可以了,不用借助工具 向服务端获取数据的 数据是放在url里面 post请求:向服务端发送数据的 数据放在body里 ...
- WinForm、WPF、ASP.NET窗口生命周期
https://blog.csdn.net/s_521_h/article/details/73826928
- App中h5音频不能播放问题
前置:以下问题是针对vue项目的解决方案 问题一:IOS中音频不能自动播放 原因:ios禁止了音频自动播放 解决办法:在vue的生命周期mounted中获取音频Dom并调用音频播放方法play(),注 ...
- FastDFS整合nginx模块报错
之前在本地虚拟机用的都是5.1的版本和1.12的nginx,在服务器上尝试一下高版本的6.1 一直报错各种,例如: undeclared (first use in this function) 尝试 ...
- 576 C
C. MP3 爆ll == #include<bits/stdc++.h> using namespace std; typedef long long ll; #define P pai ...
- Eclipse中安装和使用FindBugs
FindBugs在Eclipse的离线安装: 1 到http://findbugs.sourceforge.net/downloads.html下载20131115123549_nlpir_ict ...