LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices

Reply
 
LinkBack Search this Thread
Old 02-01-2006, 04:25 AM   #1
mmshekiba
LQ Newbie
 
Registered: Jan 2006
Posts: 2

Rep: Reputation: 0
iptables:redirect ports except for packets destined for fierwall(upto 256 ip) itself


Hi,
I want to redirect packets with dport 80,81,8181,8888 to 8081 except for packets destined for firewall itself.because there is a web server running on Firewall on port 80 for configuring Firewall.
firewall has 2 NICs:
eth0: local network(s)
eth1: internet
firewall's eth0 can have up to 256 ip address with ip aliasing.
for example eth0 has ips:
192.168.168.201
192.168.1.150
192.168.10.66
192.168.16.32
192.168.17.50
192.168.13.3
how can I edit below rules to do what I want?

iptables -A PREROUTING -s 192.168.168.0/255.255.255.0 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8081
iptables -A PREROUTING -s 192.168.168.0/255.255.255.0 -p tcp -m tcp --dport 81 -j REDIRECT --to-ports 8081
iptables -A PREROUTING -s 192.168.168.0/255.255.255.0 -p tcp -m tcp --dport 8180 -j REDIRECT --to-ports 8081
iptables -A PREROUTING -s 192.168.168.0/255.255.255.0 -p tcp -m tcp --dport 8181 -j REDIRECT --to-ports 8081
iptables -A PREROUTING -s 192.168.168.0/255.255.255.0 -p tcp -m tcp --dport 8888 -j REDIRECT --to-ports 8081


TNX
 
Old 02-02-2006, 12:08 PM   #2
win32sux
Moderator
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 367Reputation: 367Reputation: 367Reputation: 367
you could do it like this:
Code:
iptables -A PREROUTING -p TCP -s 192.168.168.0/255.255.255.0 \
-d ! 192.168.0.0/255.255.0.0 --dport 80 -j REDIRECT --to-ports 8081
or to achieve the same with less typing:
Code:
iptables -A PREROUTING -p TCP -s 192.168.168.0/24 \
-d ! 192.168.0.0/16 --dport 80 -j REDIRECT --to-ports 8081

Last edited by win32sux; 02-02-2006 at 12:20 PM.
 
  


Reply


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Iptables wide open, but no UDP packets allowed (all ports closed) please help mfeoli Linux - Networking 1 01-06-2006 09:52 AM
Akward ports listed and UDP packets. stryka Linux - Security 1 11-22-2005 04:25 PM
forwarding packets to multiple computers for different ports laxy_m Linux - Networking 7 11-11-2004 08:15 AM
How to check if packets/ports are being filtered/blocked mfeoli Linux - Networking 1 11-05-2004 05:27 AM
Why one nic accept packets destined for second nic gibcomp Linux - Networking 2 09-09-2004 12:21 AM


All times are GMT -5. The time now is 04:17 PM.

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
Open Source Consulting | Domain Registration