27
Effective Uses of Packet-Filtering Devices

Effective Uses of Packet- Filtering Devices. Filtering Based on Source Address: The Cisco Standard ACL 1.One of the things that packet-filtering technology

Embed Size (px)

Citation preview

Page 1: Effective Uses of Packet- Filtering Devices. Filtering Based on Source Address: The Cisco Standard ACL 1.One of the things that packet-filtering technology

Effective Uses of Packet-Filtering

Devices

Page 2: Effective Uses of Packet- Filtering Devices. Filtering Based on Source Address: The Cisco Standard ACL 1.One of the things that packet-filtering technology

Filtering Based on Source Address: The Cisco Standard ACL

1. One of the things that packet-filtering technology is great for is the

blocking or allowing of traffic based on the IP address of the source

system.

2. Some ways that this technology can be usefully applied are filters

blocking specific hosts (blacklisting), filters allowing specific hosts

(such as business partners), and in the implementation of ingress and

egress filters. Any of these examples can be implemented on a Cisco

router by using a "standard" access list.

Page 3: Effective Uses of Packet- Filtering Devices. Filtering Based on Source Address: The Cisco Standard ACL 1.One of the things that packet-filtering technology

Filtering Based on Source Address: The Cisco Standard ACL

3. The standard access list is used to specifically allow or disallow traffic

from a given source IP address only.

4. It cannot filter based on destination or port number. Because of these

limitations, the standard access list is fast and should be preferred

when the source address is the only criteria on which you need to

filter.

5. The syntax for a standard access list is as follows:

access-list list number 1-99 or 1300-1999 permit |deny source address

mask log

Page 4: Effective Uses of Packet- Filtering Devices. Filtering Based on Source Address: The Cisco Standard ACL 1.One of the things that packet-filtering technology

Filtering Based on Source Address: The Cisco Standard ACL

6. Notice that when ACLs were first created, the list number had to be

1--99. This range was expanded in IOS version 12.0(1) to include the

numbers 1300--1999.

7. The only way that the Cisco IOS can identify the list as a standard ACL

is if a list number in one of these two ranges is used.

Page 5: Effective Uses of Packet- Filtering Devices. Filtering Based on Source Address: The Cisco Standard ACL 1.One of the things that packet-filtering technology

Filtering Based on Source Address: The Cisco Standard ACL

8. The mask option is a required wildcard mask, which tells the router

whether this is a single host we are filtering or an entire network

range.

9. The log option can be appended to tell the router to specifically log

any matches of this filter.

10. These log entries can be saved in local memory or more appropriately

sent to a remote Syslog server.

Page 6: Effective Uses of Packet- Filtering Devices. Filtering Based on Source Address: The Cisco Standard ACL 1.One of the things that packet-filtering technology

Filtering Based on Source Address: The Cisco Standard ACL

12. The previously listed access list notation is entered in global

configuration mode and can be applied to the interface in the

interface configuration mode with the access-group statement, as

shown here:

ip access-group list number in|out

Page 7: Effective Uses of Packet- Filtering Devices. Filtering Based on Source Address: The Cisco Standard ACL 1.One of the things that packet-filtering technology

Filtering Based on Source Address: The Cisco Standard ACL

1. The access-group command is used to specifically apply an ACL to an

interface (by its list number) either inbound or outbound.

2. Only one access list can be applied in one direction (in or out) per

interface. This means a maximum of two applied ACLs per interface:

one inbound and one outbound.

3. One of the confusing concepts of router ACLs is the way that applying

filters "in" or "out" works.

Page 8: Effective Uses of Packet- Filtering Devices. Filtering Based on Source Address: The Cisco Standard ACL 1.One of the things that packet-filtering technology

Filtering Based on Source Address: The Cisco Standard ACL

4. This is confusing because people normally visualize "in" as traffic

moving toward their internal network and "out" as traffic moving

away from their network toward outside entities.

