All of lore.kernel.org
 help / color / mirror / Atom feed
* DNAT
@ 2004-10-26 10:20 Payal Rathod
  2004-10-26 10:30 ` DNAT Primero
  2004-10-26 12:42 ` DNAT Jason Opperisano
  0 siblings, 2 replies; 12+ messages in thread
From: Payal Rathod @ 2004-10-26 10:20 UTC (permalink / raw)
  To: Netfilter ML

Hi,
I want to access my internal machine from outside. But I am unable to do 
so. I tried,
# iptables -t nat -I PREROUTING -d <my_ext_ip> -p tcp --dport
8081 -j DNAT --to-destination 192.168.0.16:80
# iptables -I INPUT -p tcp --dport 8081 -j ACCEPT
# iptables -I FORWARD -s 192.168.0.16 -j ACCEPT

I know these are very crude but they are simple to start with. Also,
once I get one more public IP from my ISP, I will NAT it to the
internal machine.
Can anyone give pointers on this and above to why it is not working?
If this is right, is it possible that my ISP might be blocking 
traffic from outside to ports other than the few.

With warm regards,
-Payal



^ permalink raw reply	[flat|nested] 12+ messages in thread
* DNAT
@ 2005-07-19  2:01 Kai Hendry
  0 siblings, 0 replies; 12+ messages in thread
From: Kai Hendry @ 2005-07-19  2:01 UTC (permalink / raw)
  To: netfilter

I have three machines:
192.168.0.1
192.168.0.3
192.168.0.9

On 9 there is service running on port 1199 that I want clients (at 3) to 
use from 1.

With SSH I can get this working from 1 with clients at 1 with:
ssh -L 1199:localhost:1199 192.168.0.9
Thought telnet localhost 1199 only works, not telnet 192.168.0.1 1199
Anyway, I don't need encryption.

DNAT is what I've been told I need so:
http://netfilter.org/documentation/HOWTO//NAT-HOWTO-10.html

$ cat i.sh
sudo /sbin/iptables -t nat -F
# This alone doesn't work
sudo /sbin/iptables -t nat -A PREROUTING -p tcp --dport 1199 -i eth0 -j 
DNAT --to 192.168.0.9:1199
# I suspect something is wrong here:
sudo /sbin/iptables -t nat -A POSTROUTING -p tcp --dport 1199 -j SNAT 
--to 192.168.0.1:1199
sudo /sbin/iptables -t nat -vnxL --line-numbers

It just does not work when from 3:
$ telnet 192.168.0.1 1199
Trying 192.168.0.1...

Packets do show up:
SOLTEC-HDSVR$ sudo /sbin/iptables -t nat -vnxL --line-numbers
Chain PREROUTING (policy ACCEPT 6494 packets, 466878 bytes)
num      pkts      bytes target     prot opt in     out     
source               destination
1           4      240 DNAT       tcp  --  eth0   *       
0.0.0.0/0            0.0.0.0/0          tcp dpt:1199 to:192.168.0.9:1199

Chain POSTROUTING (policy ACCEPT 2102 packets, 388967 bytes)
num      pkts      bytes target     prot opt in     out     
source               destination

Chain OUTPUT (policy ACCEPT 2102 packets, 388967 bytes)
num      pkts      bytes target     prot opt in     out     
source               destination

Though from 1 not at all:
$ telnet 192.168.0.1 1199
Trying 192.168.0.1...
telnet: Unable to connect to remote host: Connection refused

What am I doing wrong?


^ permalink raw reply	[flat|nested] 12+ messages in thread
* DNAT
@ 2004-10-26  7:39 Payal Rathod
  0 siblings, 0 replies; 12+ messages in thread
From: Payal Rathod @ 2004-10-26  7:39 UTC (permalink / raw)
  To: Netfilter ML

