Linux CentOS7 最小化安装后续操作记录iptables
1.网络配置
vim编辑器 :yum -y install vim
yum install wget
2.关闭firewall,启用iptables
https://my.oschina.net/u/1253780/blog/2050514
查看防火墙状态
# firewall-cmd --state
#停止 Firewalld,关闭firewalld自动启动
systemctl stop firewalld
systemctl disable firewalld.service
#先检查是否安装了iptables
service iptables status
#安装iptables
yum install -y iptables
#安装iptables-services
yum install iptables-services
vim /etc/sysconfig/iptables #编辑防火墙配置文件
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [212:26700]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 9000 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
设置开机启动:systemctl enable iptables.service
开启服务:systemctl start iptables.service 后续修改则为:systemctl restart iptables.service
查看现有iptables规则:iptables -L -n
-
v:显示详细信息,包括每条规则的匹配包数量和匹配字节数
-
x:在 v 的基础上,禁止自动单位换算(K、M)
-
n:只显示IP地址和端口号,不将ip解析为域名
ifconfig :yum install -y net-tools

浙公网安备 33010602011771号