首页 > 代码库 > iptables防火墙之主机型
iptables防火墙之主机型
1 | [root@localhost ~] # iptables -A INPUT -p tcp -m iprange --src-range 192.168.0.100-192.168.0.105 --dport 22 -j ACCEPT |
1 | iptables -A INPUT -d 192.168.0.108 -p tcp --dport 80 -m connlimit --connlimit-above 2 -j ACCEPT |
1 | [root@localhost ~] # iptables -I INPUT -d 192.168.0.108 -m string --algo kmp --string "***" -j REJECT |
1 | [root@localhost ~] # iptables -I OUTPUT -s 192.168.0.108 -m string --algo kmp --string "h7n9" -j REJECT |
1 2 3 4 5 6 7 8 9 | [root@localhost ~] # iptables -A INPUT -s 192.168.0.0/24 -d 192.168.0.108 -p tcp --dport 22 -j ACCEPT [root@localhost ~] # iptables -A OUTPUT -s 192.168.0.108 -d 192.168.0.0/24 -p tcp --dport 22 -j ACCEPT [root@localhost ~] # iptables -A INPUT -s 192.168.0.0/24 -d 192.168.0.108 -p tcp --dport 22 -j ACCEPT [root@localhost ~] # iptables -A OUTPUT -s 192.168.0.108 -d 192.168.0.0/24 -p tcp --sport 22 -j ACCEPT [root@localhost ~] # iptables -P INPUT DROP [root@localhost ~] # iptables -P OUTPUT DROP [root@localhost ~] # iptables -P FORWARD DROP [root@localhost ~] # iptables -I INPUT -d 192.168.0.108 -p tcp --dport 80 -j ACCEPT [root@localhost ~] # iptables -I OUTPUT -s 192.168.0.108 -p tcp --sport 80 -j ACCEPT |
1 2 3 4 5 6 7 8 9 10 11 | [root@localhost ~] # iptables -L -n -vv Chain INPUT (policy DROP 12 packets, 1062 bytes) pkts bytes target prot opt in out source destination 67 7776 ACCEPT tcp -- * * 0.0.0.0 /0 192.168.0.108 tcp dpt:80 857 56588 ACCEPT tcp -- * * 192.168.0.0 /24 192.168.0.108 tcp dpt:22 Chain FORWARD (policy DROP 0 packets, 0 bytes) pkts bytes target prot opt in out source destination Chain OUTPUT (policy DROP 0 packets, 0 bytes) pkts bytes target prot opt in out source destination 76 29960 ACCEPT tcp -- * * 192.168.0.108 0.0.0.0 /0 tcp spt:80 412 40288 ACCEPT tcp -- * * 192.168.0.108 192.168.0.0 /24 tcp spt:22 |
1 2 | [root@localhost ~] # iptables -A INPUT -s 127.0.0.1 -d 127.0.0.1 -i lo -j ACCEPT [root@localhost ~] # iptables -A OUTPUT -s 127.0.0.1 -d 127.0.0.1 -o lo -j ACCEPT |
1 2 | [root@localhost ~] # iptables -A INPUT -s 192.168.0.108 -p icmp --icmp-type 8 -j ACCEPT [root@localhost ~] # iptables -A OUTPUT -d 192.168.0.108 -p icmp --icmp-type 0 -j ACCEPT |
1 2 | [root@localhost ~] # iptables -A INPUT -d 192.168.0.108 -p tcp --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT [root@localhost ~] # iptables -A OUTPUT -s 192.168.0.108 -p tcp --sport 22 -m state --state ESTABLISHE -j ACCEPT |
1 2 | [root@localhost ~] # iptables -A INPUT -d 192.168.0.108 -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT [root@localhost ~] # iptables -A OUTPUT -s 192.168.0.108 -p tcp --sport 80 -m state --state ESTABLISHED -j ACCEPT |
1 | [root@localhost ~] # iptables -I OUTPUT -s 192.168.0.108 -m state --state ESTABLISHED -j ACCEPT |
1 2 3 4 5 | [root@localhost ~] # vim /etc/sysconfig/iptables-config IPTABLES_MODULES= "ip_nat_ftp ip_conntrack_ftp" [root@localhost ~] # iptables -A INPUT -d 192.168.0.108 -p tcp --dport 21 -m state --state NEW,ESTABLISHED -j ACCEPT [root@localhost ~] # iptables -A INPUT -d 192.168.0.108 -p tcp -m state --state ESTABLISHED,RELATED -j ACCEPT [root@localhost ~] # iptables -A OUTPUT -s 192.168.0.108 -m state --state RELATED,ESTABLISHED -j ACCEPT |
1 | [root@localhost ~] # iptables -A INPUT -d 192.168.0.108 -p icmp --icmp-type 8 -m limit --limit 5/minute -j ACCEPT |
1 | [root@localhost ~] # iptables -R INPUT 3 -d 192.168.0.108 -p icmp --icmp-type 8 -m limit --limit 5/minute --limit-burst 4 -j ACCEPT |
1 | [root@localhost ~] # iptables -A INPUT -d 192.168.0.108 -p icmp --icmp-type 8 -j LOG --log-prefix "--iptables log for icmp--" |
1 2 | [root@localhost ~] # tail /var/log/messages Nov 10 12:36:55 localhost kernel: --iptables log for icmp--IN=eth0 OUT= MAC=00:0c:29:a2:0b:db:34:23:87:fc:ae:89:08:00 SRC=http://www.mamicode.com/192.168.0.101 DST=192.168.0.108 LEN=60 TOS=0x00 PREC=0x00 TTL=64 ID=30851 PROTO=ICMP TYPE=8 CODE=0 ID=256 SEQ=4199 |
1 2 3 | [root@localhost ~] # iptables -A INPUT -d 192.168.0.108 -p tcp -m state --state ESTABLISHED,RELATED -j ACCEPT [root@localhost ~] # iptables -A INPUT -d 192.168.0.108 -p tcp -m multiport --destination-ports 21,22,80 -m state --state NEW -j ACCEPT [root@localhost ~] # iptables -A OUTPUT -s 192.168.0.108 -m state --state RELATED,ESTABLISHED -j ACCEPT
|
欢迎大家访问我的个人网站 萌萌的IT人
iptables防火墙之主机型
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。