Hi,
I want to access my internal machine from outside. But I am unable to do 
so. I tried,
# iptables -t nat -I PREROUTING -d <my_ext_ip> -p tcp --dport
8081 -j DNAT --to-destination 192.168.0.16:80
# iptables -I INPUT -p tcp --dport 8081 -j ACCEPT
# iptables -I FORWARD -s 192.168.0.16 -j ACCEPT

I know these are very crude but they are simple to start with. Also,
once I get one more public IP from my ISP, I will NAT it to the
internal machine.
Can anyone give pointers on this and above to why it is not working?
If this is right, is it possible that my ISP might be blocking 
traffic from outside to ports other than the few.

With warm regards,
-Payal



^ permalink raw reply	[flat|nested] 12+ messages in thread
* RE: DNAT
@ 2003-09-08 22:48 George Vieira
  0 siblings, 0 replies; 12+ messages in thread
From: George Vieira @ 2003-09-08 22:48 UTC (permalink / raw)
  To: Nejc Skoberne, netfilter

This is a typical problem which gets asked over and over again. If you think about it carefully, you'll understand why this doesn't work.

Explained:

1. Your internal tries to access the server on it's external address.
2. The firewall DNATs it changing it's external address to the internal server address.
3. The packet arrives at the destination of 192.168.1.1
4. The Server responses to the SYN and "sends it back to 192.168.1.X DIRECTLY"
5. The client machine receives a packet from 192.168.1.1 and drops the packet because it has no reference to that machine, only to the w.x.y.z IP address. So the connection is never made.

6. Use SNAT between the local machines and the internal 192.168.1.1:4444 machine as you would when the internal users browse the internet and you masquerade them. You have to masquerade them for the internal server too.

iptables -A POSTROUTING -p tcp --dport 4444 -s 192.168.1.0/24 -d 192.168.1.1 -j SNAT $FIREWALLINTERNALIP

The above rule should fix that..

-----Original Message-----
From: Nejc Skoberne [mailto:nejc.skoberne@guest.arnes.si]
Sent: Tuesday, September 09, 2003 12:40 AM
To: netfilter@lists.netfilter.org
Subject: DNAT


Hi.

I have a problem with DNAT. I want to set up portforwarding. In local
network I have two servers and workstations. One (main) server is listening
at some port, let's say 4444. The other one also acts like a gateway
to internet and I set up a portforwarding like this:

iptables -A PREROUTING -p tcp --dport 4444 -j DNAT --to 192.168.1.1:4444

where 192.168.1.1 is the IP of the main server which runs the service.
If I try to connect from outside, everything works fine. If I try to
connect from one of workstations to the gateway machine to port 4444,
nothing happens. tcpdumps shows just requests but no answers. Why
doesnt DNAT work also for local IP addresses?

Thanks.

-- 
Nejc Skoberne
Grajska 5
SI-5220 Tolmin
E-mail: nejc.skoberne@guest.arnes.si




