How can I remove a record from IPtables? I was blocking PaperLiBot (got 80+ hits in 10 hours) and initially I blocked 2 C classes below: DROP all -- 37.187.162.0/24 anywhere DROP all -- 37.187.165.0/24 anywhere Then I had a close look at IPs and realized that I need to block 8 C classes, so I added DROP all -- 37.187.160.0/21 anywhere I assumed that my last action will erase previous 2 records from IP tables as they are nested in this 8-range. Apparently not, when I run iptables -L I see all 3 lines there. How can I remove the first 2 records as they are unnecessary?
Great, thanks. In case somebody else is trying to do this, here is how (based on the answer from @popsicle with some info from post comments). Run command: iptables -vnL --line-numbers | grep "IP_ADDRESS", in my case IP_ADDRESS was "37.187.16" You get back something like: 66 DROP all -- 37.187.162.0/24 anywhere 67 DROP all -- 37.187.165.0/24 anywhere 68 DROP all -- 37.187.160.0/21 anywhere In my case I want to delete lines 66, 67 but have to remember that 67 will become 66 after delete the first line. So I had to run this twice: iptables -D INPUT 66