Networking Forums

Networking Forums > Computer Networking > Linux Networking > Iptables: rules not applied?

Reply
Thread Tools Display Modes

Iptables: rules not applied?

 
 
julien
Guest
Posts: n/a

 
      08-03-2008, 07:25 AM
Hello,
I'm using iptables to redirect all the TCP traffic to a transparent
proxy. It seems taht the rules are there:
# iptables -t nat --list
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
DNAT tcp -- anywhere !X.X.X.X to:X.X.X.X:Y

Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
MASQUERADE all -- anywhere anywhere

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

But when I do, for example, an HTTP request on port 80, it is not
redirected to the proxy.

I'm using Centos 5 on VMware


The script I use:
#!/bin/sh

PROXY_IP="X.X.X.X"
PROXY_PORT="Y"
LAN="eth0"

# Flush
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X

# Load modules
modprobe ip_conntrack
modprobe ip_conntrack_ftp
# For win xp ftp client
echo 1 > /proc/sys/net/ipv4/ip_forward


# Re-routing

iptables -t nat -A PREROUTING -i $LAN -p tcp -d ! $PROXY_IP -j DNAT --
to $PROXY_IP:$PROXY_PORT
iptables -t nat -A POSTROUTING -j MASQUERADE

Any idea waht I am missing?

Thank you
Julien
 
Reply With Quote
 
 
 
 
Klunk
Guest
Posts: n/a

 
      08-03-2008, 08:29 AM
On Sun, 03 Aug 2008 00:25:00 -0700, julien passed an empty day by writing:

> Hello,
> I'm using iptables to redirect all the TCP traffic to a transparent
> proxy. It seems taht the rules are there: # iptables -t nat --list
> Chain PREROUTING (policy ACCEPT)
> target prot opt source destination DNAT tcp --
> anywhere !X.X.X.X to:X.X.X.X:Y
>
> Chain POSTROUTING (policy ACCEPT)
> target prot opt source destination MASQUERADE all --
> anywhere anywhere
>
> Chain OUTPUT (policy ACCEPT)
> target prot opt source destination
>
> But when I do, for example, an HTTP request on port 80, it is not
> redirected to the proxy.
>
> I'm using Centos 5 on VMware
>
>
> The script I use:
> #!/bin/sh
>
> PROXY_IP="X.X.X.X"
> PROXY_PORT="Y"
> LAN="eth0"
>
> # Flush
> iptables -F
> iptables -X
> iptables -t nat -F
> iptables -t nat -X
> iptables -t mangle -F
> iptables -t mangle -X
>
> # Load modules
> modprobe ip_conntrack
> modprobe ip_conntrack_ftp
> # For win xp ftp client
> echo 1 > /proc/sys/net/ipv4/ip_forward
>
>
> # Re-routing
>
> iptables -t nat -A PREROUTING -i $LAN -p tcp -d ! $PROXY_IP -j DNAT --
> to $PROXY_IP:$PROXY_PORT
> iptables -t nat -A POSTROUTING -j MASQUERADE
>
> Any idea waht I am missing?
>
> Thank you
> Julien


After running this doing a iptables -L shows the rules yes?



--
I collect spam + please send it to: (E-Mail Removed)
 
Reply With Quote
 
julien
Guest
Posts: n/a

 
      08-03-2008, 05:05 PM
On Aug 3, 1:29*am, Klunk <givemes...@wibblywobblyteapot.co.uk> wrote:
> On Sun, 03 Aug 2008 00:25:00 -0700, julien passed an empty day by writing:
>
>
>
> > Hello,
> > I'm using iptables to redirect all the TCP traffic to a transparent
> > proxy. It seems taht the rules are there: # iptables -t nat --list
> > Chain PREROUTING (policy ACCEPT)
> > target * * prot opt source * * * * * * * destination DNAT * * * tcp *--
> > anywhere * * * * * *!X.X.X.X * * *to:X.X.X.X:Y

>
> > Chain POSTROUTING (policy ACCEPT)
> > target * * prot opt source * * * * * * * destination MASQUERADE *all *--
> > *anywhere * * * * * * anywhere

>
> > Chain OUTPUT (policy ACCEPT)
> > target * * prot opt source * * * * * * * destination

>
> > But when I do, for example, an HTTP request on port 80, it is not
> > redirected to the proxy.

>
> > I'm using Centos 5 on VMware

>
> > The script I use:
> > #!/bin/sh

>
> > PROXY_IP="X.X.X.X"
> > PROXY_PORT="Y"
> > LAN="eth0"

>
> > # Flush
> > iptables -F
> > iptables -X
> > iptables -t nat -F
> > iptables -t nat -X
> > iptables -t mangle -F
> > iptables -t mangle -X

>
> > # Load modules
> > modprobe ip_conntrack
> > modprobe ip_conntrack_ftp
> > # For win xp ftp client
> > echo 1 > /proc/sys/net/ipv4/ip_forward

>
> > # Re-routing

>
> > iptables -t nat -A PREROUTING -i $LAN -p tcp -d ! $PROXY_IP -j DNAT --
> > to $PROXY_IP:$PROXY_PORT
> > iptables -t nat -A POSTROUTING -j MASQUERADE

>
> > Any idea waht I am missing?

>
> > Thank you
> > Julien

>
> After running this doing a iptables -L shows the rules yes?
>
> --
> I collect spam + please send it to: givemes...@wibblywobblyteapot.co.uk


Actually, it doesn't:
# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

But the rules are displayed with iptables -t nat --list
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
HELP, Need quick iptables rules akak01000101@gmail.com Linux Networking 5 03-03-2008 07:45 PM
Is there a difference between these two iptables rules paulwvanc@yahoo.ca Linux Networking 0 12-11-2006 11:21 PM
When are 'egress' traffic shaping rules applied? spip_yeah@yahoo.com Linux Networking 3 12-01-2006 10:09 AM
Removing iptables rules Augustus SFX van Dusen Linux Networking 7 06-05-2006 04:05 PM
Looking for iptables applications code (iptables.c) to run some rules to forward packets tvnaidu@yahoo.com Linux Networking 2 01-17-2005 05:01 PM



1 2 3 4 5 6 7 8 9 10 11