Introduction

Need some useful examples for entering Iptables and Ip6tables? Look no further. All commands need to be run as sudo or root.

Useful commands

List rules

iptables -L -n -v
ip6tables -L -n -v

iptables -L --line-numbers
ip6tables -L --line-numbers

Insert rules

iptables -I INPUT 2 -p tcp -m state --state NEW -s 172.20.0.0/24 --destination-port ssh -j ACCEPT

ip6tables -I INPUT 2 -p tcp -m state --state NEW -s 2001:470:1f09:3d9::/64 --destination-port ssh -j ACCEPT

Delete rules

iptables -D INPUT 1
ip6tables -D INPUT 1

Set default rules

iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
iptables -A INPUT -m state --state NEW,ESTABLISHED -j ACCEPT

ip6tables -P INPUT DROP
ip6tables -P FORWARD DROP
ip6tables -P OUTPUT ACCEPT
ip6tables -A INPUT -m state --state NEW,ESTABLISHED -j ACCEPT

Save rules – CentOS

service iptables save
service ip6tables save

Need anything else?

Please see the following great source post:

http://www.cyberciti.biz/tips/linux-iptables-examples.html

Iptables/Ip6tables Commands
Tagged on:     

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

Optimization WordPress Plugins & Solutions by W3 EDGE