Restricting Internet Access for Specific Hosts Using MAC‑Based ACL on a Router
This guide explains how to configure a router to block selected LAN hosts from accessing the Internet by applying source‑MAC‑address based ACLs while still permitting those hosts to reach the gateway, using VLAN, traffic classifiers, and traffic policies.
The network diagram (Figure 1) shows a router acting as the enterprise gateway; internal users access the Internet through this router. Because the target hosts may change IP addresses, restricting them by IP is ineffective, so the recommended solution is to limit access based on source MAC addresses, allowing the hosts to reach the gateway but not the external Internet.
Operation Steps
Router Configuration
sysname Routervlan batch 10acl number 3001 // create numbered ACL 3001rule 1 permit ip destination 10.1.1.0 0.0.0.255 // allow traffic to gateway address 10.1.1.0/24traffic classifier gate operator andif-match acl 3001 // match ACL 3001traffic classifier mac1 operator andif-match source-mac 0015-c50d-0001 // match source MAC 0015-c50d-0001traffic classifier mac2 operator andif-match source-mac 0015-c50d-0002 // match source MAC 0015-c50d-0002traffic classifier mac3 operator andif-match source-mac 0015-c50d-0003 // match source MAC 0015-c50d-0003traffic behavior p1permit // allow traffictraffic behavior d1deny // deny and discard traffictraffic policy myqos // define traffic policy named myqosclassifier gate behavior p1 // bind classifier gate to behavior p1classifier mac1 behavior d1 // bind classifier mac1 to deny behaviorclassifier mac2 behavior d1 // bind classifier mac2 to deny behaviorclassifier mac3 behavior d1 // bind classifier mac3 to deny behaviorinterface Vlanif10ip address 10.1.1.1 255.255.255.0traffic-policy myqos inbound // apply myqos policy inbound on the interfaceinterface Ethernet2/0/0port link-type trunk // set interface as trunkport trunk allow-pass vlan 10 // allow VLAN 10 on trunkVerify Configuration
Execute display traffic policy user-defined to view the applied traffic policy details.
On a restricted host, you should be able to ping the gateway address but not any IP address outside the LAN.
Configuration Notes
Ensure the interface connecting the switch and router is configured as a trunk and includes VLAN 10.
Because packets are matched against traffic classifiers in order, when creating the myqos policy you must first configure the classifier and behavior that allow gateway access, then the classifier and behavior that block Internet access.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
