Creating iptables filter rules applicable to both FORWARD and OUTPUT chains


 
Thread Tools Search this Thread
Special Forums IP Networking Creating iptables filter rules applicable to both FORWARD and OUTPUT chains
# 1  
Old 07-23-2012
Creating iptables filter rules applicable to both FORWARD and OUTPUT chains

Hi all,

I have a script which permits users to access to a large list of IP ranges. Before, access to these ranges was granted by using a shell script to perform the necessary FORWARD chain command to allow traffic coming from the br0 interface and exiting the WAN interface, since br0 was the only interface which would access these ranges.
Code:
iptables -I FORWARD 6 -i br0 -d $CIDR -o $WAN_IFACE -j ACCEPT

However I have now implemented a caching proxy on the local gateway, and so I need to permit access to the IP ranges on the OUTPUT chain.
Code:
iptables -I OUTPUT 8 -d $CIDR -o $WAN_IFACE -j ACCEPT

However, the proxy will not always be running, in which case, the standard FORWARD command will still be needed. The problem I have is that by having several thousand ranges to add, having both these commands run for each range effectively doubles the time taken for the script to run. I was wondering if it is possible to combine these 2 commands in some way to allow both FORWARD and OUTPUT access to the IP ranges in only 1 command? Or am I stuck having to do both commands every single time?


Thanks in advance for any help.

Last edited by haggismn; 07-23-2012 at 04:27 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Filter output in curl

Hello guys, I'm writing a little script which sends me sms with my shell script via api of a sms provider. problem is I can't filter my curl output for this site: site url:... (1 Reply)
Discussion started by: genius90
1 Replies

2. Shell Programming and Scripting

How the filter output?

Hey, I'm using some sensors that can be read by http. If I run following command: curl -v 'http://192.168.111.23:8080/sensor/52f5c63cc4221fbbedcb499908a0a823?version=1.0&interval=minute&unit=watt&callback=realtime' I'm getting: I would like to put this now in a sheet with only the... (9 Replies)
Discussion started by: brononius
9 Replies

3. IP Networking

Dividing traffic with u32 iptables filter

I would like to divide traffic between two squid servers. I have been thinking about using iptables u32 filter, to check last bit of ip address which is comming to gateway. Then I would like to direct even IP adresses to one squid host, and odd to the other. Is it reasonable ? Thank you for... (2 Replies)
Discussion started by: new_item
2 Replies

4. Ubuntu

forward packet from input chain to output

Hi, I receive a packet at input chain of iptables in filter table. How can i forward that same packet exactly to the output chain of the iptables in filter table. I need this help desperately. Thanks. (0 Replies)
Discussion started by: arsipk
0 Replies

5. Debian

Iptables Nat forward port 29070

Hello, the Nat and the forward worked on my debian server up to the reboot of machines. The following rules*: /sbin/iptables -t nat -A PREROUTING -p tcp -i eth2 -d xxx.xxx.xxx.xxx --dport 29070 -j DNAT --to-destination 10.0.1.7:29070 /sbin/iptables -A FORWARD -p tcp -i eth2 -o eth0 -d... (0 Replies)
Discussion started by: titoms
0 Replies

6. Ubuntu

Iptables forward traffic to forward chain!!!

Hi, I am new to linux stuff. I want to use linux iptables to configure rule so that all my incoming traffic with protocol "tcp" is forwarded to the "FORWARD CHAIN". The traffic i am dealing with has destination addresss of my machine but i want to block it from coming to input chain and somehow... (0 Replies)
Discussion started by: arsipk
0 Replies

7. IP Networking

iptables forward public IP, no NAT, Debian i386

Hello all, got kinda problem. Have two machines in LAN, one of them connected to Internet directly, another one must be forwarded through the first one. Masquerading works perfectly, but is not what is needed here. Both machines have public IP addresses, when the second machine is forwarded its... (0 Replies)
Discussion started by: Action
0 Replies

8. Shell Programming and Scripting

Copying a files from a filter list and creating their associated parent directories

Hello all, I'm trying to copy all files within a specified directory to another location based on a find filter of mtime -1 (Solaris OS). The issue that I'm having is that in the destination directory, I want to retain the source directory structure while copying over only the files that have... (4 Replies)
Discussion started by: hunter55
4 Replies

9. IP Networking

Filter wireshark output

Hi I have a wireshark file saved (from my network) and I have to analyze the flows inside it. The problem is that i have to analyze not the complete file (60.000 pkts!) but just a subset of it. In other words i have to sample the wireshark.file.dump and for example from 60.000 pkts take... (2 Replies)
Discussion started by: Dedalus
2 Replies

10. UNIX for Dummies Questions & Answers

sed command applicable?

Find the messages with BLUE header, collect the telno, and dump to a file. file below: header 1 BLUE 11/20/01 body telno 555 body room1 trailer 1 xxx header 2 BLUE 11/20/01 body telno 444 body room2 trailer 2 xxx header 3 RED 11/20/01 body telno 666 body room3 trailer 3 xxx ... (2 Replies)
Discussion started by: apalex
2 Replies
Login or Register to Ask a Question