您的位置:首页 > 职场人生

运维人员20道必会iptables面试题

2017-02-09 16:47 531 查看
1、详述iptales工作流程以及规则过滤顺序?



iptables过滤的规则顺序是由上至下,若出现相同的匹配规则则遵循由上至下的顺序

2、iptables有几个表以及每个表有几个链?

Iptables有四表五链

3、iptables的几个表以及每个表对应链的作用,对应企业应用场景?

filter:INPUT 作用:for packets destined to local sockets

FORWARD 作用:for packets being routed through the box

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).

4、画图讲解iptables包过滤经过不同表和链简易流程图并阐述。

5、请写出查看iptables当前所有规则的命令。

iptables -L -n --line-numbers

6、禁止来自10.0.0.188 ip地址访问80端口的请求

iptables -A INPUT -p tcp --dport 80 -j DROP

7、如何使在命令行执行的iptables规则永久生效?

/etc/init.d/iptables save

iptables save >>/etc/sysconfig/iptables

8、实现把访问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

9、实现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

10、描述tcp 3次握手及四次断开过程?





11.详细描述HTTP工作原理?

1 ) 地址解析

2)封装HTTP请求数据包

3)封装成TCP包,建立TCP连接(TCP的三次握手)

4)客户机发送请求命令

5)服务器响应

6)服务器关闭TCP连接



12.请描述iptables的常见生产应用场景。

端口映射

企业应用场景:
1) 把访问外网IP及端口的请求映射到内网某个服务器及端口(企业内部);
2) 硬件防火墙,把访问LVS/nginx外网VIP及80端口的请求映射到IDC 负载均衡服务器内部IP及端口上(IDC机房的操作) ;

局域网共享上网

iptables -t nat -A POSTROUTING -s 10.0.0.0/24 -o eth0 -j SNAT --to-source 120.43.61.124

13、请描述下面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攻击的

14、企业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


(二)企业运维经验面试题:

15、写一个防火墙配置脚本,只允许远程主机访问本机的80端口(奇虎360面试题)

iptables -A INPUT -p tcp --dport 80 -j accept

iptables -A INPUT -p tcp -j DROP

16、请描述如何配置一个linux上网网关?

route add -net 192.168.0.0/24 gw 10.0.0.253 dev eth1

17、请描述如何配置一个专业的安全的WEB服务器主机防火墙?

先将默认的INPUT链和Forward链关闭,只开放允许进入的端口

iptables -P OUTPUT ACCEPT
iptables -P FORWARD DROP
iptables -P INPUT DROP

18、企业实战题6:请用至少两种方法实现!

写一个脚本解决DOS攻击生产案例

提示:根据web日志或者或者网络连接数,监控当某个IP并发连接数或者短时内PV达到100,即调用防火墙命令封掉对应的IP,监控频率每隔3分钟。防火墙命令为:iptables -I INPUT -s 10.0.1.10 -j DROP。

19、/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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: