1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Command for NAT table contents?

Discussion in 'HyperWRT Firmware' started by OPaul, Nov 24, 2004.

  1. OPaul

    OPaul Network Guru Member

    Is there a command to see the NAT table or at least how many entries are in it? Or how big it currently is?
     
  2. lud

    lud Network Guru Member

    cat /proc/net/ip_conntrack
     
  3. OPaul

    OPaul Network Guru Member

    Is there a quicker way of telling how many entries there are total besides counting them all?
     
  4. 4Access

    4Access Network Guru Member

    I believe the following should work:

    Code:
    cat /proc/net/ip_conntrack | grep -c .
     
  5. OPaul

    OPaul Network Guru Member

    Hmm, that returns
     
  6. 4Access

    4Access Network Guru Member

    It was easy to miss in the first example, but don't forget the period at the end:

    cat /proc/net/ip_conntrack | grep -c .
     
  7. OPaul

    OPaul Network Guru Member

    Perfect, thanks.
     
  8. dankim831

    dankim831 Network Guru Member

    what does the period at the end do? does it count periods or does it count lines?
     
  9. 4Access

    4Access Network Guru Member

    The period is a wild card, it matches any single character. The -c tells grep to count the number of matching lines instead of displaying the matching lines themselves.

    (Note that when just executing the "cat /proc/net/ip_conntrack" command from the web interface the results are wrapped which makes it look like there are more lines than there really are. To prove this simply copy the result of the command into notepad and disable word wrap. The grep command reports the true number of lines.)
     
  10. sjk

    sjk Network Guru Member

    Or:
    Code:
    cat /proc/net/ip_conntrack | wc -l
     
  11. OPaul

    OPaul Network Guru Member

     
  12. sjk

    sjk Network Guru Member

    Ahh, I didn't realize wc wasn't installed... thanks for the info.
     

Share This Page