^ permalink raw reply	[flat|nested] 12+ messages in thread
* DNAT
@ 2003-09-08 14:40 Nejc Skoberne
  2003-09-08 22:20 ` DNAT Jim Carter
  0 siblings, 1 reply; 12+ messages in thread
From: Nejc Skoberne @ 2003-09-08 14:40 UTC (permalink / raw)
  To: netfilter

Hi.

I have a problem with DNAT. I want to set up portforwarding. In local
network I have two servers and workstations. One (main) server is listening
at some port, let's say 4444. The other one also acts like a gateway
to internet and I set up a portforwarding like this:

iptables -A PREROUTING -p tcp --dport 4444 -j DNAT --to 192.168.1.1:4444

where 192.168.1.1 is the IP of the main server which runs the service.
If I try to connect from outside, everything works fine. If I try to
connect from one of workstations to the gateway machine to port 4444,
nothing happens. tcpdumps shows just requests but no answers. Why
doesnt DNAT work also for local IP addresses?

Thanks.

-- 
Nejc Skoberne
Grajska 5
SI-5220 Tolmin
E-mail: nejc.skoberne@guest.arnes.si



^ permalink raw reply	[flat|nested] 12+ messages in thread
* DNAT
@ 2003-08-28 22:57 Mattia Martinello
  0 siblings, 0 replies; 12+ messages in thread
From: Mattia Martinello @ 2003-08-28 22:57 UTC (permalink / raw)
  To: netfilter

Hi all

I created a script that setup a set of rules on the nat table.
It works good without any problem on SuSE 8.0, and now I wish to move 
the system on Debian.
I installed Debian and I set the network correctly like on SuSE and I 
copied the script on it.
The scripts shows me no error, and the rules works good, but there is a 
little problem.
The DNATs from the local network works very well (I can see the server 
which is on the DMZ from the local network), but the DNATs from the 
Internet doesn't work! From the Internet (ppp0) i cannot see the server 
which is on the DMZ.
On SuSE 8.0 all works good and I didn't change anything in the script!
The input, output and forward chains are all setted on ACCEPT, like all 
the chains on the nat table.

This works good:
iptables -t nat -A POSTROUTING -s $LocalNET/24 -o ppp0 -j MASQUERADE
iptables -t nat -A POSTROUTING -s $LocalNET/24 -o ppp0 -j ACCEPT
iptables -t nat -A POSTROUTING -s $LocalNET/255.255.255.0 -o eth2 -j 
MASQUERADE
iptables -t nat -A PREROUTING -p tcp -i eth1 -d $PublicIP -j DNAT --to 
$ServerIP

This DOESN'T work! :(
iptables -t nat -A PREROUTING -p tcp -i ppp0 -d $PublicIP --dport 80 -j 
DNAT --to $ServerIP:80

The kernel in use is 2.4.20 with all netfilter modules.

Where could be the problem?

Thank you very much!
Bye
Mattia.



^ permalink raw reply	[flat|nested] 12+ messages in thread
* DNAT
@ 2003-03-30 14:30 Alexandru Coseru
  0 siblings, 0 replies; 12+ messages in thread
From: Alexandru Coseru @ 2003-03-30 14:30 UTC (permalink / raw)
  To: netfilter

[-- Attachment #1: Type: text/plain, Size: 292 bytes --]

hello.. I have the folowing problem...  I have a linux gateway with the external IP x.x.x.x  and internal Ip 192.168.0.1.    I want to make a DNAT and mask a conection from the external IP , forwarded to one of my lan's computer , and the lan computer to see it as 192.168.0.1 , not x.x.x.x

[-- Attachment #2: Type: text/html, Size: 633 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread
* DNAT
@ 2002-12-12 18:00 Justin Kay
  0 siblings, 0 replies; 12+ messages in thread
From: Justin Kay @ 2002-12-12 18:00 UTC (permalink / raw)
  To: Netfilter (E-mail)

When using a linux box to DNAT to some other boxes in a private address
space, do you need to alias all of the public ip addresses that you will be
doing DNAT for on the linux box?

internet--->208.224.51.10 (LINUX PUB IP FAKE) Linux/DNAT---> 10.10.20.15
other box
	    208.224.51.11 (alias used for other box)  IS THIS NEEDED in
order for it to work?	


Justin


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2005-07-19  2:01 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-26 10:20 DNAT Payal Rathod
2004-10-26 10:30 ` DNAT Primero
2004-10-26 12:42 ` DNAT Jason Opperisano
  -- strict thread matches above, loose matches on Subject: below --
2005-07-19  2:01 DNAT Kai Hendry
2004-10-26  7:39 DNAT Payal Rathod
2003-09-08 22:48 DNAT George Vieira
2003-09-08 14:40 DNAT Nejc Skoberne
2003-09-08 22:20 ` DNAT Jim Carter
2003-09-08 22:31   ` DNAT Nejc Skoberne
2003-08-28 22:57 DNAT Mattia Martinello
2003-03-30 14:30 DNAT Alexandru Coseru
2002-12-12 18:00 DNAT Justin Kay

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.