LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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
Senior Member
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, Fedora, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, Vsido, tinycore, Q4OS
Posts: 3,829

Rep: Reputation: 1735Reputation: 1735Reputation: 1735Reputation: 1735Reputation: 1735Reputation: 1735Reputation: 1735Reputation: 1735Reputation: 1735Reputation: 1735Reputation: 1735
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
Senior Member
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, Fedora, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, Vsido, tinycore, Q4OS
Posts: 3,829

Rep: Reputation: 1735Reputation: 1735Reputation: 1735Reputation: 1735Reputation: 1735Reputation: 1735Reputation: 1735Reputation: 1735Reputation: 1735Reputation: 1735Reputation: 1735
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 08:03 AM.

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