12-30-2023 06:28 PM
I have setup NAT and firewall on my C1111-8w8p router and I believe it is correct. Let me know if you see any other problems here. I am still learning. But now I need to block access to the router. Port scan of public ip shows 22, 80, 443, and 1720 open. Not sure how to do that the best way. Please help. Here is my configuration:
12-31-2023 12:20 AM - edited 12-31-2023 01:11 AM
to be honest I was think that the OUT-IN Zone pair cover also zone-pair OUT-Self
but in such case and I have time I lab it to check
Case 1
the OUT-IN using class match protocol OUT-IN action is drop
and you can see I can telnet to R1
Case2
Zone Pair OUT-Self with class match telnet and action is drop
you can see the port is closs and I cant access R1 anymore
so use class match protocol then use policy action drop
NOTE:- this make you can not access Router via telnet or SSH from OUT anymore
MHM
12-31-2023 12:45 AM - edited 12-31-2023 07:53 AM
@jeremy0463 if you wish to restrict access "to" the router itself using ZBFW then you need to use the "self" zone. Create a zone-pair from source OUTSIDE to destination self (referening the service policy obviously). Using a zone-pair from OUTSIDE to INSIDE affects only traffic going "through" the firewall, not "to" the firewall itself.
EDIT - @MHM Cisco World I notice you have now corrected your initial response, FYI here is more information on the self zone https://community.cisco.com/t5/security-knowledge-base/zbfw-self-zone-integration/ta-p/3154572
12-31-2023 08:03 AM
Thanks
Let us stop work and enjoy with our family this night.
Have a nice new year eve
See you next year lol..
MHM
12-31-2023 01:38 PM
So here is what I am planning on implementing. It should leave room to add vpn later. Does this work?
—————————————————————————————————————————
SELF AND INSIDE
—————————————————————————————————————————
ip access-list extended Self_and_Inside
permit ip any any
class-map type inspect Inside_Self
match access-group name Self_and_Inside
policy-map type inspect Inside_Self
class Inside_Self
inspect
Policy-map type inspect Self_Inside
class Inside_Self
inspect
zone-pair security Self_to_Inside source self destination INSIDE
service-policy type inspect Self_Inside
zone-pair security Inside_to_Self source INSIDE destination self
service-policy type inspect Inside_Self
—————————————————————————————————————————
SELF AND OUTSIDE
—————————————————————————————————————————
ip access-list extended OUTSIDE_to_self_acl
deny ip any any
ip access-list extended self_to_OUTSIDE_acl
permit ip any any
class-map type inspect match-any OUTSIDE_to_self_app
match protocol ipsec
class-map type inspect match-any self_to_OUTSIDE_app
match protocol any
class-map type inspect match-all OUTSIDE-to-self_cmap
match class-map OUTSIDE_to_self_app
match access-group name OUTSIDE_to_self_acl
class-map type inspect match-all self-to-OUTSIDE_cmap
match class-map self-to-OUTSIDE_app
match access-group name self-to-OUTSIDE_acl
policy-map type inspect self-TO-OUTSIDE_policy
class type inspect OUTSIDE-TO-self_cmap
inspect
class class-default
drop log
policy-map type inspect OUTSIDE-TO-self_policy
class type inspect self-TO-OUTSIDE_cmap
inspect
class class-default
drop log
zone-pair security Out-To-Self source OUTSIDE destination self
service-policy type inspect Out_Self
zone-pair security Self-To-Out source self destination OUTSIDE
service-policy type inspect Self_Out
12-31-2023 02:02 PM - edited 12-31-2023 02:08 PM
@jeremy0463 Why are you matching all on the same class map? Traffic will have to match both.
class-map type inspect match-all OUTSIDE-to-self_cmap
match class-map OUTSIDE_to_self_app
match access-group name OUTSIDE_to_self_acl
Regardless, you would "pass" the IPSec traffic (udp/500, esp and udp/4500 if nat-t) rather than match on ipsec for traffic to the router. https://www.cisco.com/c/en/us/support/docs/routers/3800-series-integrated-services-routers/112051-zbf-vpn-access-config.html
So create an ACL to match the IPsec traffic, match on that ACL in the class-map and reference in the policy-map. Then deny all other traffic to self from outside using the class-default and drop. Example:
ip access-list extended ISAKMP-IPSEC
permit udp any any eq isakmp
permit esp any any
permit udp any any eq non500-isakmp
class-map type inspect match-all CM-IPSEC
match access-group name ISAKMP-IPSEC
policy-map type inspect PM-OUTSIDE->self
class type inspect CM-IPSEC
pass
class class-default
drop
zone-pair security OUTSIDE->self source OUTSIDE destination self
service-policy type inspect PM-OUTSIDE->self
12-31-2023 03:10 PM
The vpn was just a provision for the future just in case, I can leave that alone for now and make that another step. Basically I had a match all so that the acl would be matched and the class map would also be matched. I left the deny all in place to block it completely for now, but was later going to permit specific iPs and then I could do the pass con portion. I don’t know, still learning here. My primary goal is to block outside access to the router itself. I jumped the gun on vpn. Let’s stick with blocking services. So as far as an overall “self-zone” to block services from outside to self but allow self to outside, inside to self, and self to inside, would this accomplish:
—————————————————————————————————————————
SELF AND INSIDE
—————————————————————————————————————————
ip access-list extended Self_and_Inside
permit ip any any
class-map type inspect Inside_Self
match access-group name Self_and_Inside
policy-map type inspect Inside_Self
class Inside_Self
inspect
Policy-map type inspect Self_Inside
class Inside_Self
inspect
zone-pair security Self_to_Inside source self destination INSIDE
service-policy type inspect Self_Inside
zone-pair security Inside_to_Self source INSIDE destination self
service-policy type inspect Inside_Self
—————————————————————————————————————————
SELF AND OUTSIDE
—————————————————————————————————————————
ip access-list extended OUTSIDE_to_self_acl
deny ip any any
class-map type inspect OUTSIDE_to_self_cmap
match access-group name OUTSIDE_to_self_acl
policy-map type inspect OUTSIDE-TO-self_policy
class type inspect OUTSIDE-TO-self_cmap
inspect
class class-default
drop log
ip access-list extended self_to_OUTSIDE_acl
permit ip any any
class-map type inspect self_to_OUTSIDE_cmap
match access-group name self_to_OUTSIDE_acl
policy-map type inspect self-TO-OUTSIDE_policy
class type inspect self-TO-OUTSIDE_cmap
inspect
class class-default
drop log
zone-pair security OUTSIDE-TO-self source OUTSIDE destination self
service-policy type inspect OUTSIDE-TO-self_policy
zone-pair security self-TO-OUTSIDE source self destination OUTSIDE
service-policy type inspect self-TO-OUTSIDE_policy
12-31-2023 03:12 PM
I feel like I’m confused now
12-31-2023 03:17 PM
Dont confused' in late night of Monday I will send you some note.
Dont worry
Happy new year friend
MHM
01-01-2024 08:21 AM
it long time from last year LOL...
NOW let start
classify the Zone
there is
1-default Zone which all interface member of it unless you make interface member of other Zone (this use for though the box)
2-Zone, simple way config zone with name IN and OUT or LAN and WAN ...etc.
3-Self Zone this include the all interface in this device (use for to-box traffic)
Zone Pair
1-to-Self-from-Out
traffic like
1- icmp
2-telnet
3-SSH
4-VPN IPSec UDP 500/4500
5-http
use class match-any let called it Class Port
traffic toward specific IP
use acl
use class match all let called it Class IP
finally we config class let called it Class to-self match all under it we match class Class Port and Class IP
for policy we use Class to-self and action is
1- Pass if we dont use other zone pair from-Self
2- Inspect if we use other zone pair from-self
1-from-Self-to-Out
this zone if you want to ping from router to other and telnet from it to other.
traffic like
1- icmp
2-telnet
3-SSH
4-VPN IPSec UDP ports 500/4500
5-http
use class match-any let called it Class Port
note:- you can optional specific IP that router can ping or make it open
finally we config class let called it Class from-self match all under it we match class Class Port
for policy we use Class from-self and action is
Inspect since we use to-self with inspect
that all what you need
you are free to ask if you have Q
MHM
01-01-2024 09:02 AM
lol! Yes it has been a long time…haha
ok, let me get to working on this and I will report back. I’m going to do some more reading and start the firewall configuration over completely. I feel like there is a gap in my understanding of how zone based firewalls work. I will report back soon
01-01-2024 02:15 PM
Ok, just got finished reading the ZBFW design doc all over again. Here is what I think I have come up with. Let’s just start over here:
——————————————————————————————————————————
Firewall requirements:
***Configuration below uses Cisco default firewall configuration as a base***
——————————————————————————————————————————
1-2:
zone security INSIDE
description Zone for inside interfaces
zone security OUTSIDE
description Zone for outside interfaces
zone security default
ip access-list extended Web_acl
permit ip any any
class-map type inspect match-any Web_app
match protocol tcp
match protocol udp
match protocol ftp
match protocol icmp
class-map type inspect match-all Web
match class-map Web_app
match access-group name Web_acl
policy-map type inspect INSIDE-OUTSIDE-POLICY
class type inspect Web
inspect
class class-default
drop log
zone-pair security INSIDE-OUTSIDE source INSIDE destination OUTSIDE
service-policy type inspect INSIDE-OUTSIDE-POLICY
interface gigabitEthernet 0/1/0
zone-member security INSIDE
interface Vlan1
zone-member security INSIDE
interface Vlan250
zone-member security INSIDE
interface gigabitEthernet 0/1/0
zone-member security OUTSIDE
Comments - This configuration defines three zones, which by default are deny according to the ZBFW rules. A class map “Web” has been defined to inspect and match all traffic in the Web_acl and the Web_app class map. Inside each of those is a match any. So as I understand it, what happens is, any traffic from inside to out must match anything in the acl and any traffic in the class map in order to be permitted. This seems to allow restricting/permitting particular clients or networks and more generally, particular protocols. So if I wanted to allow https but not http, I would do that in the class map. If I wanted to restrict internal subnets from getting through, I would specify only the ones I wanted to get through in the acl. The policy map INSIDE-OUTSIDE-POLICY then performs the action. It inspects based on the web class map and permits but inspects that traffic. Then everything else is dropped and logged based on the class class-default. In this case, all traffic is inspected but permitted from inside to out. Since the zone outside and inside are defined, but no policy is in place for outside to inside, all traffic is denied by default. This seems to accomplish the first two objectives in the requirements. If I wanted to allow som out-in traffic at some point, I would need to do the same configuration as above for the out-in policy, limit to particular ip addresses in the acl, and limit to particular protocols in the class map with a new class map that was match all. Then I would inspect that traffic and then drop and log all other traffic based on class-default. Although, I’m not sure why I need the drop portion of the policy if the default is deny. Wouldn’t the policy allow what has been defined and drop everything else? Or is that only implicit when a policy does not exist?
Now on to the self zone.
According to the documentation, the self-zone a system defined zone is the only exception to the default deny all policy. All traffic to any router interface is allowed until traffic is explicitly denied. Therefore, it would seem that in this case, I can similarly configure the self-out policy to permit all traffic as above. However, I can’t leave out-self without a policy because it will implicitly permit all traffic. Therefore, I think this needs to be my self zone configuration:
3:
ip access-list extended self_Web_acl
permit ip any any
class-map type inspect match-any self_Web_app
match protocol tcp
match protocol udp
match protocol ftp
match protocol icmp
class-map type inspect match-all self_Web
match class-map self_Web_app
match access-group name self_Web_acl
policy-map type inspect self-OUTSIDE-POLICY
class type inspect self_Web
inspect
class class-default
drop log
zone-pair security self-OUTSIDE source self destination OUTSIDE
service-policy type inspect self-OUTSIDE-POLICY
4: (This one is the one I am not sure about)
ip access-list extended Web_self_acl remark: in place to permit future vpn ip addresses
deny ip any any
class-map type inspect match-any Web_self_app remark: left empty to add vpn protocols
class-map type inspect match-all Web_self
match class-map Web_self_app
match access-group name Web_self_acl
policy-map type inspect OUTSIDE-self-POLICY
class type inspect self_Web
pass remark: because layer 7 can’t be inspected?
class class-default
drop log
zone-pair security OUTSIDE-self source OUTSIDE destination self
service-policy type inspect OUTSIDE-self-POLICY
Comments: now I know I could simplify #4 to policy-map type inspect OUTSIDE-self-POLICY
class class-default
drop log
But I want to leave room for vpn from specific addresses. And I may even permit all in the acl in order to use the client to site vpn so I could connect from anywhere. But this is where I am. Does this seem right and like I understand everything correctly? This is after reading this article again (https://www.cisco.com/c/en/us/support/docs/security/ios-firewall/98628-zone-design-guide.pdf) and the articles you guys posted.
01-01-2024 02:57 PM
all is correct, and I also check your point 4,
I check if by default the traffic between the OUT and Self is permit or not
and I get result it permit by default
I run IPSec VPN and the tunnel is UP and traffic is pass between two routers (after allow traffic from IN/OUT to OUT/IN)
so your steps to deny the traffic is override the default and deny any VPN
MHM
01-01-2024 03:20 PM
Awesome, I feel like I’m understanding the concept now. On 4, yes, I intended to deny all for now until I get around to setting up the vpn. For now, the policy should deny all traffic from outside to self.
01-01-2024 03:26 PM - edited 01-01-2024 03:28 PM
Yes I see and it more secure.
for IN-OUT you match any protocol and action is inspect this will allow traffic from IN to OUT match protocol + prefix
and since you use inspect NOT pass the return traffic can permit from OUT-IN
that different between inspect and pass
have a nice day and happy new year
MHM
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide