久久婷婷香蕉热狠狠综合,精品无码国产自产拍在线观看蜜,寡妇房东在做爰3,中文字幕日本人妻久久久免费,国产成人精品三上悠亚久久

當前位置:首頁 > 嵌入式培訓 > 嵌入式學習 > 講師博文 > Linuxiptables 配置

Linuxiptables 配(pei)置 時(shi)間:2018-09-27      來源(yuan):未知(zhi)

一、只(zhi)給 Centos 6.5 打開 22 和 80 端口,并且重啟后有效:

1、查(cha)看所有 iptables 配置:

[root@Demon yum.repos.d]# iptables -L -n (當前防(fang)火墻(qiang)是關閉的)

Chain INPUT (policy ACCEPT)

target prot opt source destination

Chain FORWARD (policy ACCEPT)

target prot opt source destination

Chain OUTPUT (policy ACCEPT)

target prot opt source destination

2、只允許 80 和 22 端口通過防火(huo)墻

# 清(qing)除所有(you)規則

[root@Demon opt]# iptables -F

# 只允許 發送的包從(cong) 22 端口進入(ru)和返(fan)回, -A 的意思是添加一(yi)條 INPUT 規(gui)則, -p 指定(ding)為什么協(xie)議,--dport 為目標(biao)端口

[root@Demon opt]# iptables -A INPUT -p tcp --dport 22 -j ACCEPT

[root@Demon opt]# iptables -A OUTPUT -p tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT

# 允許本機訪(fang)問(wen)本機

[root@Demon opt]# iptables -A INPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT

[root@Demon opt]# iptables -A OUTPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT

# 允許所有 IP 訪問(wen) 80 端口(kou)

[root@Demon opt]# iptables -A INPUT -p tcp -s 0/0 --dport 80 -j ACCEPT

[root@Demon opt]# iptables -A OUTPUT -p tcp --sport 80 -m state --state ESTABLISHED -j ACCEPT

[root@Demon opt]# iptables -P INPUT DROP

[root@Demon opt]# iptables -P OUTPUT DROP

[root@Demon opt]# iptables -P FORWARD DROP

# 保存配置

[root@Demon opt]# iptables-save > /etc/sysconfig/iptables

[root@Demon opt]# iptables -L

Chain INPUT (policy DROP)

target prot opt source destination

ACCEPT tcp -- anywhere anywhere tcp dpt:ssh

ACCEPT all -- localhost localhost

ACCEPT tcp -- anywhere anywhere tcp dpt:http

Chain FORWARD (policy DROP)

target prot opt source destination

Chain OUTPUT (policy DROP)

target prot opt source destination

ACCEPT tcp -- anywhere anywhere tcp spt:ssh state ESTABLISHED

ACCEPT all -- localhost localhost

 ACCEPT tcp -- anywhere anywhere tcp spt:http state ESTABLISHED

# 重啟電(dian)腦后(hou), ping 一下百度(du):

[root@Demon opt]# ping www.baidu.com

ping: unknown host www.baidu.com

二(er)、關閉 iptables

# 打開防火墻,重啟生效

# chkconfig iptables on

# 關閉防(fang)火墻,重啟生效(xiao)

# chkconfig iptables off

# 打開防(fang)火墻,立(li)即生效,重啟后不生效

# chkconfig start

# 關閉(bi)防火墻,立即生效,重啟后不生效

# chkconfig stop

上一篇:Linux管理軟件包

下一篇:Linux編譯軟件包

熱(re)點文章推薦
華清學員(yuan)就業榜單
高(gao)薪(xin)學員(yuan)經驗(yan)分享
熱點新(xin)聞推薦
前臺專線:010-82525158 企(qi)業(ye)培訓(xun)洽談專線:010-82525379 院(yuan)校合作洽談(tan)專(zhuan)線:010-82525379 Copyright © 2004-2022 北京華清遠見科技集團有限公司 版權所有 ,,京公海網安備11010802025203號

回到頂部