how to save iptables commands?
If I issue a command like this rather than write it in the iptables file:
iptables -A INPUT -i eth0 -p tcp --dport 1723 -j ACCEPT how do I get that command to be automatically scripted to the iptables file in /etc/sysconfig/iptables? |
If I understood you right
to save Code:
iptables-save >> savefile Code:
iptables-restore << savefile Code:
pre-up iptables-restore < savefile |
Quote:
|
Code:
iptables-save > /etc/sysconfig/iptables |
or you need it to be written immediately as soon as you press 'enter'?
maybe then Code:
ipt='iptables -A INPUT -i eth0 -p tcp --dport 1723 -j ACCEPT' ; eval $ipt ; echo $ipt >> /etc/sysconfig/iptables |
On a CentOS system, edit
/etc/sysconfig/iptables then to make your changes take effect iptables-restore < /etc/sysconfig/iptables This file exists in my Fedora system as well. |
Quote:
Code:
#/bin/bash |
What if you have already used a command like
iptables -A FORWARD -i eth0 -o ppp+ -j ACCEPT How do you get that written to the file just by saving it? |
Quote:
If you're asking about the command for addition of the lines to file then it is realised in script with $ipt >> /etc/sysconfig/iptables It simple adds the line at the end of that file. Or you'd like to have more difficult script that don't add commands that are already written? But if that line is not written yet then you do need to iptables-save > /etc/sysconfig/iptables |
On Centos
1. cp /etc/sysconfig/iptables /etc/sysconfig/iptables.YYYYMMDD_HHMM 2. vi /etc/sysconfig/iptables 3. service iptables restart (Strictly speaking iptables isn't a service, but the functionality is there to treat it as such) |
Using CentOS with Plesk? Plesk is a virus for Linux. So is CPanel.
|
All times are GMT -5. The time now is 12:19 PM. |