Iptables is a Linux kernel firewall that can be used to manage network traffic by setting up rules and policies. Here's how to configure Iptables on ECS Debian Server:
1. Update the package repository and install Iptables:
sudo apt update
sudo apt install iptables
2. Create a new Iptables rule file:
sudo touch /etc/iptables-rules
3. Open the Iptables rule file with a text editor:
sudo nano /etc/iptables-rules
4. Add the rules for incoming and outgoing traffic:
*filter
# Allow all outgoing traffic
-A OUTPUT -j ACCEPT
# Allow incoming SSH traffic
-A INPUT -p tcp --dport ssh -j ACCEPT
# Allow incoming HTTP and HTTPS traffic
-A INPUT -p tcp --dport http -j ACCEPT
-A INPUT -p tcp --dport https -j ACCEPT
# Block all other incoming traffic
-A INPUT -j DROP
COMMIT
These rules allow all outgoing traffic and incoming SSH, HTTP, and HTTPS traffic, but block all other incoming traffic.
5. Save and close the Iptables rule file.
6. Enable Iptables at boot time:
sudo touch /etc/network/if-pre-up.d/iptables
sudo chmod +x /etc/network/if-pre-up.d/iptables
sudo nano /etc/network/if-pre-up.d/iptables
7. Add the following content to the iptables file:
#!/bin/sh
iptables-restore < /etc/iptables-rules
exit 0
8. Save and close the iptables file.
9. Restart the network service:
Restart the network service:
Now, Iptables is configured on your ECS Debian server. You can verify the Iptables rules by running the following command:
sudo iptables -L
This will show you the list of rules that have been applied to your system. If you want to modify the rules, you can edit the /etc/iptables-rules file and then run the following command to apply the changes:
sudo iptables-restore < /etc/iptables-rules
Note: Be careful when configuring Iptables, as incorrect rules can block all incoming and outgoing traffic, which can result in loss of connectivity to your server.
63 posts | 14 followers
FollowAlibaba Clouder - September 30, 2018
Alibaba Clouder - July 15, 2019
Alibaba Clouder - August 22, 2018
Alibaba Clouder - August 23, 2018
francisndungu - May 29, 2019
Alibaba Clouder - November 9, 2020
63 posts | 14 followers
FollowAlibaba Cloud offers an accelerated global networking solution that makes distance learning just the same as in-class teaching.
Learn MoreMigrate to the cloud with your own IP addresses.
Learn MoreAn independent public IP resource that decouples ECS and public IP resources, allowing you to flexibly manage public IP resources.
Learn MoreConnect your business globally with our stable network anytime anywhere.
Learn MoreMore Posts by Dikky Ryan Pratama