Convert iptables line to command-line syntax for CSF bash script

This is the question about command-line iptables syntax. I have the following chains in /etc/sysconfig/iptables

# Generated by iptables-save v1.4.21 on Fri May 22 07:51:03 2015 *nat :PREROUTING ACCEPT [0:0] :POSTROUTING ACCEPT [0:0] COMMIT

but I need them to write to bash CSFPRE.SH for CSF firewall, so they should be in a command-line like

iptables -t nat -I POSTROUTING -s -o br0 -j SNAT --to-source


iptables -A FORWARD -s -m state --state NEW -j ACCEPT

But with the lines above I have a stumbling block. I already tried something like

iptables :PREROUTING ACCEPT [0:0] iptables -t nat -I :PREROUTING ACCEPT [0:0]

but no success.



iptables: Bad built-in chain name.

So still not a solution. Thanks in advance for any hint else to try

-------------Problems Reply------------

After some tests my solution was

iptables -t nat -P PREROUTING ACCEPT
iptables -t nat -P POSTROUTING ACCEPT

Category:bash Views:25 Time:2019-03-21
Tags: bash iptables

Related post

  • Does anyone know the exact Command Prompt syntax for copying my E drive to my H drive (thum drive) using Command Prompt? 2015-02-22

    Original title: Help/ Help Windows 7 shutdown need to back up Hello, This is my first time posting here. I had 2 rootkit infections and during the removal process I accidentally un-installed Internet Explorer and rebooted. Now I am unable to get to s

  • Command inside if statement of bash script 2011-03-11

    I have the following line as part of a much bigger bash script: if [ `packages/TinySVM-0.09/bin/svm_learn 2>&1| grep TinySVM | wc -l | cut -c0-7 | sed 's/^ *//g'` -eq 1 ] upon running the script, I get: ./ line 219: [: -eq: unary op

  • Latest DNG converter not working in command-line mode 2012-03-07

    Today I downloaded Adobe's latest DNG converter. It is failing with both .NEF and .CR2 files when run in command-line mode. It does appear to work in GUI mode. The switches+arguments I've used for my tests are: -u -e -p1 filename.CR2 (or filename.NEF

  • DNG converter: what's the command line to "Skip source image if exists" option? 2013-08-25

    I'm using Adobe DNG Converter to convert more then a Million of raw images in thousands of diferent folders. It is working well, but first I must prepare and rename with a script some of the folders and then collect all the paths to a xml f

  • How to convert accented chars from command line to wstring? 2013-07-09

    I'm trying to implement an application where I would like users to enter accented chars on the command line. What I'm trying to do is to convert the char array into a vector of wstring. I'm on Linux. Here is what I got so far: #include <vector>

  • VB.NET - Read lines from command line to Windows form possible? 2010-06-09

    Hey Overflow, I have an application which serves as a user interface for a spartan/command line program. I have the program running on a separate process, and my application monitors it to see if it is responding and how mush CPU it is utilising. Now

  • How to open source file in IDE on a certain line through command line 2011-08-31

    I'm just wondering if there is some IDE command line parameter which would open a source file on a specified line (in the current view) ? I know this is probably too much to publish as a command line parameter, but it would be great for my Assert log

  • Sort subgroups of lines with command-line tools 2009-07-22

    I've been trying to find a way of sorting this with standard commandline tools, bash, awk, sort, whatever but can't find a way apart from using perl or similar. Any hint? Input data header1 3 2 5 1 header2 5 1 3 ..... ..... Output data header1 1 2 3

  • List of strings (multiple lines) as command line input in Java 2011-05-05

    I am trying to do an assignment for school and I don't know how to deal with the input. I have provided a link below for context on the assignment:

  • is there a simpler way to update a Mongodb collection in just one line (in command line)? 2011-07-25

    right now, i do this in command line: var obj = db.mycollect.find({id="231412"}); = 'new value';; 3 lines of code.. is there a simpler way to do this? e.g. db.mycollect.find({id=12345}).save({abc:'new value'}); --------------Soluti

  • installing flashplayer command on fedora14 for php-cgi scripts 2011-04-01

    I'm trying to install a video convertion tool and one of the dependencies is to have flashplayer in command line. i've already done this yum install flash-plugin with result Package flash-plugin- already installed and latest ve

  • How to atomically print lines from multiple background processes in a bash script? 2011-07-06

    In a bash function I'm writing I start multiple remote commands via ssh, and have them run in separate background processes. Each of these processes produces many lines of text, which are merged together and then sorted. My problem is that sometimes

  • Unknown Error for a bash script! 2010-11-21

    So I have a perl script which takes in 2 arguments. a directory leading to the '.txt' files I am interested in searching through a file that has words in it which I have converted to an array. Perl file ( #!/usr/bin/perl use strict; u

  • Does netbeans support coloring for .sh (bash) scripts? 2009-10-28

    I use netbeans 6.8 beta and when i load .sh (bash) file it's not colored at all. i can add a new file association for the .sh extension but it doesn't seem that there is a known associated mime type. --------------Solutions------------- I have not tr

  • Run command with space characters in bash script 2011-01-10

    I have a file that contains a list of files: 02 of Clubs.eps 02 of Diamonds.eps 02 of Hearts.eps 02 of Spades.eps ... I am attempting to mass-convert these to png format in several sizes. The script I am using to do this is: while read -r line do for

  • Reliable way for a bash script to get the full path to itself? 2011-01-23

    I have a bash script that needs to know its full path. I'm trying to find a broadly-compatible way of doing that without ending up with relative or funky-looking paths. I only need to support bash, not sh, csh, etc. What I've found so far: The accept

  • how do i start commands in new terminals in BASH script 2011-03-25

    my bash script reads in a few variables and then runs airodump on my home network. I would like to keep the window with airodump running and open some new terminals to run other commands for network discovery while the airodump screen is open (so i c

  • command not found error in bash script 2011-04-12

    I have written a bash script. It basicaly gets three paths based on input parameters and then then gets the imagename/filename in the path. Something like: I provide: AA=/home/user Then it uses the find command to get /home/user/dir2/images/dir/tellm

  • Looking for a bash script to run a program with different inputs on linux server 2011-01-03

    I knew how to write that bash once, but I can't figure it out anymore. As the title says, it should be script aimed at running on a Linux server. My goal is to do those commands without having it typed again and again. (I'm chaining the input files i

  • Looking to get the env vars of a PID in BASH for a BASH script 2009-07-29

    Any way to do this? I have a script that exports a few vars and runs a component. I'm looking to find out the actual values of some of these vars while the process is running. (Which applies here, because I'll be incorporating those values into anoth

  • How to put a variable in the path of a command being executed in a Bash script 2014-01-02

    presently I'm working on a Bash script, and I am having trouble with writing a particular portion of the script. Basically I read in an appName using the read command in the bash script, and then I want to run a command with the appName variable in t

  • Interacting with iptables via the command line 2010-11-07

    I'm trying to create a Java program that is a front-end for iptables. To accomplish this, I'm using Java's Process class and pass commands. I'm wondering if I'm going about it correctly in general. For example, here is a selection of commands that re

  • What is a good way to match a part of a line using command line tools? 2010-06-07

    I want to match a part of a line for example in the sentence: "The super id=42 or something." I want to return the number 42. echo "The super id=42 or something" | grep -o 'id=[0-9]+' | sed 's/id=//' Would return the correct answer, but is there a mo

  • sed - append to next line using command line 2012-03-17

    I wish to append " dddd" to the next line whenever I encounter "=" in a textfile. This command sed -i '/=/s|$| dddd|' *.krn is close to what I am looking for as it appends to the current line where "=" is. How can I append to the next line instead? -

Copyright (C), All Rights Reserved.

processed in 0.116 (s). 12 q(s)