Example for Configuring Packet Filtering Based on the Server Port Number
Networking Requirements
As shown in Figure 7-3, the enterprise office area connects to the server area through SwitchB, the FTP server and email server belong to the same network segment, and the web server belongs to another network segment.
It is required that the enterprise R&D department and administrative department access only the FTP server.
Configuration Roadmap
The configuration roadmap is as follows:
- Configure SwitchB to differentiate traffic from the FTP, web, and email servers based on the port number and network segment.
- Configure SwitchB to discard traffic from the web and email servers so that the R&D department and administrative department can access only the FTP server.
Procedure
- Create VLANs and configure interfaces on SwitchA, SwitchB, and switches in the enterprise office area to implement network connectivity. The configuration details are not mentioned here.
- Configure ACLs.
# Create ACL 3001 on SwitchB, and configure rules in ACL 3001 to permit traffic from the web server based on the network segment of the web server and traffic from the email server based on the network segment and port number of the email server.
[~SwitchB] acl 3001 [*SwitchB-acl4-advance-3001] rule permit ip source 192.168.2.1 24 [*SwitchB-acl4-advance-3001] rule permit tcp source-port eq pop2 source 192.168.1.0 24 [*SwitchB-acl4-advance-3001] quit [*SwitchB] commit
- Configure a traffic classifier.
# Create a traffic classifier named c1 on SwitchB and reference ACL 3001 in the traffic classifier.
[~SwitchB] traffic classifier c1 [*SwitchB-classifier-c1] if-match acl 3001 [*SwitchB-classifier-c1] quit [*SwitchB] commit
- Configure a traffic behavior.
# Configure a traffic behavior named b1 on SwitchB and define the deny action.
[~SwitchB] traffic behavior b1 [*SwitchB-behavior-b1] deny [*SwitchB-behavior-b1] quit [*SwitchB] commit
- Configure a traffic policy and apply the traffic policy to 10GE1/0/1 in the inbound direction.
# Create a traffic policy named p1 on SwitchB and bind the traffic policy to the traffic classifier and traffic behavior.
[~SwitchB] traffic policy p1 [*SwitchB-trafficpolicy-p1] classifier c1 behavior b1 [*SwitchB-trafficpolicy-p1] quit [*SwitchB] commit
# Apply the traffic policy p1 to 10GE1/0/1 in the inbound direction.
[~SwitchB] interface 10ge 1/0/1 [~SwitchB-10GE1/0/1] traffic-policy p1 inbound [*SwitchB-10GE1/0/1] quit [*SwitchB] commit [*SwitchB] quit
- Verify the configuration.
# Check the ACL configuration.
<SwitchB> display acl 3001 Advanced ACL 3001, 2 rules ACL's step is 5 rule 5 permit ip source 192.168.2.0 0.0.0.255 (0 times matched) rule 10 permit tcp source 192.168.1.0 0.0.0.255 source-port eq pop2 (0 times matched)
# View the traffic classifier configuration.
<SwitchB> display traffic classifier c1 Traffic Classifier Information: Classifier: c1 Type: OR Rule(s): if-match acl 3001
# Check the traffic policy configuration.
<SwitchB> display traffic policy p1 Traffic Policy Information: Policy: p1 Classifier: c1 Type: OR Behavior: b1 Deny
Configuration Files
SwitchB configuration file
# acl number 3001 rule 5 permit ip source 192.168.2.0 0.0.0.255 rule 10 permit tcp source 192.168.1.0 0.0.0.255 source-port eq pop2 # traffic classifier c1 type or if-match acl 3001 # traffic behavior b1 deny # traffic policy p1 classifier c1 behavior b1 precedence 5 # interface 10GE1/0/1 traffic-policy p1 inbound # return