To block an IP address you need to type the iptables command as follows:
- # iptables -A INPUT -s IP-ADDRESS -j DROP. Replace IP-ADDRESS with your actual IP address.
- # iptables -A INPUT -s 209.175.453.23 -j DROP.
- # iptables -A INPUT -s 209.175.453.23 -p tcp --destination-port 22 -j DROP.
.
Simply so, how do I block an IP address in Linux iptables?
How to block IP address on Linux server
- Step 1: Login as root user. Login to your server as root user ssh [email protected]
- Step 2: Add new Iptables rule. Enter the following rule to block an IP address from accessing your server iptables -A INPUT -s IP-ADDRESS -j DROP.
- Aternate option – Block access to a specific port.
- To revoke the drop rule:
Additionally, how do I block an IP from my server? Here's how to block an IP or an IP range on Windows server
- Press Win+R to start the Run dialog box.
- Type MMC -> press Enter.
- Inside the console -> click File -> Add/Remove Snap in.
- Select the Standalone tab -> click the Add button.
Also, how do I block a specific port in Linux?
Block Incoming Port To block the port only on a specific interface use the -i option. To block port only for given IP or Subnet use the -s option to specify the subnet or IP addess. Save the iptables for rules to be persistent across reboots. Save the iptables for rules to be persistent across reboots.
How do I whitelist an IP in Linux?
To Whitelist IP address:
- Click on "Firewall allow IP" to Whitelist the IP address.
- Enter the IP address which needs to be whitelisted.
- Click on change button and restart the firewall.
Related Question Answers
How do I flush iptables?
To flush a specific chain, which will delete all of the rules in the chain, you may use the -F , or the equivalent --flush , option and the name of the chain to flush. For example, to delete all of the rules in the INPUT chain, run this command: sudo iptables -F INPUT.
How do I check firewall rules in Linux?
How to list all iptables rules on Linux
- Open the terminal app or login using ssh: ssh [email protected]
- To list all IPv4 rules : sudo iptables -S.
- To list all IPv6 rules : sudo ip6tables -S.
- To list all tables rules : sudo iptables -L -v -n | more.
- To list all rules for INPUT tables : sudo iptables -L INPUT -v -n.