index Previous Next



To configure the iptables to install a linux firewall like firestarter or in debian
iptables-persistent or other firewall like shorewall.
If your other network computer share the Internet connection the enable the ip_forward from the
/etc/sysctl.conf and then run the sysctl -p for the changes to take effect:
# Uncomment the next line to enable packet forwarding for IPv4
net.ipv4.ip_forward=1
Now run the command:
sysctl -p
To list your current iptables rules run the command:
iptables -l
To print your current iptables rules run the command:
iptables-save
Or save to a file:
iptables-save > iptables-config
To delete all the iptables rules run the command:
iptables --flush
These are the already configured rules for a network running the web and mail server,with forwarding and masquerading
enabled,
run the restore command to restore from the file rules
:
iptables-restore < rules
To restore the iptables rules at boot put a script firewall in the /etc/init.d with these lines:
#! /bin/sh
### BEGIN INIT INFO
# Provides: custom firewall
# Required-Start: $remote_fs $syslog $network
# Required-Stop: $remote_fs $syslog $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: firewall initscript
# Description: Custom Firewall
### END INIT INFO
/sbin/iptables-restore < /etc/iptables/rules
and then run the:
update-rc.d -f firewall defaults
This will restore the iptables rules in each boot, remember to put the rules in the /etc/iptables
dir.
These are all-in-one-rules iptables commands to run one by one.
