Skip to main content

How to Configure a Router to block websites with Access-List

Here are the simple steps to follow to block a website to the user who are accessing Internet through your Router
Step 1: Configure a DNS server

Let’s say we want to block access to the creatively named www.block-site.com. We don’t know the IP address, and we don’t want to know it. When we configure the Access List in the router—the Cisco IOS can look it up and fill it automatically.
To do this, we need at least one DNS server configured on the router. To configure a DNS server, use the ip name-server command. Here’s an example:
Router(config)# ip name-server 1.1.1.1 2.2.2.2
In this case, we configured a primary and a backup DNS server for the router to use to resolve DNS names. This doesn’t affect any traffic flowing through the router; the router will use these DNS servers when we ping a Web server by name. Here’s an example:
Router# ping www.khatrinetworks.blogspot.com
Translating “www.khatrinetworks.blogspot.com”…domain server (1.1.1.1) [OK]
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 216.239.113.101, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/4 ms
Router#
In this example, the router used the domain name server we specified (i.e., 1.1.1.1) to resolve the DNS name. It successfully translated the DNS name to 216.239.113.101.
If we hadn’t already specified a DNS server, then the router would have returned something like the following:
Translating “www.khatrinetworks.blogspot.com”…domain server (255.255.255.255)
% Unrecognized host or address, or protocol not running.
Step 2: Create the ACL
To actually block the undesirable Web site, we need to create an access control list (ACL) to define exactly what we want to block. Here’s an example:
Router(config)# access-list 101 deny tcp any host www.block-site.com eq www
 Translating “www.block-site.com”…domain server (1.1.1.1) [OK]
Router(config)# access-list 101 permit ip any any
(Do not forget this permit tcp any any, As you know otherwise all web traffic will be denied)
This ACL denies all Web traffic from any source going to the specified Web site. After blocking that traffic, it will also allow all other Web traffic from any source to any destination. Finally, because of the implied deny, it will deny all other traffic.
What if you want to determine which IP addresses are trying to go to the blocked Web site? You can log this information using the log keyword. Here’s an example:
Router(config)# access-list 101 deny tcp any host www.block-site.com eq www log
Step 3: Avoid this
Here’s one issue to keep in mind. After we entered the first line of the ACL above, notice how the router used the DNS server to resolve the DNS name. It then replaced the IP address that the hostname resolved to in the ACL. Here’s a closer look at the configuration:
Router# sh run
inc access-list 101
access-list 101 deny tcp any host 66.116.109.62 eq www
This is a nice feature, but it can be problematic for a couple of reasons. First, the IP address entered is only the first IP address that the DNS server responded to. If this is a large Web site that has multiple servers (such as a search engine), the ACL only contains the first IP address that the DNS server responded with—you’ll need to manually block the other IP addresses. Here’s an example:
C:\> nslookup www.google.com
Server: DNSSERVER
Address: 1.1.1.1
Non-authoritative answer:
Name: www.google.com
Addresses: 64.233.167.104, 64.233.167.147, 64.233.167.99
Aliases: www.google.com
In addition, if the IP address of the blocked Web server changes, your ACL will remain the same. You would need to manually update the ACL.
Step 4: Apply the ACL
Just because we’ve created the ACL doesn’t mean the router is actually using it—we still have to apply the ACL. We created this ACL with the assumption that it’s blocking traffic from our local LAN that’s going out to the WAN (i.e., the Internet). That’s because we formatted the ACL with source then destination.
Because of this design, we need to apply the ACL in the OUTBOUND direction on the router. Here’s an example:

Router(config)# int serial 0/0
Router(config-if)# ip access-group 101 out
That is it… Your have successfully blocked the www.block-site.com

Comments

Popular posts from this blog

How to import Putty Saved Connections to mRemoteNG

Just started using mRemoteNG and its being very cool to connect to different remote connection with different protocols e.g Window Remote Desktop, VNC to Linux, SSH, HTTP connection etc. from a single application. As new user I configured some remote desktop connection which was quite easy to figure out. But when I wanted to add SSH connections, it came in my mind to import all of the saved connections in the putty. But I couldn't figure it out how can it be done, though it was quite easy and here are the steps. Open your mRemoteNG Create a folder if you want segregation of multiple networks Create a new connection Enter the IP address of remote server under connection in Config pane Under the config pane, select protocol " SSH version 2 ".  Once you select protocol to SSH version 2 you are given option to import putty sessions, as shown in the snap below. In the above snap, I have imported CSR-AWS session from my saved sessions in Putty.

Authoritative DNS Servers Delegation and Internal DNS Explained

DNS (Domain Name System) plays a critical role in how users and systems find resources on the internet or within internal networks. Whether it's managing an internal domain in an enterprise or delegating parts of a domain for traffic distribution, DNS setups vary widely depending on needs. In this blog post, we’ll break down the different types of DNS setups, including authoritative DNS servers, DNS delegation, and how internal DNS functions within organizations. 1. Authoritative DNS Server An Authoritative DNS server is the final source of truth for a specific domain. When someone queries a domain (e.g., example.com ), the authoritative DNS server for that domain holds the DNS records (A records, CNAME, MX, etc.) and responds with the corresponding IP address. Key Points: Who can host it? Authoritative DNS servers are often hosted by domain registrars (e.g., GoDaddy, Namecheap) or cloud DNS providers (e.g., AWS Route 53, Cloudflare). However, organizations can also host their ...

BGP MED: Managing Inbound Traffic with Multi-Exit Discriminator

The Multi-Exit Discriminator (MED) is used in BGP to control inbound traffic into your AS. It tells a neighboring AS which entry point into your network it should prefer when there are multiple links between your AS and the neighboring AS. The lower the MED value , the more preferred the path. MED is only honored between the same neighboring AS . Example Scenario : You are connected to ISP1 via two routers, CE1 and CE2 , and want to control which router ISP1 uses to send traffic into your AS. Network Topology : CE1 (connected to ISP1): 10.0.1.1/30 CE2 (connected to ISP1): 10.0.2.1/30 iBGP Router (Internal) connected to both CE1 (10.0.1.2/30) and CE2 (10.0.2.2/30). Configuration on CE1 (Lower MED, More Preferred) : Create a route map to set the MED to 50 for CE1: route-map SET_MED permit 10 set metric 50 Apply this route map to the neighbor in the BGP configuration for CE1: router bgp 65001 neighbor 10.0.1.1 remote-as 65000 neighbor 10.0.1.1 route-map SET_MED out Configuratio...