LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Iptables command won't work (https://www.linuxquestions.org/questions/linux-networking-3/iptables-command-wont-work-316416/)

no_names_left 04-23-2005 12:40 PM

Iptables command won't work
 
Hi,

I have iptables installed but the command "iptables" doesn't do anything. All I get is bash: iptables: command not found, which seems a little odd to me.

I am sure that I have iptables installed and have tried to configure it will webmin but I think something went wrong. Can anyone help me recover this please?

Thanks,

James

osvaldomarques 04-23-2005 01:02 PM

Hi James,

Bash is telling you it couldn't find iptables. So, or if it is not installed or it is not on your path. Iptables is generally installed on /usr/sbin; if you are trying to execute it from a normal user, probably you won't find it.

Good luck!

Osvaldo.

Ephracis 04-23-2005 01:02 PM

What kernel are you using?

iptables should be in /usr/sbin/iptables, have you checked with whereis iptables? You may need to modprobe iptables if you have it compiled as a module and it does not load on boot.

no_names_left 04-23-2005 01:10 PM

Hi guys,

Thanks for your quick responses. I tried #whereis iptables and got iptables: /sbin/iptables /lib/iptables /usr/share/man/man8/iptables.8.gz

I am a newbie to this area of linux and don't understand what you mean by

"You may need to modprobe iptables if you have it compiled as a module and it does not load on boot."

Could it be that I have made a mess of the configuration files and now it won't start?

thanks,

James

no_names_left 04-23-2005 01:12 PM

also. I am using Fedora Core 2 which I think it kernel 2.4. Is there a shell command to tell this?

Ephracis 04-23-2005 01:21 PM

Do this /sbin/iptables -h
That should work. You have iptables in /sbin/ which is not in your $PATH, it shouldn't be if you are not root. Are you sure that you have been root when you have been trying to access iptables? Cause iptables requires root access.

no_names_left 04-23-2005 01:39 PM

Just tried /sbin/iptables -h and it displayed a list of instructions :) Now I have /sbin/ in front of the commands it seems to work. The /sbin/iptables command and /sbin/iptables --list command work.

Should I update my $PATH and if so do you know how I should do this?

thanks,

James

Ephracis 04-23-2005 05:39 PM

Are you sure that you are root when trying? Because here is the thing. /sbin is "super-user bin" and it is a dir with programs only for root, therefor root should have it in $PATH but a regular user should not. Whoever you are you can check you $PATH with echo $PATH.

Here is how you change $PATH.
Edit /root/.bashrc and add this line:
Code:

export PATH=/sbin:/usr/sbin:/usr/local/sbin:$PATH
This line adds three sbin-dirs and at last the original path, to path. The reason we put it into the /root/.bashrc file is because now it will be updated every time you login as root.

no_names_left 04-23-2005 07:06 PM

I am certain that I am the su. Firstly if says root and second there is # which I assume also means root.

So on echo $path I got nothing at all. just a blank line. Should i be worried?

Anyhow I will try you code to change this.

James

osvaldomarques 04-23-2005 07:53 PM

Hi James,

If you're doing from kde and maybe gnome, you won't have /sbin and /usr/sbin in your path. It would be different in text mode.

Osvaldo.

P.S. PATH must be in upper case letters.


All times are GMT -5. The time now is 06:31 PM.