一、详述iptales工做流程以及规则过滤顺序?html
iptables过滤的规则顺序是由上至下,若出现相同的匹配规则则遵循由上至下的顺序linux
二、iptables有几个表以及每一个表有几个链?nginx
Iptables有四表五链web
三、iptables的几个表以及每一个表对应链的做用,对应企业应用场景?面试
filter:INPUT 做用:for packets destined to local sockets安全
FORWARD 做用:for packets being routed through the boxbash
OUTPUT 做用:for locally-generated packets服务器
nat:PREROUTING 做用:for altering packets as soon as they come in网络
OUTPUT 做用:for altering locally-gener- ated packets before routing并发
POSTROUTING 做用:for altering packets as they are about to go out
mangle :PRE-ROUTING (for altering incoming packets before rout-ing) and OUTPUT (for altering locally-generated pack-ets before routing). INPUT (forpackets coming into the box itself), FORWARD (foraltering packets being routed through the box), and POSTROUTING (for altering packets as they are about to go out).
四、画图讲解iptables包过滤通过不一样表和链简易流程图并阐述。
五、请写出查看iptables当前全部规则的命令。
iptables -L -n --line-numbers
六、禁止来自10.0.0.188 ip地址访问80端口的请求
iptables -A INPUT -p tcp --dport 80 -j DROP
七、如何使在命令行执行的iptables规则永久生效?
/etc/init.d/iptables save
iptables save >>/etc/sysconfig/iptables
八、实现把访问10.0.0.3:80的请求转到172.16.1.17:80
iptables -t nat -A PREROUTING -d 10.0.0.3 -p tcp --dport 80 -j DNAT --to-destination 172.16.1.6:80
九、实现172.16.1.0/24段全部主机经过124.32.54.26外网IP共享上网。
iptables -t nat -A POSTROUTING -s 172.16.1.0/24 -j SNAT --to-source 124.32.54.26
iptables -t nat -A POSTROUTING -s 172.16.1.0/24 -j MASQUERADE
十、描述tcp 3次握手及四次断开过程?
11.详细描述HTTP工做原理?
1 ) 地址解析
2)封装HTTP请求数据包
3)封装成TCP包,创建TCP链接(TCP的三次握手)
4)客户机发送请求命令
5)服务器响应
6)服务器关闭TCP链接
12.请描述iptables的常见生产应用场景。
端口映射
局域网共享上网
iptables -t nat -A POSTROUTING -s 10.0.0.0/24 -o eth0 -j SNAT --to-source 120.43.61.124
1三、请描述下面iptables命令的做用
iptables -N syn-flood
iptables -A INPUT -i eth0 -syn -j syn-flood
iptables -A syn-flood -m limit -limit 5000/s -limit-burst 200 -j RETURN
iptables -A syn-flood -j DROP
防止syn-flood攻击的
1四、企业WEB应用较大并发场景如何优化iptables?
net.nf_conntrack_max = 25000000
net.netfilter.nf_conntrack_max = 25000000
net.netfilter.nf_conntrack_tcp_timeout_established = 180
net.netfilter.nf_conntrack_tcp_timeout_time_wait = 120
net.netfilter.nf_conntrack_tcp_timeout_close_wait = 60
net.netfilter.nf_conntrack_tcp_timeout_fin_wait = 120
(二)企业运维经验面试题:
1五、写一个防火墙配置脚本,只容许远程主机访问本机的80端口(奇虎360面试题)
iptables -A INPUT -p tcp --dport 80 -j accept
iptables -A INPUT -p tcp -j DROP
1六、请描述如何配置一个linux上网网关?
route add -net 192.168.0.0/24 gw 10.0.0.253 dev eth1
1七、请描述如何配置一个专业的安全的WEB服务器主机防火墙?
先将默认的INPUT链和Forward链关闭,只开放容许进入的端口
1八、企业实战题6:请用至少两种方法实现!
写一个脚本解决DOS攻击生产案例
提示:根据web日志或者或者网络链接数,监控当某个IP并发链接数或者短时内PV达到100,即调用防火墙命令封掉对应的IP,监控频率每隔3分钟。防火墙命令为:iptables -I INPUT -s 10.0.1.10 -j DROP。
方法一:
netstat
-na|
grep
EST|
awk
-F
"[ :]+"
'{print $6}'
|
sort
|
uniq
-c >>
/tmp/a
.log
while
true
do
grep
EST a.log|
awk
-F
'[ :]+'
'{print $6}'
|
sort
|
uniq
-c >
/tmp/tmp
.log
exec
<
/tmp/tmp
.log
while
read
line
do
ip=`
echo
$line|
awk
"{print $2}"
`
count=`
echo
$line|
awk
"{print $1}"
`
if
[ $count -gt 100 ] && [ `iptables -L -n|
grep
$ip|
wc
-l` -lt 1 ]
then
iptables -I INPUT -s $ip -j DROP
//-I
将其封杀在iptables显示在第一条
echo
"$line is dropped"
>>
/tmp/dropip
.log
fi
done
sleep
180
done
方法二:
netstat
-na|
grep
EST|
awk
-F
"[ :]+"
'{print $6}'
|
awk
'{S[$1]++}END{for(i in S) print i,S[i]}'
1九、/var/log/messages日志出现kernel: nf_conntrack: table full, dropping packet.请问是什么缘由致使的?如何解决?
优化内核参数
net.nf_conntrack_max = 25000000
net.netfilter.nf_conntrack_max = 25000000
net.netfilter.nf_conntrack_tcp_timeout_established = 180
net.netfilter.nf_conntrack_tcp_timeout_time_wait = 120
net.netfilter.nf_conntrack_tcp_timeout_close_wait = 60
net.netfilter.nf_conntrack_tcp_timeout_fin_wait = 120
20、压轴上机实战iptables考试题
iptables -t nat -A POSTROUTING -s 10.0.0.253 -j SNAT -o eth0 --to-source 120.43.61.124
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
tcpdump ip host 10.0.0.253 and 10.0.0.6 或 tcpdump ip host 10.0.0.253 and 10.0.0.7
iptables -t nat -A PREROUTING -d 120.43.61.124 -p tcp --dport 80 -j DNAT --to-destination 172.16.1.6:80