iptables

IPtables


==============================
Block Port:
==============================

# iptables -I INPUT -p tcp -m tcp --dport 80 -j DROP
# iptables -I OUTPUT -p tcp -m tcp --dport 80 -j DROP
# iptables-save

==============================
IPTables Add Rule:
==============================

# iptables -nvL --line-numbers
# iptables -I INPUT 1 -p tcp --dport 8443 -j ACCEPT
# iptables-save
# service iptables save
# service iptables restart

==============================
Block an IP in IPTABLES:
==============================

# iptables -I INPUT -s XXX.XXX.XXX.XXX -j DROP

==============================
IPTables Delete Rule:
==============================
# iptables -nvL --line-numbers
# iptables -D INPUT 22
==============================
IPTables Other Rules:
==============================
# iptables -I INPUT 1 -i ens192 -s 82.165.232.19 -j ACCEPT #permit traffic from this IP on interface ens192. Place rule before all others
# iptables -A INPUT -i lo -j ACCEPT # permit traffic on local loopback. Rule goes in current last place
# iptables -A INPUT -p tcp -m multiport --dports 80,443 -j ACCEPT # accept traffic on multiple ports
# iptables -A PREROUTING -t nat -p udp -i eth0 --dport 443 -j DNAT --to 10.10.10.2:443 # rewrite traffic on eth0 over port 443 to destination 10.10.10.2