5. However, this premise does not necessarily hold true when talking

about the in and out keywords in Cisco router access lists.

6. Specifically, the keywords tell the router to check the traffic moving

toward (in) or away from (out) the interface listed.

Page 9: Effective Uses of Packet- Filtering Devices. Filtering Based on Source Address: The Cisco Standard ACL 1.One of the things that packet-filtering technology

Filtering Based on Source Address: The Cisco Standard ACL

7. In a simple dual-interface router, this concept is more easily

illustrated.

8. Let's assume you have an interface called e1 (hooked to your internal

network) and an external interface called s1 (hooked up to the

Internet, for example).

9. Traffic that comes into the s1 interface moves toward your internal

network, whereas traffic that goes out of the s1 interface moves

toward the Internet.

Page 10: Effective Uses of Packet- Filtering Devices. Filtering Based on Source Address: The Cisco Standard ACL 1.One of the things that packet-filtering technology

Filtering Based on Source Address: The Cisco Standard ACL

10. So far this seems to be pretty logical, but now let's consider the

internal e1 interface.

11. Traffic that comes into e1 moves away from your internal network

(toward the Internet), and traffic that goes out of e1 goes toward your

internal network.

Page 11: Effective Uses of Packet- Filtering Devices. Filtering Based on Source Address: The Cisco Standard ACL 1.One of the things that packet-filtering technology

Filtering Based on Source Address: The Cisco Standard ACL

12. if something should be blocked (or permitted, for that matter) coming

in from the Internet, it would make the most sense to block it coming

in to the s1 (outside) interface.

13. In addition, if something should be filtered leaving your network, it

would be best to filter it inbound on the e1 (inside) interface.

14. Basically, you should show preference to the in keyword in your

access lists.

15. Some specific exceptions to this rule exist, which involve certain

access list types (such as reflexive ACLs) that require being placed

outbound.

Page 12: Effective Uses of Packet- Filtering Devices. Filtering Based on Source Address: The Cisco Standard ACL 1.One of the things that packet-filtering technology

Filtering Based on Source Address: The Cisco Standard ACL

16. These examples often list the actual prompt for a router named

"router" to remind you of the command modes that the router will be

in when entering the various commands.

17. The following is an example of an actual filter that uses the previous

syntax and 190.190.190.x as the source network's IP address that you

want to deny:

router(config)#access-list 11 deny 190.190.190.0 0.0.0.255

Page 13: Effective Uses of Packet- Filtering Devices. Filtering Based on Source Address: The Cisco Standard ACL 1.One of the things that packet-filtering technology

Filtering Based on Source Address: The Cisco Standard ACL

19. This filter's list number is 11.

20. It denies any packet with a source network address of 190.190.190

with any source host address.

21. It is applied to the interface inbound, so it filters the traffic on the way

into the router's interface.

22. The command to apply the access list to your serial 1 interface would

be

23. router(config-if)#ip access-group 11 in

Page 14: Effective Uses of Packet- Filtering Devices. Filtering Based on Source Address: The Cisco Standard ACL 1.One of the things that packet-filtering technology

Filtering Based on Source Address: The Cisco Standard ACL

25. where we are in interface configuration mode for the interface to

which we are applying the access list, inbound.

Page 15: Effective Uses of Packet- Filtering Devices. Filtering Based on Source Address: The Cisco Standard ACL 1.One of the things that packet-filtering technology

The Cisco Wildcard Mask Explained

The wildcard mask is one of the least understood portions of the Cisco ACL

syntax. Take a look at the following example:

access-list 12 permit 192.168.1.17 0.0.0.255

In this case, 0.0.0.255 represents the wildcard mask.

It looks like a reverse subnet mask and represents the portion of the

listed IP address range to filter against the traffic in question.

Zeros mean, "Test this portion of the address," and ones mean, "Ignore

this portion of the address when testing."

