要查看iptables规则,您可以在Linux终端中使用以下命令:
iptables -L:列出所有iptables规则。iptables -L -n:以数字形式显示IP地址和端口号,而不是尝试解析主机名和服务名。iptables -L -v:显示规则的详细信息,包括数据包和字节计数。iptables -L -t nat:列出NAT表中的规则。iptables -L -t mangle:列出mangle表中的规则。iptables -L -t filter:列出filter表中的规则(这是默认表)。iptables -L -t raw:列出raw表中的规则。您还可以使用grep命令来过滤特定的规则,例如:
iptables -L | grep "192.168.1.1":显示包含IP地址192.168.1.1的所有规则。iptables -L -n | grep ":80":显示允许或拒绝访问端口80的所有规则。请注意,您需要具有root权限才能查看iptables规则。在执行这些命令时,请确保使用sudo或以root用户身份登录。