centos7配置安装iptables

  • 关闭firewalld,且禁用

    1
    2
    systemctl stop firewalld.service
    systemctl disable firewalld.service
  • 安装iptables

    1
    yum install iptables-services -y
  • 配置iptables

vi /etc/sysconfig/iptables

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# sample configuration for iptables service
# you can edit this manually or use system-config-firewall
# please do not ask us to add additional ports/services to this default configuration
*filter
:INPUT DROP [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-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 -s 192.168.1.0/24 -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
  • 重启iptables
    1
    systemctl restart iptables.service
Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×