Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Utility iptables lists host names and not IP addresses

Using command

iptables -L

I list the rules in a all chains, but this tool lists host names instead of IP addresses for the rules that are saved. This is kind of hard reading, as in case I want to quickly find some IP address in the list, it is impossible.

Is there a way, the command switch or anything simple to use, that would let me list my iptables rules with IP addresses and not host names?

like image 685
Ωmega Avatar asked Feb 28 '14 01:02

Ωmega


People also ask

How is iptables utility used?

iptables is a user-space utility program that allows a system administrator to configure the IP packet filter rules of the Linux kernel firewall, implemented as different Netfilter modules. The filters are organized in different tables, which contain chains of rules for how to treat network traffic packets.

Can you use hostname in iptables?

Using IP sets allows you to create an easy to manage list of IP addresses that iptables can use in it's rules. As we have shown when paired with a simple Bash script it can also help to create rules from a hostname or domain name.


1 Answers

Use the following:

iptables -L -n

From the man page:

-n, --numeric
    Numeric output. IP addresses and port numbers will be printed in numeric format.
    By default, the program will try to display them as host names, network names, 
    or services (whenever applicable). 
like image 186
Bob Shannon Avatar answered Sep 23 '22 13:09

Bob Shannon