Page 16: Effective Uses of Packet- Filtering Devices. Filtering Based on Source Address: The Cisco Standard ACL 1.One of the things that packet-filtering technology

The Cisco Wildcard Mask Explained

In our example, let's say a packet comes in with a source address of

192.168.2.27.

Because the first octet of the wildcard mask is a zero, the router compares the

first octet of the incoming packet to the value 192, listed in the access list.

In this case, they are the same, so the router continues to the second octet of

the wildcard mask, which is also a zero. Again, the second octet of the value of

the source address of the incoming packet is compared to the value 168.

Because they are also the same, the router continues to the third octet. Because

the wildcard mask specifies a zero in the third octet as well, it continues to test

the address, but the value of the third octet does not match, so the packet is

dropped.

Page 17: Effective Uses of Packet- Filtering Devices. Filtering Based on Source Address: The Cisco Standard ACL 1.One of the things that packet-filtering technology

The Cisco Wildcard Mask Explained

For the sake of example, let's continue to look at the fourth octet, even though in

actuality the packet would have been dropped at this point.

The wildcard's fourth octet is valued at 255. In binary, this equates to 11111111.

In this example, the value 0 in the access list does not match the value 27 of the

compared packet; however, because the wildcard wants us to ignore this octet,

the access list allows the packet to pass (assuming it hadn't failed on the

previous octet).

The concept might seem pretty easy with a wildcard value that deals with entire

octets, but it gets tricky when you need to deal with an address range that is

smaller than 255. The reality is that the router doesn't test octet by octet, but bit

by bit through each of the octets.

Page 18: Effective Uses of Packet- Filtering Devices. Filtering Based on Source Address: The Cisco Standard ACL 1.One of the things that packet-filtering technology

The Cisco Wildcard Mask Explained

What if you want to allow traffic from systems in the address range

192.168.1.16----192.168.1.31 only?

The first three octets of the wildcard are easy: 0.0.0. It's the last octet that is

difficult. The values between 16 and 31 are covered in the range 10000-11111.

To allow those values, you need to place zeros in your wildcard mask for the

portions that need to match exactly, and ones for the binary values that change.

Because the last four bits are the only bits that change in the desired range, the

wildcard mask reflects those four bits with ones. In binary, our wildcard mask is

as follows:

00000000.00000000.00000000.00001111

Page 19: Effective Uses of Packet- Filtering Devices. Filtering Based on Source Address: The Cisco Standard ACL 1.One of the things that packet-filtering technology

The Cisco Wildcard Mask Explained

Translated with our binary calculator, that is 0.0.0.15.

This wildcard mask works for any range of 15 addresses you are

comparing, so to make it work for 1631, you must properly reflect the

range in the IP address portion of the access list. Your final access list

looks like this:

access-list 10 permit 192.168.1.16 0.0.0.15

Page 20: Effective Uses of Packet- Filtering Devices. Filtering Based on Source Address: The Cisco Standard ACL 1.One of the things that packet-filtering technology

The Cisco Wildcard Mask Explained

zeros and ones, without interruption, as in the example listed previously.

In some cases, you need more than one ACL statement and wildcard

mask to cover a range of network addresses.

For example, if you want to block addresses in the range 232--255, you

need the command

access-list 110 deny ip 192.168.1.232 0.0.0.7 any

to block the range 232--239, and you also need to specify

access-list 110 deny ip 192.168.1.240 0.0.0.15 any

to block the range 240---255.

Page 21: Effective Uses of Packet- Filtering Devices. Filtering Based on Source Address: The Cisco Standard ACL 1.One of the things that packet-filtering technology

Blacklisting: The Blocking of Specific Addresses

One popular use of the standard access list is the "blacklisting" of particular host networks.

This means that you can block a single host or an entire network from accessing your

network.

The most popular reason for blocking a given address is mischief found by your IDS

For example, if your intranet web server should only be offering its information to your

