為了保證linux服務(wù)器網(wǎng)絡(luò)的安全,需要禁止服務(wù)器訪問某些不健康的網(wǎng)站。實(shí)操請(qǐng)往下看:
怎么保證linux服務(wù)器的網(wǎng)絡(luò)安全?
1.對(duì)指定網(wǎng)站禁止訪問
iptables支持試用域名和ip地址兩種方法來指定禁止的網(wǎng)站。如果使用域名的方式指定網(wǎng)站,iptables會(huì)通過dns服務(wù)器查詢?cè)撚蛎麑?duì)應(yīng)的所有ip地址,并將這些ip地址加入到規(guī)則中,所以使用域名指定網(wǎng)站時(shí),iptables的執(zhí)行速度會(huì)稍慢。
命令如下:
[root@localhost ~]# iptables -i forward -d www.xxx.com -j drop
[root@localhost ~]# iptables -t filter -l forward
2.禁止linux服務(wù)器上網(wǎng)
操作命令如下:
[root@localhost ~]# iptables -i forward -s 192.168.1.102 -j drop
[root@localhost ~]# iptables -t filter -l forward
3.禁止linux服務(wù)器訪問某些訪問
端口是tcp/ip使用“端口”來區(qū)分系統(tǒng)中的不同的服務(wù),如web服務(wù)使用的是tcp 80端口,ftp服務(wù)使用的是tcp 21端口等。由于不同的服務(wù)會(huì)使用不同的端口與外界進(jìn)行通信,因此要禁止linux服務(wù)器上的某些訪問,只要禁止服務(wù)使用的端口號(hào)即可。
操作命令如下:
[root@localhost ~]# iptables -i froward -s 192.168.1.0/24 -p tcp –dport 21 -j drop
[root@localhost ~]# iptables -t filter -l froward
聲明:文章來自網(wǎng)絡(luò)轉(zhuǎn)載,若無意中有侵犯您權(quán)益的信息,請(qǐng)聯(lián)系我們,我們會(huì)在第一時(shí)間刪除!