Logging TCP Sessions
Problem
You want to log the total number of TCP sessions.
Solution
You can configure the router to log the total number of TCP sessions, rather than just the number of packets, with the following set of commands:
Router1#configure terminal
Enter configuration commands, one per line. End with CNTL/Z. Router1(config)#access-list
122
permit tcp any any eq telnet established
Router1(config)#access-list
122
permit tcp any any eq telnet
Router1(config)#access-list
122
permit ip any any
Router1(config)#interface
Router1(config-if)#
Serial0/0
ip access-group
122
in
Router1(config-if)#exit
Router1(config)#end
Router1#
Here is an alternative method that will also work:
Router1#configure terminal
Enter configuration commands, one per line. End with CNTL/Z. Router1(config)#access-list
121
permit tcp any any eq telnet syn
Router1(config)#access-list
121
permit tcp any any eq telnet
Router1(config)#access-list
121
permit ip any any
Router1(config)#interface
Router1(config-if)#
Serial0/0
ip access-group
121
in
Router1(config-if)#exit
Router1(config)#end
Router1#
Discussion
When you configure an access-list, the router counts the total number of times it finds something that matches each line in the ACL. While this information is often useful, it does not tell you whether these counters are recording a thousand packets on a single session, or a single packet from each of a thousand sessions. The ACLs in this recipe count the number of TCP sessions as well as the total number of packets. ...
Get Cisco IOS Cookbook, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.