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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
04-28-2017, 09:56 AM
|
#1
|
LQ Newbie
Registered: Apr 2017
Posts: 3
Rep: 
|
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!
|
|
|
04-28-2017, 10:01 AM
|
#2
|
LQ Guru
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS, Manjaro
Posts: 6,358
|
Why would you expect running iptables commands to change a file?
Did I miss something?
|
|
|
04-28-2017, 10:09 AM
|
#3
|
LQ Newbie
Registered: Apr 2017
Posts: 3
Original Poster
Rep: 
|
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?
|
|
|
04-28-2017, 10:14 AM
|
#4
|
LQ Guru
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS, Manjaro
Posts: 6,358
|
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.
|
|
|
04-28-2017, 10:17 AM
|
#5
|
LQ Newbie
Registered: Apr 2017
Posts: 3
Original Poster
Rep: 
|
ahhh ok that makes sense. I Will do  Thanks for the help
|
|
|
04-28-2017, 10:36 AM
|
#6
|
Senior Member
Registered: Mar 2004
Location: UK
Distribution: CentOS 6/7
Posts: 1,375
|
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.
|
|
|
All times are GMT -5. The time now is 10:16 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|