LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-28-2017, 09:56 AM   #1
eilis89
LQ Newbie
 
Registered: Apr 2017
Posts: 3

Rep: Reputation: Disabled
Question iptables configuration script


Hi everyone,

Im a complete newbie to iptables and Im Trying to create a script to edit the configuration of my iptables on a CentOS 2 legged firewall. I have a bridge network and a host only network.

Ive created a very basic script to switch on routing, set the default policies and to flush all existing rules.

the routing part is working fine but my iptables file is not changing at all after running my script. Any help would be greatly appreciated.


# Switch on routing
echo 1 > /proc/sys/net/ipv4/ip_forward

# Set default policies (-P), these rules will apply if no more specific rule exists
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT

# Flush all existing rules
iptables -F INPUT
iptables -F FORWARD
iptables -F OUTPUT
iptables -F -t nat

Thanks in advance!
 
Old 04-28-2017, 10:01 AM   #2
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,511

Rep: Reputation: 2656Reputation: 2656Reputation: 2656Reputation: 2656Reputation: 2656Reputation: 2656Reputation: 2656Reputation: 2656Reputation: 2656Reputation: 2656Reputation: 2656
Why would you expect running iptables commands to change a file?

Did I miss something?
 
Old 04-28-2017, 10:09 AM   #3
eilis89
LQ Newbie
 
Registered: Apr 2017
Posts: 3

Original Poster
Rep: Reputation: Disabled
Thanks for the reply, Should it not change the iptables file in /etc/sysconfig to reflect the changes you have made? As I said Im completely new to this, just presuming this file should change?
 
Old 04-28-2017, 10:14 AM   #4
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,511

Rep: Reputation: 2656Reputation: 2656Reputation: 2656Reputation: 2656Reputation: 2656Reputation: 2656Reputation: 2656Reputation: 2656Reputation: 2656Reputation: 2656Reputation: 2656
You can make as many changes as you want into the memory of the running instance. Nothing is written out to disk (as far as I know, I have not dived into the code) until you run iptables-save.


This is from memory, you might take time to google for /etc/sysconfig/iptables and see what you find.
 
Old 04-28-2017, 10:17 AM   #5
eilis89
LQ Newbie
 
Registered: Apr 2017
Posts: 3

Original Poster
Rep: Reputation: Disabled
ahhh ok that makes sense. I Will do Thanks for the help
 
Old 04-28-2017, 10:36 AM   #6
r3sistance
Senior Member
 
Registered: Mar 2004
Location: UK
Distribution: CentOS 6/7
Posts: 1,375

Rep: Reputation: 217Reputation: 217Reputation: 217
What version of CentOS are you running? looks like you said CentOS 2, anything older than the latest version of CentOS 6 is heavily out of date and without security patching.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
iptables-save, iptables-restore, how to set up them in some script sarajevo Linux - Networking 1 03-24-2008 11:39 PM
Iptables (with masq) troubleshooting, very simple script attached script and logs. xinu Linux - Networking 13 11-01-2007 04:19 AM
iptables configuration props666999 Linux - Security 3 08-28-2005 02:32 PM
IPTables Configuration shaileshjain Linux - Networking 2 04-07-2005 12:16 AM
My iptables script is /etc/sysconfig/iptables. How do i make this baby execute on boo ForumKid Linux - General 3 01-22-2002 07:36 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:21 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration