Article View: alt.linux
Article #192Re: IPTables forwarding rule
From: 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
Technical Details
Message-ID:
<if8ct1-v17.ln1@free.teranews.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed-east.nntpserver.com!nntpserver.com!animal.nntpserver.com.POSTED!afbe4e3b!not-for-mailReferences:
<i7p1t1-n1u.ln1@free.teranews.com> <89b0c48f.0407222247.13f74b84@posting.google.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 100c5f,366e92497eb0b79a X-Google-Thread: faa64,366e92497eb0b79a X-Google-Thread: f9382,366e92497eb0b79a X-Google-Thread: 102983,366e92497eb0b79a X-Google-Attributes: gid100c5f,gidfaa64,gidf9382,gid102983,public X-Google-Language: ENGLISH,ASCII-7-bit Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed-east.nntpserver.com!nntpserver.com!animal.nntpserver.com.POSTED!afbe4e3b!not-for-mail From: Harry Phillips <harry@hkjsfh.com> User-Agent: Mozilla Thunderbird 0.7.1 (X11/20040629) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: alt.linux,alt.os.linux,comp.os.linux,aus.computers.linux Subject: Re: IPTables forwarding rule References: <i7p1t1-n1u.ln1@free.teranews.com> <89b0c48f.0407222247.13f74b84@posting.google.com> In-Reply-To: <89b0c48f.0407222247.13f74b84@posting.google.com> X-Enigmail-Version: 0.84.2.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <if8ct1-v17.ln1@free.teranews.com> Lines: 36 NNTP-Posting-Date: Sun, 25 Jul 2004 04:00:39 EST Date: Sun, 25 Jul 2004 18:44:01 +1000