Get the App
SLTechnology News&Howtos  ›  Network Security  › 

Secure iptables firewall configuration (only activate SSH,WEB,DNS service)

Shulou Source: shulou.com Published: 2022-06-01 04:36:38 09月30日 Update

Iptables-F clear all rule chains iptables-X remove specific manual chain iptables-Z emptying counter iptables-P INPUT DROP / / default INPUT rules discard iptables-P OUTPUT DROP / / default OUTPUT rules discard iptables-P FORWARD DROP / / default FORWARD rules discard iptables-An INPUT-d 192.168.10.250-p tcp-m tcp-dport 22-j ACCEPT / / open SSH service inbound port iptables-An INPUT-d 192. 168.10.250-p tcp-m tcp-- dport 80-j ACCEPT / / Open WEB service inbound port iptables-An INPUT-s 127.0.0.1-d 127.0.0.1-j ACCEPT / / allow local loopback data iptables-An INPUT-p udp-m udp-sport 53-j ACCEPT / / packets from remote DNS server port 53 go through iptables-An INPUT-p udp-m udp-dport 53-j ACCEPT / / Packets entering port 53 of the local server can enter the local server through iptables-An INPUT-d 192.168.10.250-p icmp-j ACCEPT / / ICPM packets can enter the local server iptables-An OUTPUT-s 192.168.10.250-p tcp-m tcp-sport 22-m state-- state ESTABLISHED-j ACCEPT / / An OUTPUT-s 192.168.10.250-p tcp- M tcp-- sport 80-m state-- state ESTABLISHED-j ACCEPT / / Open outbound port iptables-An OUTPUT-s 127.0.0.1-d 127.0.0.1-j ACCEPT / / allow local loopback data iptables-An OUTPUT-p udp-m udp-sport 53-j ACCEPT / / packets outbound from local port 53 outbound via iptables-An OUTPUT-p udp-m udp-- dport 53- J ACCEPT / / packets outbound to remote DNS server port 53 via iptables-An OUTPUT-s 192.168.10.250-p icmp-j ACCEPT / / A pair of ICMP packets echo (ping command echo packet) service iptables save / / Save configuration information service iptables start / / turn on firewall service

Tags: Data service port server rule firewall configuration fire prevention information command other party manual counter accessible security Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Apple MySQL Shulou Information vpn