Improve company productivity with a Business Account.Sign Up

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 894
  • Last Modified:

Cisco host permit and deny a range of addresses

I am using a cisco router.  I want to restrict the use of ssh to only an internal 172.16.x.x set of addresses and block any other address from using using port 22.

I am using the following and including the subnet mask to indicate that I want to use the entire class b range.  

First, do I need to include the subnet mask?
Second, if so, what is the proper format?

access-list 123 permit tcp any host eq 22
access-list 123 deny   tcp any any eq 22
access-list 123 permit ip any any
  • 3
2 Solutions
You use a filter, not the subnet mask. use for this example.
Sorry, to be more clear. It's not generally referred to as a 'filter', this is a 'wildcard masking'.

so it should read

access-list 123 permit tcp any host eq 22
c3neAuthor Commented:
I get an invalid input response using either the mask or the filter with the market at the beginning of the filter.

router(config)#$ 123 permit tcp any host eq 22
access-list 123 permit tcp any host eq 22
% Invalid input detected at '^' marker.
Take the word host out of the statement. Sorry, I didnt catch that earlier!!
use the tab it will help you as you type in commands as far as what you need next.
there is an easier way to limit access to the device so its only through SSH and not Telnet..

enter these commands, this will take care of the access list also..

conf t
ip access-list extended SSH_ACCESS
  permit ip any
<type exit to get out of NACL mode>
line vty 0 4
transport input ssh
access-class SSH_ACCESS in

soon as you put the access list command in and the SSH thats it so make sure you are sure its right...a good little trick is before you do anything with the access lists type reload in 5, if it asks you to confirm the reload hit yes and then the timer starts...that will give you 5 minutes after which if you dont cancel it the router will reboot. so say you lock yourself out with an access list just wait 5 minutes and it will reboot and load the last saved config....just make sure if you do everything right to do a reload cancel to cancel can change the 5 to any number of minutes you want

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Building an Effective Phishing Protection Program

Join Director of Product Management Todd OBoyle on April 26th as he covers the key elements of a phishing protection program. Whether you’re an old hat at phishing education or considering starting a program -- we'll discuss critical components that should be in any program.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now