LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 03-16-2002, 12:15 PM   #1
padukes
LQ Newbie
 
Registered: Mar 2002
Posts: 4

Rep: Reputation: 0
Execute a script from iptables


Hey all,

Does any know if there isany way to run a script from an iptables rule? Something along the lines of:

iptables -A INPUT -s 1.2.3.4 -j /usr/bin/my_script

Thanks,
pa
 
Old 03-17-2002, 07:53 AM   #2
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
Isn't it better to get everything to a script and just run the script?
 
Old 03-17-2002, 08:45 AM   #3
padukes
LQ Newbie
 
Registered: Mar 2002
Posts: 4

Original Poster
Rep: Reputation: 0
What do you mean by "get everything to a script"? and how would I do that?

thanks,
P
 
Old 03-17-2002, 09:01 AM   #4
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
All rules started from a script. You create file with
#!/bin/sh
#modprobes, if needed
iptables -A input whatever
.
.
.
You save the file, make it executable, and it's done. You can even add it to your boot scripts to run firewall at boot.
 
Old 03-17-2002, 09:38 AM   #5
padukes
LQ Newbie
 
Registered: Mar 2002
Posts: 4

Original Poster
Rep: Reputation: 0
<grin> what I meant was is there any way to launch a script when a packet matches a particular rule. For example, if i have 3 Input rules:

1. iptables -A INPUT -s 1.2.3.4 -j ACCEPT
2. iptables -A INPUT -s 5.6.7.8 -j /usr/bin/my_script
3. iptables -A INPUT -s 9.10.11.12 -j ACCEPT

Is there any way to have my_script executed every time a packet matches rule #2?

Thanks again,
Doug
 
Old 03-17-2002, 09:47 AM   #6
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
I'm not 100% sure, but I think it's impossible. Iptables won't let you. Rules have their syntax and there is no place for a script. But maybe there are other utilities that can do it.
 
Old 03-17-2002, 06:15 PM   #7
bbenz3
Member
 
Registered: Feb 2002
Location: Orlando
Distribution: Whatever I feel like at the time I install.
Posts: 284

Rep: Reputation: 30
You would either have to write yourself a daemon or find one that runs in the background that would identify incoming IPs. Otherwise there isn't much hope.
 
  


Reply



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
How to execute iptables command by the user apache ??? Bassam Linux - Security 2 10-28-2005 07:10 AM
execute a script as a different user JordanH Linux - Software 3 02-08-2005 02:47 PM
Cannot execute a script grueugene Programming 15 01-27-2005 04:50 AM
shell script won't execute brandnewbie Linux - Newbie 7 08-10-2004 01:30 PM
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 - Networking

All times are GMT -5. The time now is 04:00 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