linux 防火墙开启关闭
(1)即时生效,重启失效
service iptables start
service iptables stop
(2)重启后生效
chkconfig iptables on
chkconfig iptables off
查看端口状态
(1)upd
netstat -nupl
(2)tcp
netstat -ntpl
查看某端口状态 lsof
例如:lsof -i:80
netstat -an | grep port
拒绝端口访问
例如拒绝3000端口访问
iptables -A INPUT --dport 3000 -j DROP
例如拒绝3000以上的端口访问
iptables -A INPUT --dport 3001:65535 -j DROP
开启3000端口
iptables -A INPUT -p tcp --dport 3000 -j ACCEPT
(1)即时生效,重启失效
service iptables start
service iptables stop
(2)重启后生效
chkconfig iptables on
chkconfig iptables off
查看端口状态
(1)upd
netstat -nupl
(2)tcp
netstat -ntpl
查看某端口状态 lsof
例如:lsof -i:80
netstat -an | grep port
拒绝端口访问
例如拒绝3000端口访问
iptables -A INPUT --dport 3000 -j DROP
例如拒绝3000以上的端口访问
iptables -A INPUT --dport 3001:65535 -j DROP
开启3000端口
iptables -A INPUT -p tcp --dport 3000 -j ACCEPT