business locations in the continental United States, and you are getting a lot of hits from a

range of IPs in China, you might want to consider blocking those addresses.

The blocking of address ranges is also a popular way to "band-aid" your system against an

immediate threat. For example, if one of your servers was being attacked from a certain IP

address, you could simply block all traffic from that host or network number

Page 22: Effective Uses of Packet- Filtering Devices. Filtering Based on Source Address: The Cisco Standard ACL 1.One of the things that packet-filtering technology

Blacklisting: The Blocking of Specific Addresses

A sample access list to block access from an outside address range would be

router(config)#access-list 11 deny 192.168.1.0 0.0.0.255

router(config-if)# ip access-group 11 in

where the network number of the outside parties to be blocked would be

192.168.1.0255. (Of course, this address range is part of the ranges reserved for

private addressing, and it's simply used as an example in this instance.) This access

list would be applied to the external router interface, inbound.

Page 23: Effective Uses of Packet- Filtering Devices. Filtering Based on Source Address: The Cisco Standard ACL 1.One of the things that packet-filtering technology

"Friendly Net": Allowing Specific Addresses

Another way you can use a standard access list is to permit traffic from a given IP

address. However, this is not recommended.

Allowing access to an address in this manner, without any kind of authentication,

can make you a candidate for attacks and scans that use spoofed addresses.

Because we can only filter on source address with a standard ACL, any inside

device with an IP address can be accessed. Also, it's impossible to protect

individual services on those devices.

If you need to set up access like this and can't do it through a solution that

requires authentication or some type of VPN, it is probably best to at least use

Page 24: Effective Uses of Packet- Filtering Devices. Filtering Based on Source Address: The Cisco Standard ACL 1.One of the things that packet-filtering technology

"Friendly Net": Allowing Specific Addresses

an access list that considers more than the source address.

This type of access may be suitable in situations requiring less security, such as

access between internal network segments.

For example, if Bob in accounting needs access to your intranet server segment,

a standard ACL would be a simple way to allow his station access.

Page 25: Effective Uses of Packet- Filtering Devices. Filtering Based on Source Address: The Cisco Standard ACL 1.One of the things that packet-filtering technology

Ingress Filtering

RFC 1918 pertains to reserved addresses. Private/reserved addresses

are ranges of IP addresses that will never be distributed for public

use.

The reserved ranges are as follows:

Class A: 10.0.0.010.255.255.255

Class B: 172.16.0.0--172.31.255.255

Class C: 192.168.0.0--192.168.255.255

Page 26: Effective Uses of Packet- Filtering Devices. Filtering Based on Source Address: The Cisco Standard ACL 1.One of the things that packet-filtering technology

Ingress Filtering

Private IP is used in internal network numbers, they are good candidates for

someone who is crafting packets or doing other malicious packet-

transmitting behavior, including denial of service.

Therefore, these ranges should be blocked at the outside of your network.

In addition, the loopback address 127.0.0.1 (the default address that all IP

stations use to "address" themselves) is another candidate for being blocked,

for the same reason.

While you are blocking invalid addresses, you should also block the multicast

address range 224.0.0.0239.255.255.255 and the invalid address 0.0.0.0.

Page 27: Effective Uses of Packet- Filtering Devices. Filtering Based on Source Address: The Cisco Standard ACL 1.One of the things that packet-filtering technology

Ingress Filtering

Following is a sample access list to accomplish this:

router(config)#access-list 11 deny 10.0.0.0 0.255.255.255

router(config)#access-list 11 deny 127.0.0.0 0.255.255.255

router(config)#access-list 11 deny 172.16.0.0 0.15.255.255

router(config)#access-list 11 deny 192.168.0.0 0.0.255.255

router(config)#access-list 11 deny 224.0.0.0 15.255.255.255

router(config)#access-list 11 deny host 0.0.0.0

router(config-if)# ip access-group 11 in