All of lore.kernel.org
 help / color / mirror / Atom feed
From: Klaus Wacker <klaus_gr_W_kl_Acker@web.de>
To: netfilter@lists.netfilter.org
Subject: iptables /nat and route
Date: Mon, 13 Aug 2007 10:58:09 +0200	[thread overview]
Message-ID: <1549989276@web.de> (raw)

Hi, it seems it is a simple task, but can't get it going.
I want have a couple of private machines accessing a public one  (and other way around) through a router/gateway
At the moment I do not care about ports (one to one is enough for me), just try to get a ping through in both directions including a change of source and destination ip
The default gateways address of the public machine I did set to OUTIP  respectively INIP for internal machine. 
Here is my setup:

echo #rc.my.iptables

####network######
#given IP (not yet DHCP)
PUP_IP="192.168.10.99"

#internal devices (might be a range)
NET_IP1="192.168.9.1"

####router#######
OUT_INFC="eth0"
IN_INFC="eth2"
INIP="192.168.9.200"
OUTIP="192.168.10.200"


### iptables #####
##for incoming from puplic ###
iptables -t nat   -A PREROUTING -i $IN_INFC -s $PUP_IP -d $INIP -j DNAT --to $NET_IP1
iptables -t filter -A FORWARD -s $PUP_IP -d $NET_IP1 -j ACCEPT

###return way ### 
iptables -t nat   -A POSTROUTING -d $PUP_IP -s $NET_IP1 -j SNAT  --to $INIP
#(have tried without next line)
iptables -t filter -A FORWARD -s $NET_IP1 -d $PUP_IP -j ACCEPT


## keep things going, (have tried without)###
iptables -A FORWARD -i eth0  -o eth2  -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i eth2  -o eth0  -m state --state RELATED,ESTABLISHED -j ACCEPT
 

It does not work in any direction. I am wondering it may have something to do with my route settings:


Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.10.1    255.255.255.0   UG    0      0        0 eth0
default         192.168.9.1     255.255.255.0   UG    0      0        0 eth2
192.168.10.0    *               255.255.255.0   U     0      0        0 eth0
192.168.9.0     *               255.255.255.0   U     0      0        0 eth2
default         127.0.0.0       0.0.0.0         UG    0      0        0 lo
 

Cheers
Klaus


_______________________________________________________________________
Jetzt neu! Schützen Sie Ihren PC mit McAfee und WEB.DE. 3 Monate
kostenlos testen. http://www.pc-sicherheit.web.de/startseite/?mc=022220



                 reply	other threads:[~2007-08-13  8:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1549989276@web.de \
    --to=klaus_gr_w_kl_acker@web.de \
    --cc=netfilter@lists.netfilter.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.