LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 10-29-2010, 11:11 AM   #1
saiyen2002
Member
 
Registered: Dec 2006
Location: London, UK
Distribution: Centos, Fedora
Posts: 50

Rep: Reputation: 0
restart iptables from shell script hangs unitl button is pressed


I am trying to restart iptables from within a shell script. I guess I am missing something very basic since I stripped the shell script down to just the iptables restart command yet still I am having problems.

What happens is that the iptabels starts the restart process but hangs at 'Unloaded iptables modules:'.

It will stay there forever until any key is pressed, after that it completes the restart.

my file test.sh looks like this

Code:
#!/bin/bash

/etc/init.d/iptables restart
The output looks like the following

Flushing firewall rules: [ OK ]
Setting chains to policy ACCEPT: mangle filter nat [ OK ]
Unloading iptables modules:
[ OK ]
Applying iptables firewall rules: [ OK ]
Loading additional iptables modules: ip_conntrack_netbios_n[ OK ]

I am using Centos 5.4 2.6.18-164.el5. I am executing the script as root
 
Old 10-30-2010, 05:17 AM   #2
feinbein
Member
 
Registered: Jan 2010
Location: Norway
Posts: 76

Rep: Reputation: 12
Just a dirty hack but can you try instead:
Code:
#!/bin/bash

/etc/init.d/iptables stop
/etc/init.d/iptables start
 
Old 10-31-2010, 06:39 PM   #3
saiyen2002
Member
 
Registered: Dec 2006
Location: London, UK
Distribution: Centos, Fedora
Posts: 50

Original Poster
Rep: Reputation: 0
feinbein, I tried what you said, but it still hangs at unloading iptables modules.

I have noticed that this is something which is only relative to the boxes that I am working on, which is my test environment.

Iptables restarts fine within my live environment, which uses centos 5.5 instead of centos 5.4, which is my test environemnt
 
Old 10-31-2010, 07:19 PM   #4
dive
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Slackware
Posts: 3,211

Rep: Reputation: 293Reputation: 293Reputation: 293
Do you really _need_ to unload the modules on stop?
 
Old 11-01-2010, 01:12 PM   #5
saiyen2002
Member
 
Registered: Dec 2006
Location: London, UK
Distribution: Centos, Fedora
Posts: 50

Original Poster
Rep: Reputation: 0
What I _need_ to do is to restart the iptables.
doing that via the init script involves unloading the module.

Is there another way to do this?
 
  


Reply

Tags
hanging, iptables, shell script


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
Map a keypress to a GUI button (when keycode 175 pressed a GUI button pressed) wikapuki Linux - Desktop 0 09-16-2010 10:08 AM
How to make shell script wait for a particular key pressed in order to proceed? Caed Lucin Linux - General 5 01-31-2010 07:08 PM
Prevent XLIB application from closing when close button pressed fcdev Programming 1 11-11-2007 02:47 PM
Connect Gtk's key event with button pressed? Chowroc Programming 6 12-20-2004 02:52 PM
Automatic shutdown when power button pressed.. mr_smidge Linux - General 9 09-08-2003 03:16 AM


All times are GMT -5. The time now is 10:04 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration