Showing posts with label cciesecurity. Show all posts
Showing posts with label cciesecurity. Show all posts

Saturday, August 28, 2021

An intro. into Network Programmability

Today my post is about something I was doing recently which we all need to move forward and accept it as a vital part of our career development. which is learning python for network engineers.

as you all know, this has became a part from the blueprints and practical day to day work requirements to understand and use programmability of the networks.

Many programming languages exist but myself and many other network engineers if not 99% of us love working with Python. one of the reasons are:

1. Easy to learn and understand Python.

2. Network supporting libraries availability.

3.On systems like Linux and Mac OS Python comes preinstalled.

 

Okay, so since I knew that it was a must to start learning programming, I was in the phase of accepting this new challenge to simply reason which was (I HATED Programming) and of course this was due to learning in University and the languages we used to learn (Pascal back then). which did not make any sense to me and could not progress in it at all.

But after a while, I started pushing myself to learn and the challenge was (where to start?).

Of course learning ability and learning ways are different from one person to another, some people like to start reading on oppose to learn from a video, others are video learn first then book.

I'm latter type of people, so I started looking for video series that can help me learn python and especially network engineers type of learning python.

So my first go to option was (Udemy.Com) where I searched and found David Bombal's training series.(you can find lots of videos on YouTube as well)

and it was really good purchase compared to the price and the material quality.

 Started watching the videos at first which all was about 2-5 minutes long videos, which you think "that is short video!" but try again when you hate something and try to watch it for a minute.

As soon as David started explaining the need for learning programming language and it's benefits to us as network engineers, I started to realize how important it is and how important to learn it.

Basically you can make your daily tasks, the boring type of tasks that require you to login all devices one by one and collect simple information from each device an easy task and can be done in few seconds.

