0. query the existing iptables-S [chain]. for example, for the input class set in 1, to query, enter iptables-SINPUT to delete the existing settings iptables-D [chain] [chain-num, chain-num indicates the number of rows in the query result. 1. the MAC address is blocked. the MAC address is XX: XX. all communication between hosts: IP0. query existing settings.
Iptables-S [chain]
For example, for the input class set in 1, to query, enter iptables-S INPUT
Delete existing settings
Iptables-D [chain] [chain-num]
It can be used in combination with the query. chain-num indicates the number of rows in the query results.
1. stop all communications between hosts whose MAC address is XX:
Iptables-a input-m mac -- mac-sourceXX: XX-j DROP
2. allow the MAC address to be XX: XX host to access port 22:
Iptables-a input-p tcp -- destination-port22-m mac -- mac-source XX: XX-j ACCEPT
3. allow communication between hosts whose IP address is 192.168.1.21 and whose MAC address is XX: XX, and reject other hosts:
Iptables-a input-s 192.168.1.21-m mac -- mac-source XX: XX-j ACCEPT
Iptables-P INPUT DROP
4. you can write a script to restrict MAC:
Iptables-P FORWARD DROP
For mac in $ (cat ipaddressfile); do
Iptables-a forward-m mac -- mac-source $ mac-j ACCEPT
Done
Enter man 8 iptables in the terminal to query the iptables user manual.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service