Get the App
SLTechnology News&Howtos  ›  Network Security  › 

Iptables Firewall activity

Shulou Source: shulou.com Published: 2022-06-01 07:08:13 11月25日 Update

1. So that only 192.168.0.x and 192.168.0.y machines can connect to your pop3 server. But other people in the same segment can't. [answer: POP3 is the receiving server, default port is 110, SMTP is the sending server Default port 25] #! / bin/bash for i in net filter mangle do iptables-t $I-F iptables-t $I-X done ip = "192.168.0" iptables-t filter-An INPUT-p tcp-s $ip.x-- dport 110-j ACCEPT iptables-t filter-An INPUT-p tcp-s $ip.y-- dport 110-j ACCEPT iptables-t filter-An INPUT-p tcp-s $ip.0/24-- dport 110-j REJECT- -2. Set the default policy to INPUT and OUTPUT to deny all, but: allow you any access to your own ip addresses (192.168.0.11 and 127.0.0.1). #! / bin/bash for i in net filter mangle do iptables-t $I-F iptables-t $I-X done iptables-An INPUT-s 192.168.0.11-j ACCEPT iptables-An OUTPUT-d 192.168.0.11-j ACCEPT iptables-An INPUT-s 127.0.0.1-j ACCEPT iptables-An OUTPUT-d 127.0.0.1-j ACCEPT iptables-P INPUT REJECT iptables-P OUTPUT REJECT # iptables-An INPUT-j REJECT # iptables-An OUTPUT-j REJECT -3. Only two people, that is, two hosts, are allowed to telnet you. For example, one of them is 192.168.0.123 #! / bin/bash for i in net filter mangle do iptables-t $I-F iptables-t $I-X done ip = "192.168.0" iptables-An INPUT-s ip.123-- dport 23-j ACCEPT iptables-An INPUT-s ip.x-dport 23-j ACCEPT iptables-An INPUT-- dport 23-j REJECT-- -- 4. Allow two people to ping you once per second [ping type=8] #! / bin/bash iptables-F iptables-t nat-F iptables-X iptables-t nat-X iptables-An INPUT-s 192.168.1.x-p icmp--icmp-type 8-m limit-- limit 1Universe s-j ACCEPT iptables-An INPUT-s 192.168.1.y-p icmp--icmp-type 8-m limit-limit 1Bank s-j ACCEPT-- -5. Allows you to actively visit anyone #! / bin/bash iptables-F iptables-t nat-F iptables-X iptables-t nat-X iptables-An OUTPUT-p tcp--tcp-flags SYN,ACK,RST SYN-j ACCEPT iptables-An INPUT-p tcp--tcp-flags SYN,ACK RST SYN-j REJECT-6.Test01 users can use their own ip addresses for testing purposes But cannot access any other ip-7.Test02 users can access any address #! / bin/bash iptables-F iptables-t nat-F iptables-X iptables-t nat-X iptables-A INPUT-s Test02-j ACCEPT iptables-P INPUT REJECT-8. Define a custom rule to log all actions that access your port 23. #! / bin/bash iptables-F iptables-t nat-F iptables-X iptables-t nat-X iptables-An INPUT-dport 23-j LOG-log-level info-- log-prefix "iptables"

Tags: Address server port service user problem solution Xu no active host action only log machine usage network segment rules query test firewall Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Shulou Technology Linux Shulou Information Shulou Tech Info