Thread View: alt.linux
7 messages
7 total messages
Started by Harry Phillips
Wed, 21 Jul 2004 09:20
IPTables forwarding rule
Author: Harry Phillips
Date: Wed, 21 Jul 2004 09:20
Date: Wed, 21 Jul 2004 09:20
28 lines
2240 bytes
2240 bytes
I have a client with a firewall device that has a limited interface to
iptables (I cannot ssh into it either). All you can do is forward a port
to another IP address, you can't restrict it to a certain source IP.
I have set it up to forward port 22 to my Linux box, that then has
IPTables to accept anything local and drop everything else except my
ADSL modem IP.
Now I want to do a similar thing except forward the packets to another
internal host. I have no idea where to start and what rules to use. The
setup is:
_____________________
| (firewall device) | |---> |192.168.1.50|
internet <----> |ext_ip 192.168.1.254| <---|---> |192.168.1.1 |
|_____________________| |---> |192.168.1.x |
I want the Linux box (192.168.1.1) to forward port x to 192.168.1.50,
but only if the source is my ADSL modem IP.
Do I use the NAT and PREROUTING, POSTROUTING, FORWARD? I have examples
from the Internet if the Linux box and the host it is forwarding to are
on different networks but not when they are on the same network.
--
Regards,
Harry Phillips
Re: IPTables forwarding rule
Author: Black Adder
Date: Wed, 21 Jul 2004 11:01
Date: Wed, 21 Jul 2004 11:01
38 lines
2851 bytes
2851 bytes
I had a client similar to that too. I threw in an IPCOP box for them, and took out the firewall -- ---------------------------------------------------------------------------- ------------------------------------------------------------ "It's all coming back to me now", said the blind man as he peed into the wind "Harry Phillips" <harry@hkjsfh.com> wrote in message news:i7p1t1-n1u.ln1@free.teranews.com... > I have a client with a firewall device that has a limited interface to > iptables (I cannot ssh into it either). All you can do is forward a port > to another IP address, you can't restrict it to a certain source IP. > > I have set it up to forward port 22 to my Linux box, that then has > IPTables to accept anything local and drop everything else except my > ADSL modem IP. > > Now I want to do a similar thing except forward the packets to another > internal host. I have no idea where to start and what rules to use. The > setup is: > > _____________________ > | (firewall device) | |---> |192.168.1.50| > internet <----> |ext_ip 192.168.1.254| <---|---> |192.168.1.1 | > |_____________________| |---> |192.168.1.x | > > > I want the Linux box (192.168.1.1) to forward port x to 192.168.1.50, > but only if the source is my ADSL modem IP. > > Do I use the NAT and PREROUTING, POSTROUTING, FORWARD? I have examples > from the Internet if the Linux box and the host it is forwarding to are > on different networks but not when they are on the same network. > > -- > Regards, > Harry Phillips
Re: IPTables forwarding rule
Author: Harry Phillips
Date: Wed, 21 Jul 2004 11:33
Date: Wed, 21 Jul 2004 11:33
11 lines
1526 bytes
1526 bytes
Black Adder wrote: > I had a client similar to that too. I threw in an IPCOP box for them, and > took out the firewall > That is not an option after paying over $4,000 for it. I just thanks god it was not on my advice. -- Regards, Harry Phillips
Re: IPTables forwarding rule
Author: atec
Date: Wed, 21 Jul 2004 20:58
Date: Wed, 21 Jul 2004 20:58
34 lines
2218 bytes
2218 bytes
perhaps you can utilize firestarter ? Harry Phillips wrote: > > I have a client with a firewall device that has a limited interface to > iptables (I cannot ssh into it either). All you can do is forward a port > to another IP address, you can't restrict it to a certain source IP. > > I have set it up to forward port 22 to my Linux box, that then has > IPTables to accept anything local and drop everything else except my > ADSL modem IP. > > Now I want to do a similar thing except forward the packets to another > internal host. I have no idea where to start and what rules to use. The > setup is: > > _____________________ > | (firewall device) | |---> |192.168.1.50| > internet <----> |ext_ip 192.168.1.254| <---|---> |192.168.1.1 | > |_____________________| |---> |192.168.1.x | > > I want the Linux box (192.168.1.1) to forward port x to 192.168.1.50, > but only if the source is my ADSL modem IP. > > Do I use the NAT and PREROUTING, POSTROUTING, FORWARD? I have examples > from the Internet if the Linux box and the host it is forwarding to are > on different networks but not when they are on the same network. > > -- > Regards, > Harry Phillips -- X-No-Archive: Yes
Re: IPTables forwarding rule
Author: caliban
Date: Fri, 23 Jul 2004 06:47
Date: Fri, 23 Jul 2004 06:47
50 lines
3051 bytes
3051 bytes
Harry Phillips <harry@hkjsfh.com> wrote in message news:<i7p1t1-n1u.ln1@free.teranews.com>... > I have a client with a firewall device that has a limited interface to > iptables (I cannot ssh into it either). All you can do is forward a port > to another IP address, you can't restrict it to a certain source IP. > > I have set it up to forward port 22 to my Linux box, that then has > IPTables to accept anything local and drop everything else except my > ADSL modem IP. > > Now I want to do a similar thing except forward the packets to another > internal host. I have no idea where to start and what rules to use. The > setup is: > > _____________________ > | (firewall device) | |---> |192.168.1.50| > internet <----> |ext_ip 192.168.1.254| <---|---> |192.168.1.1 | > |_____________________| |---> |192.168.1.x | > > > I want the Linux box (192.168.1.1) to forward port x to 192.168.1.50, > but only if the source is my ADSL modem IP. > > Do I use the NAT and PREROUTING, POSTROUTING, FORWARD? I have examples > from the Internet if the Linux box and the host it is forwarding to are > on different networks but not when they are on the same network. I assume you tried DNAT on the PREROUTING chain? The problem is probably with routing -- your packets from ADSL modem are going to the linux box and having their destination IP rewritten as .1.50 but the source IP remains ADSL so when the .1.50 box replies to these it will send the packets to ADSL and thus the default router (.1.254) knowing nothing of this connection drops them. The trick is to both DNAT on the PREROUTING chain and SNAT on the POSTROUTING chain (twice nat?) eg $IT -t nat -A PREROUTING -j DNAT -p tcp -s $ADSL -d $ALIAS --dport $PORT --to-destination=192.168.1.50:$PORT $IT -t nat -A POSTROUTING -j SNAT -p tcp -s $ADSL -d 192.168.1.50 --dport $PORT --to-source=$ALIAS Where ALIAS is an IP alias for your linux box and ADSL is your modem IP. Good luck.
Re: IPTables forwarding rule
Author: Black Adder
Date: Fri, 23 Jul 2004 08:16
Date: Fri, 23 Jul 2004 08:16
25 lines
2103 bytes
2103 bytes
Sounds like my client too. I'm not sure how much it was (Cisco PIX
Firewall). To the end user it made no diiference really, because in the end
they had a solution that worked.
- I didn't advise them on the Pix Either?
--
----------------------------------------------------------------------------
------------------------------------------------------------
"It's all coming back to me now", said the blind man as he peed into the
wind
"Harry Phillips" <harry@hkjsfh.com> wrote in message
news:n012t1-2nv.ln1@free.teranews.com...
> Black Adder wrote:
> > I had a client similar to that too. I threw in an IPCOP box for them,
and
> > took out the firewall
> >
>
> That is not an option after paying over $4,000 for it. I just thanks god
> it was not on my advice.
>
> --
> Regards,
> Harry Phillips
Re: IPTables forwarding rule
Author: Harry Phillips
Date: Sun, 25 Jul 2004 08:44
Date: Sun, 25 Jul 2004 08:44
36 lines
2377 bytes
2377 bytes
caliban@rootshell.be wrote: >> >>Do I use the NAT and PREROUTING, POSTROUTING, FORWARD? I have examples >>from the Internet if the Linux box and the host it is forwarding to are >>on different networks but not when they are on the same network. > > > I assume you tried DNAT on the PREROUTING chain? > The problem is probably with routing -- > your packets from ADSL modem are going to the linux box and > having their destination IP rewritten as .1.50 but the source IP > remains > ADSL so when the .1.50 box replies to these it will send the packets > to ADSL and thus the default router (.1.254) knowing nothing of this > connection drops them. > > The trick is to both DNAT on the PREROUTING chain and SNAT on the > POSTROUTING chain (twice nat?) > eg > $IT -t nat -A PREROUTING -j DNAT -p tcp -s $ADSL -d $ALIAS --dport > $PORT --to-destination=192.168.1.50:$PORT > > $IT -t nat -A POSTROUTING -j SNAT -p tcp -s $ADSL -d 192.168.1.50 > --dport $PORT > --to-source=$ALIAS > > > Where ALIAS is an IP alias for your linux box and ADSL is your modem > IP. Thanks you very much I have tried this and it works exactly they way I want it to. -- Regards, Harry Phillips
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads