Add entry with -A
sudo iptables -A INPUT -p tcp -m tcp --dport 3306 -j ACCEPT
Remove an entry with -D
sudo iptables -D INPUT -p tcp -m tcp --dport 3306 -j ACCEPT
You can list all rules by line number
sudo iptables -L INPUT --line-numbers
Chain INPUT (policy DROP)
num target prot opt source destination
1 ACCEPT all -- anywhere anywhere
2 ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED
3 ACCEPT tcp -- anywhere anywhere tcp dpt:ssh
4 ACCEPT tcp -- anywhere anywhere tcp dpt:http
5 ACCEPT tcp -- anywhere anywhere tcp dpt:mysql
6 DROP all -- anywhere anywhere
7 ufw-before-logging-input all -- anywhere anywhere
8 ufw-before-input all -- anywhere anywhere
9 ufw-after-input all -- anywhere anywhere
10 ufw-after-logging-input all -- anywhere anywhere
11 ufw-reject-input all -- anywhere anywhere
12 ufw-track-input all -- anywhere anywhere
Delete rule by number
sudo iptables -D INPUT 5