2.0 KiB
2.0 KiB
iptable work with net filter
connection type:
- new
- stablished
- Related
iptable-persitant --> install iptables and save in iptables file
defualt path --> /etc/iptables
command format
iptables -t <table-names> <option> <chain-name> <match> -j <action>
table name:
- filter (default) --> Filtering Packets
- nat --> Nating Service
- mangel --> Edit Packets
- raw --> edit packets before prossecc by os
chains:
- filter:
- INPUT
- OUTPUT
- Forward
- nat
- OUTPUT
- PREROUTING
- PASTROUTING
- mangle
- INPUT
- OUTPUT
- Forward
- PREROUTING
- PASTROUTING
- raw
- OUTPUT
- PREROUTIUNG
INPUT : Connection Incomming into Server OUTPUT : Packets Outgoiing From server FORWARD : Packer incomming to server but the target is not server (routing) PREROUTING : EDIT Packets Before Routing PASTROUTING : Edit Packet After Routing And Before Exit From Server
option:
-A: Append-I: Insert-D: Delete
actions: ACCEPT: accept the packet DROP: drop the packer without any msg REJECT: drop the packet with send message to packet sender LOG: Log The Packet MASQUERADE: Nating
iptables-save >> <file_dir>
iptables -nL
iptables -t nat -nL
iptables -t filter -I INPUT -s 192.168.1.100 -j ACCEPT
iptables -t filter -I INPUT -j DROP
iptables -t filter -A INPUT -j DROP
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -I INPUT -p tcp --dport 22 -j DROP
iptables -A INPUT -p tcp -s 192.168.1.100 -j DROP
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
les -A INPUT -p tcp -m multiport --dport 22,443,80,3306 -j ACCEPT
iptables -A INPUT -p tcp -m multiport --dport 22,443,80,3306 -d 192.168.10.0/24 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -m limit --limit 100/minute --limit-burst 200 -j ACCEPT
iptables -t NAT -A PREROUTING -i ens33 -p tcp --dport 80 -j REDIRECT --to-port 443