- add chain
# iptables -N (enter chain name)نمایش وضعیت فایروال لینوکس (linux iptables)
# iptables -n -L -v --line-numbersحذف کلیه رول ها از فایروال ( Flush iptables ):
# iptables -F
OR
# iptables --flush
# service iptables save
Saving firewall rules to /etc/sysconfig/iptables: [ OK ]# iptables -A INPUT -s 1.2.3.4 -j DROP
# iptables -A INPUT -s 192.168.0.0/24 -j DROPHow to forward port in Linux
Here we will forward port 80 to port 8080 on 172.31.40.29. Do not get confused port forwarding with port redirection. We need to insert an entry in PREROUTING chain of iptables with DNAT target. Command will be as follows –
# iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j DNAT --to 172.31.40.29:8080
# iptables -A FORWARD -p tcp -d 172.31.40.29 --dport 8080 -j ACCEPTHow to check port forwarding iptables rules
[pc:]# iptables -t nat -L -n -v
result :
Chain PREROUTING (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 DNAT tcp -- eth0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:80 to:172.31.40.29:8080
Using ICMPv4:
ping <client wireguard ip > for exam -> 10.0.0.2
ping fdc9:281f:04d7:9ee9::2iptables -t nat -xvnL
tcpdump -n -tttt -i wg0 not port 22
# service iptables save
Saving firewall rules to /etc/sysconfig/iptables: [ OK ]