一、詳述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