watching when you run a code to do it's magic in one click is amazing, thinking back about when I was still studying and preparing for my CCIE lab exam, and remembering time inside exam to use NotePad to make configuring devices fast and easy. learning python is sure an easy task to do giving it's value to help you configure hundreds of devices in no time.(Don't you think using notepad is kind of programmability?)

I remember  reactions from people here and there saying that I can't learn python and I can't be programmer and also programmers are going to take our jobs, or saying I'm too old to learn Python (which unfortunately some were a role models to network engineers from all over the world).

This does not make any sense and far beyond truth, no programmer is going to replace network engineer because programmers still don't know what is the commands that a network device can understand or which protocol to use and where and why!

In addition, Information technology in all of it's aspects and sections continue to develop everyday and we must keep ourselves up to date when it comes to knowledge, BTW this applies to everything around us because every profession requires updates, this is normal and we have to accept it!

This is kind of nonsense and you as a network engineer must not fall into this, go and seek knowledge 

by yourself, explore the subjects before deciding what is good or bad of hard or easy. you must be able to adapt new changes and continue learning.

I have finished the training and going beyond this training to finish a book that I bought from CiscoPress.com which is Cisco DEVASC Official Certification Guide. which I will be reading cover to cover now and practice everything in it, this is my next certification goal.

If you don't know what is Cisco DEVASC then go to the following link:

https://www.cisco.com/c/en/us/training-events/training-certifications/exams/current-list/devasc-200-901.html

My last advise to you is to go ahead and start your python learning, you will see the relief you will get after you start using the codes you write. seeing progress through your study is amazing as long as you are doing it the right way, Python and any other programming language is to practice while studying and make mistakes because you will learn the most from your mistakes.

In my next posts, I will be sharing my progress and some of the codes that I practiced on while studying.

 

So here are links to my study resources in my DEVNET journey:

1. David Bombal's video series

2. Cisco OCG DEVASC https://www.ciscopress.com/store/cisco-certified-devnet-associate-devasc-200-901-official-9780136642961

3. Network Programmability and automation fundamentals  https://www.ciscopress.com/store/network-programmability-and-automation-fundamentals-9781587145148

4. Cisco Learning Network DEVNET Study group https://learningnetwork.cisco.com/s/topic/0TO3i0000008jY5GAI/devnet-certifications-community

5. Cisco DEVNET Courses are also available https://developer.cisco.com

6. Video Course from Cisco Devnet https://developer.cisco.com/video/net-prog-basics/ 

I hope you find my post useful and motivating!


Samer R. Saleem




 

 

 

 



 

 


Saturday, June 26, 2021

Time Based Access Control List on Cisco Router/EIGRP

 In today's post, we will work on creating an Access Control List that works in specific time that we decide, this could be useful for a cases that you want to filter traffic according to that time you set 

 

In many cases you can use this time based ACL, so let's create a simple lab showing the use of it.

 

First, as usual we will use a simple topology because there is no need to make thing complicated, all you need is three routers or layer3 switches

 

In my lab, I will be using three Cisco Routers with 15.4T IOS version.



 

 Topology below:

 



 In the topology above, R1 hosts 9, 10, 11 will be advertised as a loopback prefixes from R1.


we will filter the access for these hosts inbound to Site-B  on R3 to stop unwanted traffic after working hours to SVR5, SVR6, SVR7

 

 in my example, I will filter only one of the IP's for the sake of explanation to make sure the rest of hosts have reachability after the filtration.


After configuring EIGRP between the three sites, we can see the routing tables with prefixes for the advertised networks

on both sides.



 


 

 

 

 

 

 

 

 

 

 

 

 

 

 

 As you can see above, the host that we will filter is 130.130.130.3/32, we will configure any time that we like the policy 

to start working in it, then we will monitor our logs.


remember it is better to enable logs with the Access list that we will configure in order to see the hits on the policy for the matching

packets.



 Note: the Time based ACL will only be in extended Access Control lists and not in standard.


Now, it is time to define the time range that will be used in access list.


 Commands are:


time-range AFTER-WORK
 absolute start 08:25 26 June 2021

 absolute end 08:43 26 june 2021


the Access list configured as below:

 #ip access-list extended TIME
 #deny   ip host 130.130.130.3 any time-range AFTER-WORK log
 #permit ip any any time-range TIME log


apply it inboung on E0/1 or Router3 and check if its active:






here you go, we have hits on both lines, where we generated some ICMP packets sourced from 130.130.130.3/32

and the permitted log matches the other traffic which include EIGRP packets as well.






 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

As you can see, the packets not reaching the 5.5.5.5/32 SVR when the source of the ICMP is 130.130.130.3/32


 

 

 

 

 Here above you can see the logs generated by the hit on R3 for both the denied logs and permitted EIGRP packets.

Note: before the time range is activated, it should be seen as inactive as below:




 

 

 

 

 

Ok, please note that you must put end option to the time-range settings:

 

 #time-range AFTER-WORK
 #absolute end 08:42 26 June 2021

 

 which will put the ACL back to inactive state.


Ok, what about making this task automated? the answer is also by using time-range but with another option which is:





 

 

 

 

 

 

 

 

 

 

 

That was it, I hope you enjoyed this post!

 

 

 

Samer Rafid Saleem

 

 

 

 

 

Saturday, June 19, 2021

Filtering even prefixes in third octet with Access Lists

 In this post, we will simulate a filtration scenario where you are tasked to filter (Deny) subnets that has even numbers in the third octet.

we will use the following topology:


Three routers are enough to do the trick, they all working in IGP (OSPF) area 0, each router is using his Loopback0 as OSPF router-id.

all interfaces are enabled for OSPF, we will use R3 to advertise many loopback prefixes

10.150.1.1/32 ==> 10.150.10.1/32

You can of course consider R1 is branch office and R2 is where network security engineer applying filtration to prevent important sites (even 3rd octet subnets) from entering  to both (R2 and R1)

In order to do this, we will create a standard access list, in order to match prefixes and not extended access list.

R2:

#enable

#configure terminal 

#access-list 1 deny   10.150.0.0 0.0.254.255 log
#access-list 1 permit any log

 router ospf 1
 router-id 2.2.2.2
 network 0.0.0.0 255.255.255.255 area 0
 distribute-list 1 in Ethernet0/1
R2#

After we applied the distribute list, we will start getting logs on R2

R2#
*Jun 19 06:11:02.383: %SEC-6-IPACCESSLOGNP: list 1 denied 0 10.150.8.1 -> 0.0.0.0, 1 packet  
*Jun 19 06:11:02.384: %SEC-6-IPACCESSLOGNP: list 1 denied 0 10.150.6.1 -> 0.0.0.0, 1 packet  
*Jun 19 06:11:02.384: %SEC-6-IPACCESSLOGNP: list 1 denied 0 10.150.4.1 -> 0.0.0.0, 1 packet  
*Jun 19 06:11:02.384: %SEC-6-IPACCESSLOGNP: list 1 denied 0 10.150.2.1 -> 0.0.0.0, 1 packet  
*Jun 19 06:11:02.384: %SEC-6-IPACCESSLOGNP: list 1 denied 0 10.150.10.1 -> 0.0.0.0, 1 packet  
R2#


The above logs, shows the even 3rd octet prefixes being denied.

on the same router, you can issue the command: 

#clear ip access-list counters

you will see the permitted prefixes logs:


OK, now let's do a test on R1 to see if we can achieve reachability to the allowed/filtered prefixes:


 As you can see, ping to odd 3rd octet of the subnet 10.150.0.0/16 is allowed and ping is successful, while the even 3rd octet is not successful. and shows the letter (U.U.U) which indicates unreachable flag.

So, how did we do that using this wildcard (0.0.254.255)?

The answer is, since we use 255 to say match any, we mean here match any bit from 0-255

But once we remove the 1st bit, we changed this to match any bit except the 1st bit.

Once we done that, all numbers will be even and odd was excluded from the match process.

So for example: subnet 0 is matched and next subnet which is 1 will not be matched because the 1 bit is set to 0, which means its OFF, then subnet 2 will be matched, but 3 will not because you will not be able to add 2+1 bits because 1 is not enabled to be matched.

then, the access list will decide if you want to deny or allow based on your set option.


I hope this was useful!


Samer R. Saleem




Thursday, June 10, 2021

Allowing BGP MD5 authentication through Cisco ASA


Author: Samer R Saleem

We have the following scenario where BGP traffic between routers going through an ASA firewall will face a problem if you have an ASA in the middle of two BGP routers trying to peer and they both are using MD5 authentication.

We will create a lab and solve the issue on the firewall by allowing BGP to authenticate and form peering session between the routers, I will be posting in my labbing results and findings during this and the small topology I used EVE-NG community to simulate this case.

The diagram below is self-explanatory, two routers on the sides and an ASA in between, ip addresses are 192.168.1.0/24 on the left and 12.0.0.0/24 on the right side.

AS111 on R1 and AS222 on R2



you will need to configure the ASA interfaces as below:

G0/0 (ip address and nameif) which is as in the diagram above

G0/1 (ip address and nameif)which is as in the diagram above

Then configure both routers interfaces and ping to make sure ASA is reachable.

To provide reachability I will be using  EIGRP and once completed its adjacency process you will see R2 and R1 networks but they will not have reachability between them, so you will need to add ICMP into ASA firewall inspection:

#class inspection_default

#inspect icmp 

After this, you will have reachability between R1 loopback0 to R2 loopback0, here we start configuring eBGP:

R2:

router bgp 222

bgp log-neighbor-changes

network 200.200.200.200 mask 255.255.255.255

neighbor 1.1.1.1 remote-as 111

neighbor 1.1.1.1 password 12345

neighbor 1.1.1.1 disable-connected-check

neighbor 1.1.1.1 update-source Loopback0

R1:

router bgp 111

bgp log-neighbor-changes

network 100.100.100.100 mask 255.255.255.255

neighbor 2.2.2.2 remote-as 222

neighbor 2.2.2.2 password 12345

neighbor 2.2.2.2 disable-connected-check

neighbor 2.2.2.2 update-source Loopback0

Note: I have created two more loopbacks 100 and 200 in both R1 and R2 and advertised over BGP only, and disabled directly connected check on BGP.

You will see the session comes UP and prefixes appear in both BGP RIB tables.

However, once you add password authentication under BGP, you will start seeing the below logs:

R2(config-router)#

*Sep 11 08:54:44.093: %TCP-6-BADAUTH: No MD5 digest from 1.1.1.1(36963) to 2.2.2.2(179) tableid - 0

R2(config-router)#

*Sep 11 08:54:46.098: %TCP-6-BADAUTH: No MD5 digest from 1.1.1.1(36963) to 2.2.2.2(179) tableid - 0

R2(config-router)#

*Sep 11 08:54:50.106: %TCP-6-BADAUTH: No MD5 digest from 1.1.1.1(36963) to 2.2.2.2(179) tableid - 0

And now the BGP session is lost.

Diagnoses and Solution:

the reason for this is that, BGP is uses TCP 179 protocol, which is fine, but once authentication is used with MD5, ASA will strip the authentication which is TCP option 19


And the routers will not see the MD5 coming with connection attempt because it's being filtered by the firewall, so you will need to add the following part on the Cisco ASA:

1.first you need to create an extended ACL to match the traffic between the BGP routers

access-list bgp extended permit tcp host 1.1.1.1 host 2.2.2.2 eq bgp 

access-list bgp extended permit tcp host 2.2.2.2 host 1.1.1.1 eq bgp 

2.create TCP map to allow option 19

tcp-map allow-tcp-19

tcp-options range 19 19 allow

3.use the global policy map to match the class map BGP that we created to match traffic and apply our settings:

policy-map global_policy

class-map BGP 

match access-list bgp

class BGP

set connection random-sequence-number disable

set connection advanced-options allow-tcp-19

After this is done, you will see the bgp session UP again!

Check the logs again:

R2#

*Sep 11 09:14:59.477: %BGP-5-NBR_RESET: Neighbor 1.1.1.1 active reset (BGP Notification sent)

*Sep 11 09:14:59.477: %BGP-5-ADJCHANGE: neighbor 1.1.1.1 Up 

R2#

RFC about Protection of BGP Sessions via the TCP MD5 Signature Option

https://www.ietf.org/rfc/rfc2385.txt

To download the lab go to my post on Cisco learning Network you will find as a zip attached:

EVE-FILE


I hope this was useful!

Samer R. Saleem


Monday, June 7, 2021

Change Global Protect portal logo

 It is nice and good idea to replace the Global Protect logo to your company logo.

to be more professional and to give better impression about your company attention to details.


in this post, I will be showing you how to do that:

First of all you need to have global protect portal (web based VPN page) enabled.

go to : Network > Global Protect > Portals > General

As you can see  > you should have the interface (outside) and it's IP address 

under appearance: Portal Login Page is set to customized-page.html


Note, in your case you would not see the custom page in the drop list because you did not create it yet.

here is how to create this page:

Go to Device > Response pages >

you will find a list of pages used in your firewall, find and click on Global Protect Portal Login Page

then, select the "Default" and export as shown in the image below:


Once you downloaded it, you can open the ".html" page that you downloaded and edit with texteditor

as you can see below:

change the image source to a different source than the original one, in my case I'm recalling it from the link of a server lab, you can see the highlighted link below:


 once you finished editing this page, save it as (NAME.html)

Go again to Response Pages and select Global Protect portal login page:



Now you can go to the first step and select the new customized page from the drop list and commit your configs.

Hope this was useful!

Samer R. Saleem

Thursday, June 3, 2021

Security Policy Testing on PaloAlto Firewall

Firewalls in an active working environment will always be susceptable to change in configuration, hosts will be added to new policies and removed later, or added to one or more of the security policies at the same time, this of course will cause some problems at some point, especially if the rule hits were not as intended to be and some server or IP will lose access to internet or DMZ.

Here we will see how to find out if the same host was added to one or more security rules by simulating a trace which is similar to packet tracer of the Cisco ASA firewalls to some extent. 

How to test your configuration for a specific host to see in which policy it might be?

What if the host was used in more than security policy?

 

Security Policy Testing on PaloAlto Firewall

How to know If there is conflict for the same host?

 

There are two ways for the same test.

A.    Go to Device > Troubleshooting

B.    Go to Security Policy > Select “Test Policy” which can be found at the bottom bar

 

Both of these options will do the same thing.

 

So let’s see how it works.

Using option B, we are going to press on the test policy option which you can see "in the right corner of the screen"

we will start filling the details:

1. Source interface (Inside, outside, DMZ) in our case it is (Inside)

2. Destination Interface (Insidde, outside, DMZ) in our case it is (Outside)

3. Select the protocol type (TCP, UDP, ICMP) for this example we are going to use (ICMP)

once you selected the ICMP, the destination port is no longer needed.


Here as you can see below, our source will be a host that was added previsouly to a security rule named (DIRECT-INTERNET-ACCESS) and the ip address of this host is (10.211.112.2)

The destination in our policy is Google (8.8.8.8)


there is another useful option that can be seen in the screen below:

"Show all potential match rules until first allow rule"


once you entered all details as the in the screen, you can scroll-down to "excute" option and press it, right away you will see the "test result" showing the matching rule "Direct-Internet-Access"

Now you can select this rule and check out it's "result details" tab on the right.

scroll-down to the end, now you can see if the Action is "Allowed or Denied"

Type is "interzone or universal" 




You can then see if there is duplicate for the same host IP with another rule that might cause a hit and prevent the host from working in another intended way, and resolve the misconfiguration.



Hope this was useful!


Samer R. Saleem



Monday, May 31, 2021

Installing PaloAlto Certificate on Mobile phones or Computers - Traffic decryption

 As you all know, controlling smart phones in a Network could be a challenge. 


Especially these day many mobile applications works with  the secured version of HTTP > (HTTPS)

As a solution that might be useful for many of us is URL filtering.

Since Firewalls need to make SSL scanning or (Decryption) for HTTPS traffic to do that because as you know, HTTPS is encrypted.

you can do the decryption on the firewall which of course will have some impact on your firewall resources, but if you don't have a lot of users to apply decryption policy then that should be fine.


In my post, I'm going to apply decryption policy using PALOALTO firewall, which I think is a great firewall.

you can review the creation of the policy from an older post here on my blog on this link >

https://pbitccie.blogspot.com/2020/08/ssl-decryption-policy-on-paloalto.html


however, in regards to exporting and installing certifications on your devices, I will post here:

1. In order to export the certification you need to go to Device > Certificate management > certificates


2. select the certificate which was generated by the LAB Firewall and in my case it is showing with the firewall inside IP address of 10.211.250.253

3. choose the export option at the end of the page


4. you will get a drop list option from the window that will open and you will need to select the option

(.PEM or .DER) one of them is applicable to Windows and IPHONE, and the second is for Android based smart phones.



5. press OK and the certificate will be downloaded to your local disk.

now you need to import on your target device (PC, IPHONE, ANDROID phone)

NOTE: on PC you will need to install as trusted certificate.

on IPHONE you can email it to yourself and download it to your iphone then install from Settings> General > Profiles

on Android devices it can be installed from Advanced Wifi settings (look it up in google)


Once this all done, you can check if the users traffic is getting decrypted by the Firewall

go to > Monitor > Decryption


Or Go to > URL filter option and check the traffic for the filtered traffic there

NOTE: make sure the user does not have a direct access to internet and his IP is available in decryption policy and in Access Policy it must be applied with the URL filter options that you need (Allowed or Denied)


I hope this was helpful to you!


Thanks

Samer R. Saleem




Friday, May 14, 2021

Enable sending PaloAlto Firewall logs to Email Account

 If you are using PALO-ALTO Firewalls, which they are great products according to my experience, you would not want to be connected all the time to check events/threats and monitor the everything all the time.

this would be time waste and of course you will not get better benefits from sitting the whole time in front of the screen.

 

Other way is enabling log forwarding to an external receiver.

the options available to forward the logs are as below:

1. SNMP

2. EMAIL

3. SYSLOG

4. HTTP

Creating Log forwarding, select the option and click on ADD:













Go to Objects > Log Forwarding > Add

Now add the information below:












Select from the Log type drop list> I'm selecting threats which will check vulnerabilities and Viruses and File checking and this of course will include Wildfire submissions as you can see in my email list below






A great option to use here will be EMAIL, you can send threats for a specific rule to your EMAIL Inbox.

For Example, an important rule like incoming rules used to allow emails coming inbound to Exchange server or security policy rule for the traffic allowed to hosts accessing internet.


 

you will be able to add the option to get alerts for threats coming in emails for example.

here is how to enable the Log forwarding to email:

you should see a drop list under the option Log Forwarding:



at the end this what you will start seeing in your email feed:

The type is threat, source IP and destination IP, the name of the policy which in my case is INCOMING-EMAIL, Logset which is the log type we chose as logging forward to email











 

 

 

 

 

 

 

 

 

 

 

 

you can do the same for any log forward enabled policy.

Hope this was useful!

#CCIE #NETWORKSECURITY #PCNSE #PCNSA #PALOALTONETWORKS

Samer R.Saleem



Thursday, August 20, 2020

Decryption Policy on PaloAlto Firewall


SSL Decryption is a feature that is used by the Firewalls and web gateways to inspect encrypted traffic such as HTTPS, the SSL decryption will make the firewall work as a proxying the user for the traffic to remote destinations and requests.

NOTE: SSL Scan/inspection can cause high impact on the Firewall resources and might cause network interruption if misconfigure.

 

 

With that been said, Firewall will for sure need to create two sessions

1.       From user to firewall

2.       From firewall to remote site

So, the firewall must have a certificate created in order to be installed on the user computer or Mobile device, to do that you will need to do the following:

Device > Certificate Management > certificates > Generate

 

the IP should be the inside interface IP address of the firewall.



 
 

Now this certificate will not be used until we implement the decryption policy.

To create the decryption policy we will:

Go to > Policies > Decryption > Add

Add the name, source zone and IP address, destination and then the action to decrypt the traffic matching source address.



Now that we have created the policy, the IP matched in it will not be able to go www.youtube.com unless the certificate created by the Firewall is installed, and below message will be seen once the firewall start inspecting the traffic, if you select “NO” then the traffic will not pass and will be dropped.


 
 
 

Ok, How to install the certificate on the computer or mobile?

What I have done is exporting the certificate I generated at the beginning, saved locally on my computer, and then imported it on the computer as trusted certificate.

Go to Device > Certificate management > certificates.

Select the certificate and then export .der file and then install this file on the device you need to make SSL inspection on.

 
I hope this was helpful!



Samer R. Saleem

Automating Network Configurations with Jinja2 and Python: A Step-by-Step Guide

 In this post, I worked on collecting a code that works with Jinja template. the nice thing in working with Jinja is that you can have basel...