netfilter.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Port Forwarding
@ 2009-10-11  0:30 jen140
  2009-10-11  1:36 ` John A. Sullivan III
                   ` (2 more replies)
  0 siblings, 3 replies; 64+ messages in thread
From: jen140 @ 2009-10-11  0:30 UTC (permalink / raw)
  To: netfilter

Hello.
I am running Debian(5.0.3), and have kernel version: 2.6.26-2-686.
And I have just installed the iptables v1.4.5.
After  searching for help on debian and ubuntu forums, i didnt get any
response, so I'm writing here.
My network configuration is next:
eth0 is my internet interface and has dinamic ip(83.x.x.x).
eth1 is my intranet interface and has static ip(192.168.0.1).
The server machine(thise pc) shares internet with other machines.
At debian start iptables has the next config:
iptables -P FORWARD ACCEPT
iptables --table nat -A POSTROUTING --out-interface eth0 -j MASQUERADE
So now getting to the problem.
I  wanted  to configure port forwarding, and forward port 135 from Any
address  that  comes from eth0 (internet) to ip 192.168.0.200 and same
port(135).
I've tryied running the next:
iptables -F
iptables -t nat -F
iptables -P FORWARD ACCEPT
iptables --table nat -A POSTROUTING --out-interface eth0 -j MASQUERADE
iptables --table nat -A PREROUTING --in-interface eth0 -j DNAT -p tcp --dport 135 --to 192.168.0.200:135
But   the   problem   is   that  it  is  filtered  (I  check  it  with
nmap-online.com service).
Am i doing anything wrong or my kernel doesnt support it ?
Thanks in advance.
Have a good day.


^ permalink raw reply	[flat|nested] 64+ messages in thread
* Re: Port Forwarding
@ 2009-10-11 13:56 jen140
  0 siblings, 0 replies; 64+ messages in thread
From: jen140 @ 2009-10-11 13:56 UTC (permalink / raw)
  To: netfilter; +Cc: Brian Austin - Standard Universal

It is enabled.
jen140@server:~$ cat /proc/sys/net/ipv4/ip_forward
1
But still doesnt work =(.


^ permalink raw reply	[flat|nested] 64+ messages in thread
* Re: Port Forwarding
@ 2009-10-11  2:00 jen140
  0 siblings, 0 replies; 64+ messages in thread
From: jen140 @ 2009-10-11  2:00 UTC (permalink / raw)
  To: netfilter

Thanks for your fast responses.
First of all i checked all the next rules:
iptables -A tcp_packets -p TCP -s 0/0 --dport 139 -j ACCEPT
iptables -A udpincoming_packets -p UDP -s 0/0 --source-port 139 -j ACCEPT
iptables -t nat -A PREROUTING -p tcp -d 83.132.157.x --dport 139 -j DNAT --to 192.168.0.200:139
//filtered <-
iptables -t nat -I PREROUTING -p tcp -i eth0 --dport 139 -j DNAT --to 192.168.0.200:139
//filtered <-
iptables -t nat -A PREROUTING -p tcp -i eth0 -d 83.132.157.x --dport 139 -j DNAT --to 192.168.0.200:139
iptables -A FORWARD -p tcp -i eth0 -d 192.168.0.200 --dport 139 -j ACCEPT
//closed <- host down
iptables -t nat -A PREROUTING -p tcp -i eth0 --dport 139 -j DNAT --to 192.168.0.200:139
iptables -A FORWARD -p tcp -i eth0 -d 192.168.0.200 --dport 139 -j ACCEPT
//filtered <-
iptables -t nat -I PREROUTING -p tcp -i eth0 --dport 139 -j DNAT --to 192.168.0.200:139
iptables -A FORWARD -p tcp -i eth0 -d 83.132.157.x --dport 139 -j ACCEPT
//filtered <- host down
iptables -t nat -I PREROUTING -p tcp -i eth0 --dport 139 -j DNAT --to 192.168.0.200:139
iptables -A FORWARD -p tcp -i eth0 --dport 139 -j ACCEPT
//filtered
With my friend's help.
And none of them directed the output.
There  is  no  problem  to  forward  the  port 139, because it will be
forwarded to a honeypot machine =) (running on virtualbox).
When  started  to  test  with the ipmasq the host stopped to listen on
other  ports  (ssh  for  lan for example),but connection sharing still
works.
And my friend couldnt connect to the host.


^ permalink raw reply	[flat|nested] 64+ messages in thread
* Port Forwarding
@ 2009-05-28 19:50 Barry A Rich
  2009-06-05 13:47 ` Aleksander Kamenik
  0 siblings, 1 reply; 64+ messages in thread
From: Barry A Rich @ 2009-05-28 19:50 UTC (permalink / raw)
  To: netfilter

Our basic configuration load balances connections across two uplink modems.
The IP addressing looks like this:

                    |-------------| 192.168.4.1         192.168.4.2
        192.160.0.1 |        eth1 |-------------------------------- Modem 1
LAN ----------------| eth0        |
                    |        eth2 |-------------------------------- Modem 2
                    |-------------| 192.168.5.1         192.168.5.2


The basic setup for the load balancing is as follows:

iptables -A INPUT -i eth0 -s 192.168.0.0/24 -d 0.0.0.0/0 -j ACCEPT

iptables -A INPUT -i eth1 -s 192.168.4.0/24 -d 0.0.0.0/0 -j ACCEPT

iptables -A INPUT -i eth2 -s 192.168.5.0/24 -d 0.0.0.0/0 -j ACCEPT

iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

iptables -A OUTPUT -o eth0 -s 192.168.4.1 -d 192.168.0.0/24 -j ACCEPT

iptables -A OUTPUT -o eth0 -s 192.168.5.1 -d 192.168.0.0/24 -j ACCEPT

iptables -A OUTPUT -o eth1 -s 192.168.4.1 -d 0.0.0.0/0 -j ACCEPT

iptables -A OUTPUT -o eth2 -s 192.168.5.1 -d 0.0.0.0/0 -j ACCEPT

iptables -t nat -A POSTROUTING -o eth1 -j SNAT --to 192.168.4.1

iptables -t nat -A POSTROUTING -o eth2 -j SNAT --to 192.168.5.1

ip route add 192.168.4.2 dev eth1 table uplink1

ip route add default via 192.168.4.1 table uplink1

ip route add 192.168.5.2 dev eth1 table uplink2

ip route add default via 192.168.5.1 table uplink2

ip route add 192.168.4.2 dev eth1

ip route add 192.168.5.2 dev eth2

ip rule add from 192.168.4.1 table uplink1

ip rule add from 192.168.5.1 table uplink2

ip route add default scope global nexthop dev eth1 weight 1 nexthop dev eth2
weight 1

This is all working. Connections are balanced across the uplinks. It turns
out the modems have a TCP control port (5000). The port number cannot be
changed on the modems. I want LAN hosts to be able to connect to both modem
control ports. The port number can be changed on the host software, so I
assigned different ports on the LAN (5000 and 5001) and tried to redirect
the ports as follows:

iptables -t nat -A PREROUTING -p tcp -d 192.168.0.1 --dport 5000 -j DNAT
--to 192.168.4.2:5000

iptables -t nat -A PREROUTING -p tcp -d 192.168.0.1 --dport 5001 -j DNAT
--to 192.168.5.2:5000

It does not work and I'm not sure what's wrong. What is the correct way to
do this?

Thanks.



^ permalink raw reply	[flat|nested] 64+ messages in thread
* Port forwarding
@ 2008-12-12 23:33 Błażej Ślusarek
  2008-12-13 16:36 ` Elvir Kuric
  2009-02-04 17:48 ` Błażej Ślusarek
  0 siblings, 2 replies; 64+ messages in thread
From: Błażej Ślusarek @ 2008-12-12 23:33 UTC (permalink / raw)
  To: netfilter

Hello, could anyone help me to enable port forwarding on a server
which default policies are PREROUTING DROP and FORWARD DROP? I'm
actually asking for a correct set of instructions.

Thanks.

^ permalink raw reply	[flat|nested] 64+ messages in thread
* Port forwarding
@ 2006-02-28 13:27 Stian B. Barmen
  0 siblings, 0 replies; 64+ messages in thread
From: Stian B. Barmen @ 2006-02-28 13:27 UTC (permalink / raw)
  To: netfilter

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

I am wondering how to enable port forwarding from a DMZ to an internal 
network. The machine forwarding is just a normal Linux machine, no firewall in 
the DMZ, and I want it to forward one port to an internal machine on the 
intenal network. Note, the DMZ machine has only one network card, the network 
with the internal machine is behind the firewall, and another router. 
Connectivity from the DMZ machine to the internal machine works.

Here is my ipables:

# Generated by iptables-save v1.3.4 on Tue Feb 28 14:24:10 2006
*nat
:PREROUTING ACCEPT [1014:84065]
:POSTROUTING ACCEPT [1243:92537]
:OUTPUT ACCEPT [1237:92240]
-A PREROUTING -d 217.20.20.160 -i eth0 -p tcp -m tcp --dport 81 -j 
DNAT --to-destination 10.22.0.79:8081
COMMIT
# Completed on Tue Feb 28 14:24:10 2006
# Generated by iptables-save v1.3.4 on Tue Feb 28 14:24:10 2006
*filter
:INPUT ACCEPT [124031010:45151447581]
:FORWARD ACCEPT [12:576]
:OUTPUT ACCEPT [155888838:182283994852]
COMMIT
# Completed on Tue Feb 28 14:24:10 2006

I just used the command:
iptables -t nat -A PREROUTING -p tcp -i eth0 -d 217.20.20.160 --dport 81 -j 
DNAT --to 10.22.0.79:8081

# cat /proc/sys/net/ipv4/ip_forward
1

Also I enabled ip_forward.

But when I try to connect to 217.20.20.160:81 it just times out waiting for an 
answer. Do I need more in this minimalistic setup to make it work?

Note, the ip addresses are bogus, but representative. (the 217 is public ip 
and the 10 is private)

Best regards
Stian B. Barmen

[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 4490 bytes --]

^ permalink raw reply	[flat|nested] 64+ messages in thread
* port forwarding
@ 2005-02-23  8:36 DurgaPrasad Adusumalli
  0 siblings, 0 replies; 64+ messages in thread
From: DurgaPrasad Adusumalli @ 2005-02-23  8:36 UTC (permalink / raw)
  To: netfilter

I am trying to use iptables firewall in an environment where there is
lot of incoming traffic destined to different web servers,ftp servers
running on different machine in LAN. I have done this using port
forwarding.

The problem I face with this is very frequently the rules go on and
off. They do not work but are listed when iptables -L -n command is
issued.

Can anyone please suggest any additional modules that I may need to
use apart  from ip_nat,ip_conntrack, ip_nat_ftp and ip_conntrack_ftp.

Thanks in advance.
Durga Prasad.


^ permalink raw reply	[flat|nested] 64+ messages in thread
* Re: port Forwarding
@ 2004-11-16 17:01 diadicic
  0 siblings, 0 replies; 64+ messages in thread
From: diadicic @ 2004-11-16 17:01 UTC (permalink / raw)
  To: netfilter

Cool, I ll give that a try.

Sorry about the typo in the SNAT statment

Thanks again.

----- Original Message -----
From: Jason Opperisano <opie@817west.com>
Date: Tuesday, November 16, 2004 11:48 am
Subject: Re: port Forwarding

> On Tue, 2004-11-16 at 11:44, diadicic@optonline.net wrote:
> > Can someone help me understand this?
> > 
> >   I have a firewall setup up with two nic's in it.
> > 
> >                1 eth0 24.190.x.x  which is my Internet connection
> >                2 eth1 172.16.12.165 which is a local area network.
> > 
> >               I have a web server at 172.16.12.160  “I hope thats 
> clear”> 
> >     Now if I port forward this way it will not work.
> > 
> >              “iptables -A PREROUTING -i eth0 -t nat -p tcp –dport 
> 80 -j DNAT –to 
> >                 172.16.12.160:80”
> >                “iptables -A FORWARD -p tcp -d 172.16.12.160 
> –dport 80 -i eth0 -o eth1 
> >                  -j ACCEPT”
> > 
> > 
> > But if I do it this way It will work:
> > 
> >                  “iptables -t nat  -A PREROUTING -p tcp –dport 80 
> -d 24.190.x.x -i eth0 -j   
> >                    DNAT --to-destination 172.16.12.160  
> 172.16.12.160”> 
> >                    “iptables -A POSTROUTING -p tcp –dport 80 -d 
> 172.16.12.160 -j SNAT -o    
> >                      eth1 –to-source 172.16.12.165”
> > 
> > 
> > Could anyone please explain why the first way did not work, all 
> the directions I read claim that is how to port forward.
> 
> because the default gateway of 172.16.12.160 is not 172.16.12.165?
> 
> -j
> 
> --
> "Oh, so they have internet on computers now!"
> 	--The Simpsons
> 
> 
>



^ permalink raw reply	[flat|nested] 64+ messages in thread
* port Forwarding
@ 2004-11-16 16:44 diadicic
  2004-11-16 16:48 ` Jason Opperisano
  0 siblings, 1 reply; 64+ messages in thread
From: diadicic @ 2004-11-16 16:44 UTC (permalink / raw)
  To: netfilter

Can someone help me understand this?

  I have a firewall setup up with two nic's in it.

               1 eth0 24.190.x.x  which is my Internet connection
               2 eth1 172.16.12.165 which is a local area network.

              I have a web server at 172.16.12.160  “I hope thats clear”

    Now if I port forward this way it will not work.

             “iptables -A PREROUTING -i eth0 -t nat -p tcp –dport 80 -j DNAT –to 
                172.16.12.160:80”
               “iptables -A FORWARD -p tcp -d 172.16.12.160 –dport 80 -i eth0 -o eth1 
                 -j ACCEPT”


But if I do it this way It will work:

                 “iptables -t nat  -A PREROUTING -p tcp –dport 80 -d 24.190.x.x -i eth0 -j   
                   DNAT --to-destination 172.16.12.160  172.16.12.160”

                   “iptables -A POSTROUTING -p tcp –dport 80 -d 172.16.12.160 -j SNAT -o    
                     eth1 –to-source 172.16.12.165”


Could anyone please explain why the first way did not work, all the directions I read claim that is how to port forward.


Any help is appreciated



Thanks 
Dominic Iadicicco



^ permalink raw reply	[flat|nested] 64+ messages in thread
* Port forwarding
@ 2004-10-28  4:30 Mike
  2004-10-28 12:50 ` Jason Opperisano
  0 siblings, 1 reply; 64+ messages in thread
From: Mike @ 2004-10-28  4:30 UTC (permalink / raw)
  To: netfilter

Hi All

I bet this has been asked many times before but I have searched and
searched trying to find the answer.

Is it possible to port forward one port from the outside world to many
clients inside the LAN. I have it working fine for single addresses and
it seems I can list each IP forward individually so that
narc-forward.conf ends up huge as each line goes in for each IP address
on the network with the same port.

The question basically is to find out if there is anyway that a range of
IP addresses can be stipulated easily in narc-forward.conf???

Mike

^ permalink raw reply	[flat|nested] 64+ messages in thread
[parent not found: <20040917135140.AE3C66A5@mail.817west.com>]
[parent not found: <20040917132253.B6B1E6A5@mail.817west.com>]
[parent not found: <20040917123138.EC8FE6A5@mail.817west.com>]
* Port forwarding
@ 2004-09-17 12:32 KUCKAERTZ Régis - NVISION
  0 siblings, 0 replies; 64+ messages in thread
From: KUCKAERTZ Régis - NVISION @ 2004-09-17 12:32 UTC (permalink / raw)
  To: netfilter

Halo,

I've set up rules so that packets sent to $MASK_IP:$MASK_PORT are forwarded
to $REAL_IP:$REAL_PORT with the source address being replaced by $MASK_IP:

# 1. Changing destination address
$IPTABLES -t nat -A PREROUTING -p tcp --dest $MASK_IP --dport $MASK_PORT -j
DNAT --to-destination $REAL_IP:$REAL_PORT

# 2. Accepting forwarded packets
$IPTABLES -A FORWARD -p tcp --dest $REAL_IP --dport $REAL_PORT -j ACCEPT

# 3. IP masquerading after filtering
$IPTABLES -t nat -A POSTROUTING --dest $REAL_IP --dport $REAL_PORT -j SNAT
--to-source $MASK_IP


When I telnet on $MASK_IP:$MASK_PORT, it's hanging... I tried sniffing with
tcpdump (although I must honestly confess that I don't know if the following
request is good), and here is what I got:

$TCPDUMP \(dst host $MASK_IP and dst port $MASK_PORT\) or \(src host
$MASK_IP and src port $MASK_PORT\)
tcpdump: listening on eth0
14:32:28.568875 x.x.x.x.46569 > $REAL_IP.$REAL_PORT: S
2813621631:2813621631(0) win 5840 <mss 1460,sackOK,timestamp 46292274
0,nop,wscale 0> (DF) [tos 0x10] 
14:32:31.568875 x.x.x.x.46569 > $REAL_IP.$REAL_PORT: S
2813621631:2813621631(0) win 5840 <mss 1460,sackOK,timestamp 46292574
0,nop,wscale 0> (DF) [tos 0x10] 
14:32:37.568875 x.x.x.x.46569 > $REAL_IP.$REAL_PORT: S
2813621631:2813621631(0) win 5840 <mss 1460,sackOK,timestamp 46293174
0,nop,wscale 0> (DF) [tos 0x10] 

Nothing seems to get back... any idea?

Thanks in advance,

Régis KUCKAERTZ
-----------------------------------------
NVISION sa - Luxembourg
Internet Services & Network Programming

50, rue des Prés
L-7333 Steinsel
Tél: (+352) 26 34 09 08
Fax: (+352) 26 34 09 07
http://www.nvision.lu/



^ permalink raw reply	[flat|nested] 64+ messages in thread
* Port forwarding.
@ 2004-06-28  9:16 Gunnar Frödin
  2004-06-28  9:57 ` Antony Stone
  0 siblings, 1 reply; 64+ messages in thread
From: Gunnar Frödin @ 2004-06-28  9:16 UTC (permalink / raw)
  To: netfilter

Hi all.
I'm trying to setup a firewall/port forwarder but can't get things going.
Some facts:
LAN is my internal network and WAN is external.
I have a static ip# on WAN and LAN.
Access to SSH on firewall works.
IP Forwarding and NAT from LAN to WAN works :-)

The problem:
On my LAN i have another machine with web, mail, ftp-server(192.168.0.100)
witch have to be accessible from the WAN.
But I just cant get it working.

Question:
At http://iptables-tutorial.frozentux.net/iptables-tutorial.html#DNATTARGET
(Oskar Andreasson) says
Quote
"This last rule will seriously harm your logging, so it is really advisable
not to use this method, but the whole example is still a valid one for all
of those who can't afford to set up a specific DMZ or alike. What will
happen is this, packet comes from the Internet, gets SNAT'ed and DNAT'ed,
and finally hits the HTTP server (for example). The HTTP server now only
sees the request as if it was coming from the firewall, and hence logs all
requests from the internet as if they came from the firewall."
End quote.
Is there some way to do this so the logging sees the "right" IP# ???


Regards Gunnar Frödin (Sweden)

One more thing: I'm trying all this out with WMware(www.vmware.com/),
Virtual Machine Software, but I havent read anything about some limitations
with that.


# DNAT/SNAT Port Forwarding
# this is the prerouting dnat
iptables -A PREROUTING -t nat -p tcp -d 217.215.x.x --dport 25 -j
DNAT --to-destination 192.168.0.100:25
# This allows packets from external->internal
iptables -A FORWARD -p tcp -i eth0 -o eth1 -d 192.168.0.100 --dport 25 -m
state --state NEW,ESTABLISHED,RELATED -j ACCEPT
# This allows packets from internal->external
iptables -A FORWARD -p tcp -i eth1 -o eth0 -s 192.168.0.100 --sport 25 -m
state --state NEW,ESTABLISHED,RELATED -j ACCEPT
# This enables access to the 'public' server from the internal network
iptables -A POSTROUTING -t nat -p tcp -d 192.168.0.100 -s
192.168.0.0/24 --dport 25 -j SNAT --to-source 192.168.0.100:25




^ permalink raw reply	[flat|nested] 64+ messages in thread
* Re:  Forwarding and masquerading got broken
@ 2003-12-04  5:43 Lawrence G. Hunsicker
  2003-12-03  8:26 ` Port Forwarding Remus
  0 siblings, 1 reply; 64+ messages in thread
From: Lawrence G. Hunsicker @ 2003-12-04  5:43 UTC (permalink / raw)
  To: netfilter

Michael Gale said:

Hello,

	Look the section"
--snip--
# --------( Sysctl Tuning - Recommended Parameters )--------

# Turn off IP forwarding by default
# (this will be enabled if you require masquerading)

if [ -e /proc/sys/net/ipv4/ip_forward ]; then
   echo 0 > /proc/sys/net/ipv4/ip_forward
fi
--snip--

The "echo 0" in the "/proc/sys/net/ipv4/ip_forward" is disabling 
ip_forwarding -- which is need to forward packets.

Change the "echo 0" to "echo 1"

Mike:

Thanks for the suggestion.  Note, though, that further down in the file 
there is a parallel section cating 1 to the same address to turn on 
kernel forwarding.  I have checked the actual setting after boot up by 
lessing the address, and it is indeed already set to one.  I'll check 
changing this line, but I suspect that this is not where my problem is.

Any other suggestions?


-- 
Lawrence G. Hunsicker
lhunsicker@mchsi.com



^ permalink raw reply	[flat|nested] 64+ messages in thread
* RE: Port Forwarding
@ 2003-12-03 16:27 Mark E. Donaldson
  0 siblings, 0 replies; 64+ messages in thread
From: Mark E. Donaldson @ 2003-12-03 16:27 UTC (permalink / raw)
  To: 'Remus', netfilter

A method that works well for me, and I use it extensively, is to place all
your IP addresses in a text file, and feed the file to the script.  With
this method, all you need to do is update (edit) the text file as needed for
adding or deleting IP's.  For instance, if you wanted to sneak TFTP through
the firewall (which I don't really recommend), you could add this rule:

####################################################################
# TFTP
####################################################################
# if TFTP enabled redirect to port 69 on internal TFTP server
if [ "$TFTP_SERVER" = "1" ] ;
then
	while read TRUSTED;
	do
		$IPT -t nat -A PREROUTING -p udp -s $TRUSTED
--destination-port 69 -i $FW_INET_IFACE -j LOG --log-level $LOG_LEVEL
--log-prefix "DNAT IN TFTP OK: "
		$IPT -t nat -A PREROUTING -p udp -s $TRUSTED
--destination-port 69 -i $FW_INET_IFACE -j DNAT --to-destination
$INTERNAL_TFTP:69
	done < $TRUSTED_LIST
fi

-----Original Message-----
From: netfilter-admin@lists.netfilter.org
[mailto:netfilter-admin@lists.netfilter.org] On Behalf Of Remus
Sent: Wednesday, December 03, 2003 12:27 AM
To: netfilter@lists.netfilter.org
Subject: Port Forwarding 

Hi folks,

I have a PREROUTING rule:
iptables -t nat -A PREROUTING -d $EXTERNALIP_1 -s some_external_IP -p 47 -j
DNAT --to 192.168.0.19

How to add more source addresses which will be able to connect?


Thanks in advance

Remus






^ permalink raw reply	[flat|nested] 64+ messages in thread
* RE: Port Forwarding
@ 2003-10-29  2:24 Fritz Mesedilla
  0 siblings, 0 replies; 64+ messages in thread
From: Fritz Mesedilla @ 2003-10-29  2:24 UTC (permalink / raw)
  To: Jason Mallory, netfilter


I think we may be able to help you. Please give us what config you have done.

For a web server, some need to have 4 rules... prerouting a forward rule, postrouting and another forward rule.

If you have set iptables -P forward ACCEPT then you only need 2 rules... prerouting and postrouting rules.

Send us what you have done and we will try to help you.


Cheers,

fritz <www.mesedilla.com>
---
+ Basta Ikaw Lord



> -----Original Message-----
> From: Jason Mallory [mailto:jason@phxrising.com]
> Sent: Tuesday, October 28, 2003 6:17 AM
> To: netfilter@lists.netfilter.org
> Subject: Port Forwarding
> 
> 
> I am tring to do a simple port forwarding from the Internet 
> to a mcahine 
> on my LAN. This has proven IMPOSSIBE! No matter how I try to forward 
> ports, its not working. I am thinking about just setting up a simple 
> Windows XP box and doing it that way after trying for 12 hours and 5 
> different configuration methods. Any last suggestions before I switch?
> 
> 
> 

----------------------------------------------------------------------
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the sender immediately by e-mail and delete this e-mail from your
system. Please note that any views or opinions presented in this
email are solely those of the author and do not necessarily represent
those of the company. Finally, the recipient should check this email
and any attachments for the presence of viruses. The company accepts
no liability for any damage caused by any virus transmitted by this
email. 

Overture Media, Inc.
Direct Line: (632) 635-4785
Trunkline:   (632) 631-8971 Local 146
Fax: (632) 637-2206
Level 1 Summit Media Offices, Robinsons Galleria EDSA Cor. Ortigas Ave., Quezon City 1100



^ permalink raw reply	[flat|nested] 64+ messages in thread
* RE: Port Forwarding
@ 2003-10-28 13:12 Babar Kazmi
  0 siblings, 0 replies; 64+ messages in thread
From: Babar Kazmi @ 2003-10-28 13:12 UTC (permalink / raw)
  To: netfilter

[-- Attachment #1: Type: text/html, Size: 5378 bytes --]

^ permalink raw reply	[flat|nested] 64+ messages in thread
* RE: Port Forwarding
@ 2003-10-28 12:49 Gaby Schilders
  0 siblings, 0 replies; 64+ messages in thread
From: Gaby Schilders @ 2003-10-28 12:49 UTC (permalink / raw)
  To: netfilter list

No suggestions. Go for the WinXP solution if you feel more comfortable
with that.

<sarcasm>
Just make sure you don't come running back when it is haxored into
oblivion by a script-kiddy with too much time on his hands and a MS
30-day exploit in his hands will you?
</sarcasm>

If you think this to be a harsh reply, then maybe you can try to
include a little bit more about your situation the next time you ask
for help? Like what your setup is, what you've tried already, what
part of the fine manuals you didn't understand... That sort of
thing.

If you still want to put some effort into the Linux/netfilter
solution I suggest you do those things and put your problem on the
list again. (If you want to know where to look things up, by all
means ask).

Good luck!

Gaby

-----Original Message-----
From: Jason Mallory [mailto:jason@phxrising.com]
Sent: maandag 27 oktober 2003 23:17
To: netfilter@lists.netfilter.org
Subject: Port Forwarding


I am tring to do a simple port forwarding from the Internet to a mcahine 
on my LAN. This has proven IMPOSSIBE! No matter how I try to forward 
ports, its not working. I am thinking about just setting up a simple 
Windows XP box and doing it that way after trying for 12 hours and 5 
different configuration methods. Any last suggestions before I switch?




^ permalink raw reply	[flat|nested] 64+ messages in thread
* Port Forwarding
@ 2003-10-27 22:17 Jason Mallory
  2003-10-28 10:54 ` Rob Sterenborg
  0 siblings, 1 reply; 64+ messages in thread
From: Jason Mallory @ 2003-10-27 22:17 UTC (permalink / raw)
  To: netfilter

I am tring to do a simple port forwarding from the Internet to a mcahine 
on my LAN. This has proven IMPOSSIBE! No matter how I try to forward 
ports, its not working. I am thinking about just setting up a simple 
Windows XP box and doing it that way after trying for 12 hours and 5 
different configuration methods. Any last suggestions before I switch?



^ permalink raw reply	[flat|nested] 64+ messages in thread
* Port Forwarding
@ 2003-09-26  8:37 Aris  Santillan
  0 siblings, 0 replies; 64+ messages in thread
From: Aris  Santillan @ 2003-09-26  8:37 UTC (permalink / raw)
  To: netfilter (E-mail)

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

hi guys


i ve 2 server A and B
A have 190.200.1.62
B have 190.200.1.61


190.200.1.62 is binded to an external IP(203.167.117.154)
in the Cisco router.



i want to forward incoming HTTP request to 190.200.1.61 w/c is my 
web server

i do this


echo '1' > /etc/sys/net/ipv4/ip_forward

iptables -t nat -A prerouting -p tcp -i eth0 -d 190.200.1.62 --dport 80 -j DNAT --to 190.200.1.61:80
iptables -A FORWARD -p tcp -i eth0 -d 190.200.1.61 --dport 80 -j ACCEPT


but it seems doesnt work..... i need ur advice & solutions

thanks in advance
aris

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

^ permalink raw reply	[flat|nested] 64+ messages in thread
* RE: port forwarding
@ 2003-07-23  6:41 George Vieira
  0 siblings, 0 replies; 64+ messages in thread
From: George Vieira @ 2003-07-23  6:41 UTC (permalink / raw)
  To: Sathi; +Cc: Netfilter Mailling List (E-mail)

You can't. FTP doesn't send any header information like http's virtual host information on which site it's for.

the only option is to use different ports for different sites..

ftp www.domain/com:10021
ftp www.domain2/com:10022
ftp www.domain3/com:10023

that's the only what I know.

Thanks,
____________________________________________
George Vieira
Systems Manager
georgev@citadelcomputer.com.au

Citadel Computer Systems Pty Ltd
http://www.citadelcomputer.com.au

Phone   : +61 2 9955 2644
HelpDesk: +61 2 9955 2698
 

-----Original Message-----
From: Sathi [mailto:sathiyan@gmx.net]
Sent: Wednesday, July 23, 2003 4:06 PM
To: Netfilter Mailing List
Subject: port forwarding


Hello All,

I am running squid reverse proxy for 5 different web servers.

I want to provide ftp access to clients so that they can update the web page
content.

As all the host name resolve to the single address i find problem in port
forward the ftp request to the correct backend web server.

How to make port forward the ftp request to the correct web server using
iptables.

Regards
Sathi





^ permalink raw reply	[flat|nested] 64+ messages in thread
* port forwarding
@ 2003-07-23  6:06 Sathi
  2003-07-23  8:02 ` Nils Juergens
  0 siblings, 1 reply; 64+ messages in thread
From: Sathi @ 2003-07-23  6:06 UTC (permalink / raw)
  To: Netfilter Mailing List

Hello All,

I am running squid reverse proxy for 5 different web servers.

I want to provide ftp access to clients so that they can update the web page
content.

As all the host name resolve to the single address i find problem in port
forward the ftp request to the correct backend web server.

How to make port forward the ftp request to the correct web server using
iptables.

Regards
Sathi




^ permalink raw reply	[flat|nested] 64+ messages in thread
* RE: Port forwarding
@ 2003-06-05 23:08 George Vieira
  0 siblings, 0 replies; 64+ messages in thread
From: George Vieira @ 2003-06-05 23:08 UTC (permalink / raw)
  To: Dhyanesh Ramaiya, netfilter

PREROUTING only works for packets passing through the firewall and not FOR the firewall to itself. There is no NAT for an incoming connection on it's local process as it's ALREADY there at the service not a packet that's coming in. if you know what I mean.

If you had multiple IPs which were NATted to an internal server then you can NAT the OUTPUT chain but not when the destination IP is the firewall itself..

One sneaky what of doing it is to put a /etc/hosts file of the internal machine.. eg.

192.168.0.1           www.yourdomain.com

When you browse the name it'll go directly to the internal machine. But remember to use names not IPs..
Outsiders get NATed and the firewall browses by the internal machine.

Thanks,
____________________________________________
George Vieira
Systems Manager
georgev@citadelcomputer.com.au

Citadel Computer Systems Pty Ltd
http://www.citadelcomputer.com.au
 

-----Original Message-----
From: Dhyanesh Ramaiya [mailto:dhyanesh@intafrica.com]
Sent: Thursday, June 05, 2003 7:49 PM
To: netfilter@lists.netfilter.org
Subject: Port forwarding


Dear all,

I have a linux router (Redhat 9.0) with iptables 1.2.7a-2. I have setup port
forwarding rules as below to allow SMTP and POP3 to a machine on the
internal network.

iptables -t nat -A PREROUTING -j DNAT -p tcp -d <public_ip> --dport 110 --to
<private_ip>:110
iptables -t nat -A PREROUTING -j DNAT -p tcp -d <public_ip> --dport 25 --to
<private_ip>:25

What happens, is that when I try to telnet port 25 or 110 from the router
itself, it doesn't connect and gives the error "Connection refused".
However, from any other machine on the network it connects. Thinking that
some firewall rules might be blocking the connection, the default policy of
all chains is set to accept.

Dhyanesh Ramaiya
dhyanesh@intafrica.com




^ permalink raw reply	[flat|nested] 64+ messages in thread
* Re: Question about nfmark
@ 2003-06-04 19:53 Cedric Blancher
  2003-06-05  9:48 ` Port forwarding Dhyanesh Ramaiya
  0 siblings, 1 reply; 64+ messages in thread
From: Cedric Blancher @ 2003-06-04 19:53 UTC (permalink / raw)
  To: gupta; +Cc: netfilter

Le mer 04/06/2003 à 20:01, Abhinav Gupta a écrit :
> I am a newbie to netfilter. While going through some code, I saw a 
> comment that nfmark can be used for communicating between the different 
> hooks. Could someone please explain me how this can be done.

Netfilter gives you the ability to mark packets using mangle table MARK
target (mangle table is attached to every hook in the stack). This mark,
commonly called nfmark (Netfilter mark) is a field within the data
structure that contains the packet (skb). This means once a packet is
marked, mark will be carried the whole packet life into the system.

Now, you have a mark match that allows you to read nfmark field. This
means in on given hook, you can extract information from another hook
though nfmark.

An example... Suppose you implement DNAT. This sits in PREROUTING chain.

	iptables -t nat -A PREROUTING -d $PUB_IP -j DNAT --to $PRIV_IP

How can I filter packets destined to $PUB_IP form those which were
destined to $PRIV_IP as they appear the same way into FORWARD chain ?
Use mark.

	iptables -t mangle -A PREROUTING -d $PRIV_IP -j MARK --mark 0x01

Then, in filter table, I do this :

	iptables -A FORWARD -m mark --mark 0x01 -j DROP

As I don't people access directly my private IP. Doing this, you get in
FORWARD chain information that would not be available otherwise.


Besides this, nfmark is more powerful than this as it allows Netfilter
to communicate with routing and QoS processes. This means you can take
routing or QoS decisions based on nfmark. Transparent proxying can be
done using nfmark (see http://lartc.org/), as well as QoS. This allows
you to use all Netfilter packet matching capabilities for routing and
shaping.

-- 
Cédric Blancher  <blancher@cartel-securite.fr>
IT systems and networks security - Cartel Sécurité
Phone : +33 (0)1 44 06 97 87 - Fax: +33 (0)1 44 06 97 99
PGP KeyID:157E98EE  FingerPrint:FA62226DA9E72FA8AECAA240008B480E157E98EE


^ permalink raw reply	[flat|nested] 64+ messages in thread
* port forwarding
@ 2003-04-27  9:09 Fox
  2003-04-27  9:37 ` Rob Sterenborg
  0 siblings, 1 reply; 64+ messages in thread
From: Fox @ 2003-04-27  9:09 UTC (permalink / raw)
  To: netfilter

Hi Everybody.

I want to forward all the packets to port 80 and 443 to 16721 and
using the following rules:

# 80->16721->80
${IPTABLES} -t nat -A PREROUTING -s 0.0.0.0/0 -d 192.168.0.1 -p tcp --dport 80 -j DNAT \
--to-destination 192.168.0.1:16721
${IPTABLES} -t nat -A POSTROUTING -s 192.168.0.1 -d 0/0 -p tcp --sport 16721 -j SNAT \
 --to-source 192.168.0.1:80

# 443->16721->443
${IPTABLES} -t nat -A PREROUTING -s 0.0.0.0/0 -d 192.168.0.1 -p tcp --dport 443 -j DNAT \
--to-destination 192.168.0.1:16721
${IPTABLES} -t nat -A POSTROUTING -s 192.168.0.1 -d 0/0 -p tcp --sport 16721 -j SNAT \
 --to-source 192.168.0.1:443

I'm just wondering - won't the source address of packets to 443 be
changed to 192.168.0.1:80 instead of 192.168.0.1:443 when they're
replied to the client?

I don't know what type of connection tracking to use. Your help is
appreciated.

Thanks in advance.

Fox



^ permalink raw reply	[flat|nested] 64+ messages in thread
* Port Forwarding
@ 2003-04-24  5:58 Brei, Matt
  2003-04-24 17:26 ` Dan Egli
  0 siblings, 1 reply; 64+ messages in thread
From: Brei, Matt @ 2003-04-24  5:58 UTC (permalink / raw)
  To: netfilter


[-- Attachment #1.1: Type: text/plain, Size: 621 bytes --]

Hello all.  
 
I'm using iptables on RH 8.0 to route and firewall my cable connection
to the rest of the lan.  My problem is joining games (Ghost Recon) on
ubi.com from behind the firewall.  Ubi.com requires port 80 for http
which works fine, port 6667 for chat which also works fine, and
40000-42000 for the game (I'm assuming) which seems to be random when I
run nmap on machines running the game with no firewall.  Is there a way
to allow one or multiple machines behind the firewall to join/host a
game by forwarding the ports.  I attached my iptables script that I'm
currently using.
 
Thanks,
Matt
 

[-- Attachment #1.2: Type: text/html, Size: 4544 bytes --]

[-- Attachment #2: route.rtf.txt --]
[-- Type: text/plain, Size: 7632 bytes --]


#!/bin/sh
#
# rc.firewall - Initial SIMPLE IP Firewall script for Linux 2.4.x and iptables
#
# Copyright (C) 2001  Oskar Andreasson &lt;blueflux@koffein.net&gt;
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program or from the site that you downloaded it
# from; if not, write to the Free Software Foundation, Inc., 59 Temple
# Place, Suite 330, Boston, MA  02111-1307   USA
#

###########################################################################
#
# 1. Configuration options.
#

###########################################################################
#
# Local Area Network configuration.
#
# your LAN's IP range and localhost IP. /24 means to only use the first 24 
# bits of the 32 bit IP adress. the same as netmask 255.255.255.0
#

LAN_IP="192.168.0.254"
LAN_IP_RANGE="192.168.0.0/16"
LAN_BCAST_ADRESS="192.168.255.255"
LAN_IFACE="eth1"

###########################################################################
#
w
# Localhost Configuration.
#

LO_IFACE="lo"
LO_IP="127.0.0.1"

###########################################################################
#
# Internet Configuration.
#

INET_IP="12.251.163.214"
INET_IFACE="eth0"

###########################################################################
#
# IPTables Configuration.
#

IPTABLES="/sbin/iptables"

###########################################################################
#
# 2. Module loading.
#

#
# Needed to initially load modules
#
/sbin/depmod -a

#
# Adds some iptables targets like LOG, REJECT and MASQUARADE.
#
/sbin/modprobe ip_conntrack
/sbin/modprobe ip_tables
/sbin/modprobe iptable_filter
/sbin/modprobe iptable_mangle
/sbin/modprobe iptable_nat
/sbin/modprobe ipt_LOG
#/sbin/modprobe ipt_REJECT
#/sbin/modprobe ipt_MASQUERADE

#
# Support for owner matching
#
#/sbin/modprobe ipt_owner

#
# Support for connection tracking of FTP and IRC.
#
#/sbin/modprobe ip_conntrack_ftp
#/sbin/modprobe ip_conntrack_irc


###########################################################################
#
# 3. /proc set up.
#
# Enable ip_forward if you have two or more networks, including the
# Internet, that needs forwarding of packets through this box. This is
# critical since it is turned off as default in Linux.
#

echo "1" > /proc/sys/net/ipv4/ip_forward

#
# Dynamic IP users:
#
#echo "1" > /proc/sys/net/ipv4/ip_dynaddr

###########################################################################
#
# 4. IPTables rules set up.
#
# Set default policies for the INPUT, FORWARD and OUTPUT chains.
# Drop ALL packets

$IPTABLES -P INPUT DROP
$IPTABLES -P OUTPUT DROP
$IPTABLES -P FORWARD DROP

#
# bad_tcp_packets chain
#
# Take care of bad TCP packets that we don't want.
#

$IPTABLES -N bad_tcp_packets
$IPTABLES -A bad_tcp_packets -p tcp ! --syn -m state --state NEW -j LOG \
--log-prefix "New not syn:"
$IPTABLES -A bad_tcp_packets -p tcp ! --syn -m state --state NEW -j DROP

#
# Do some checks for obviously spoofed IP's
#

$IPTABLES -A bad_tcp_packets -i $INET_IFACE -s 192.168.0.0/16 -j DROP
$IPTABLES -A bad_tcp_packets -i $INET_IFACE -s 10.0.0.0/8 -j DROP
$IPTABLES -A bad_tcp_packets -i $INET_IFACE -s 172.16.0.0/12 -j DROP

#
# Enable simple IP Forwarding and Network Address Translation
#

$IPTABLES -t nat -A POSTROUTING -o $INET_IFACE -j SNAT --to-source $INET_IP

#
# Bad TCP packets we don't want
#

$IPTABLES -A FORWARD -p tcp -j bad_tcp_packets

#
# Accept the packets we actually want to forward
#

$IPTABLES -A FORWARD -i $LAN_IFACE -j ACCEPT
$IPTABLES -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -A FORWARD -m limit --limit 3/minute --limit-burst 3 -j LOG \
--log-level DEBUG --log-prefix "IPT FORWARD packet died: "

#
# Create separate chains for ICMP, TCP and UDP to traverse
#

$IPTABLES -N icmp_packets
$IPTABLES -N tcp_packets
$IPTABLES -N udpincoming_packets

#
# The allowed chain for TCP connections
#

$IPTABLES -N allowed
$IPTABLES -A allowed -p TCP --syn -j ACCEPT
$IPTABLES -A allowed -p TCP -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -A allowed -p TCP -j DROP

#
# ICMP rules
#

# Changed rules totally
$IPTABLES -A icmp_packets -p ICMP -s 0/0 --icmp-type 8 -j ACCEPT
$IPTABLES -A icmp_packets -p ICMP -s 0/0 --icmp-type 11 -j ACCEPT

#
# TCP rules
#

$IPTABLES -A tcp_packets -p TCP -s 0/0 --dport 21 -j allowed
$IPTABLES -A tcp_packets -p TCP -s 0/0 --dport 22 -j allowed
$IPTABLES -A tcp_packets -p TCP -s 0/0 --dport 25 -j allowed
$IPTABLES -A tcp_packets -p TCP -s 0/0 --dport 80 -j allowed
$IPTABLES -A tcp_packets -p TCP -s 0/0 --dport 110 -j allowed
$IPTABLES -A tcp_packets -p TCP -s 0/0 --dport 113 -j allowed
$IPTABLES -A tcp_packets -p TCP -s 0/0 --dport 1723 -j allowed

#
# UDP ports
#

# nondocumented commenting out of these rules
#$IPTABLES -A udpincoming_packets -p UDP -s 0/0 --source-port 53 -j ACCEPT
#$IPTABLES -A udpincoming_packets -p UDP -s 0/0 --source-port 123 -j ACCEPT
$IPTABLES -A udpincoming_packets -p UDP -s 0/0 --source-port 2074 -j ACCEPT
$IPTABLES -A udpincoming_packets -p UDP -s 0/0 --source-port 4000 -j ACCEPT

##########################
# INPUT chain
#
# Bad TCP packets we don't want.
#

$IPTABLES -A INPUT -p tcp -j bad_tcp_packets

#
# Rules for incoming packets from the internet.
#

$IPTABLES -A INPUT -p ICMP -i $INET_IFACE -j icmp_packets
$IPTABLES -A INPUT -p TCP -i $INET_IFACE -j tcp_packets
$IPTABLES -A INPUT -p UDP -i $INET_IFACE -j udpincoming_packets

#
# VPN for incoming connections to 192.168.0.1
#

$IPTABLES -t nat -A PREROUTING -i eth0 -p tcp --dport 1723 -j DNAT --to 192.168.0.1
$IPTABLES -t nat -A PREROUTING -i eth0 -p 47 -j DNAT --to 192.168.0.1
$IPTABLES -A FORWARD -p tcp -d 192.168.0.1/16 --dport 1723 -j ACCEPT
$IPTABLES -A FORWARD -p 47 -d 192.168.0.1/16 -j ACCEPT

#
#E-Mail routes to 192.168.0.1 
#

$IPTABLES -t nat -A PREROUTING -i eth0 -p tcp --dport 25 -j DNAT --to 192.168.0.1
$IPTABLES -t nat -A PREROUTING -i eth0 -p tcp --dport 110 -j DNAT --to 192.168.0.1
$IPTABLES -A FORWARD -p tcp -d 192.168.0.1 --dport 25 -j ACCEPT
$IPTABLES -A FORWARD -p tcp -s 192.168.0.1 --dport 25 -j ACCEPT

# Rules for special networks not part of the Internet
#

$IPTABLES -A INPUT -p ALL -i $LAN_IFACE -d $LAN_BCAST_ADRESS -j ACCEPT
$IPTABLES -A INPUT -p ALL -i $LO_IFACE -s $LO_IP -j ACCEPT
$IPTABLES -A INPUT -p ALL -i $LO_IFACE -s $LAN_IP -j ACCEPT
$IPTABLES -A INPUT -p ALL -i $LO_IFACE -s $INET_IP -j ACCEPT
$IPTABLES -A INPUT -p ALL -i $LAN_IFACE -s $LAN_IP_RANGE -j ACCEPT
$IPTABLES -A INPUT -p ALL -d $INET_IP -m state --state ESTABLISHED,RELATED \
-j ACCEPT
$IPTABLES -A INPUT -m limit --limit 3/minute --limit-burst 3 -j LOG \
--log-level DEBUG --log-prefix "IPT INPUT packet died: "

###############################
# OUTPUT chain
#
#
# Bad TCP packets we don't want.
#

$IPTABLES -A OUTPUT -p tcp -j bad_tcp_packets

#
# Special OUTPUT rules to decide which IP's to allow.
#

$IPTABLES -A OUTPUT -p ALL -s $LO_IP -j ACCEPT
$IPTABLES -A OUTPUT -p ALL -s $LAN_IP -j ACCEPT
$IPTABLES -A OUTPUT -p ALL -s $INET_IP -j ACCEPT

#
# Log weird packets that don't match the above.
#

$IPTABLES -A OUTPUT -m limit --limit 3/minute --limit-burst 3 -j LOG \
--log-level DEBUG --log-prefix "IPT OUTPUT packet died: "


^ permalink raw reply	[flat|nested] 64+ messages in thread
* Port forwarding
@ 2003-04-24  5:20 Brei, Matt
  0 siblings, 0 replies; 64+ messages in thread
From: Brei, Matt @ 2003-04-24  5:20 UTC (permalink / raw)
  To: netfilter

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

Hello all.  
 
I'm using iptables on RH 8.0 to route and firewall my cable connection
to the rest of the lan.  My problem is joining games (Ghost Recon) on
ubi.com from behind the firewall.  Ubi.com requires port 80 for http
which works fine, port 6667 for chat which also works fine, and
40000-42000 for the game (I'm assuming) which seems to be random when I
run nmap on machines running the game with no firewall.  Is there a way
to allow one or multiple machines behind the firewall to join/host a
game by forwarding the ports.  I attached my iptables script that I'm
currently using.
 
Thanks,
Matt
 
 
#!/bin/sh
#
# rc.firewall - Initial SIMPLE IP Firewall script for Linux 2.4.x and
iptables
#
# Copyright (C) 2001  Oskar Andreasson &lt;blueflux@koffein.net&gt;
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program or from the site that you downloaded it
# from; if not, write to the Free Software Foundation, Inc., 59 Temple
# Place, Suite 330, Boston, MA  02111-1307   USA
#
 
########################################################################
###
#
# 1. Configuration options.
#
 
########################################################################
###
#
# Local Area Network configuration.
#
# your LAN's IP range and localhost IP. /24 means to only use the first
24 
# bits of the 32 bit IP adress. the same as netmask 255.255.255.0
#
 
LAN_IP="192.168.0.254"
LAN_IP_RANGE="192.168.0.0/16"
LAN_BCAST_ADRESS="192.168.255.255"
LAN_IFACE="eth1"
 
########################################################################
###
#
w
# Localhost Configuration.
#
 
LO_IFACE="lo"
LO_IP="127.0.0.1"
 
########################################################################
###
#
# Internet Configuration.
#
 
INET_IP="12.251.163.214"
INET_IFACE="eth0"
 
########################################################################
###
#
# IPTables Configuration.
#
 
IPTABLES="/sbin/iptables"
 
########################################################################
###
#
# 2. Module loading.
#
 
#
# Needed to initially load modules
#
/sbin/depmod -a
 
#
# Adds some iptables targets like LOG, REJECT and MASQUARADE.
#
/sbin/modprobe ip_conntrack
/sbin/modprobe ip_tables
/sbin/modprobe iptable_filter
/sbin/modprobe iptable_mangle
/sbin/modprobe iptable_nat
/sbin/modprobe ipt_LOG
#/sbin/modprobe ipt_REJECT
#/sbin/modprobe ipt_MASQUERADE
 
#
# Support for owner matching
#
#/sbin/modprobe ipt_owner
 
#
# Support for connection tracking of FTP and IRC.
#
#/sbin/modprobe ip_conntrack_ftp
#/sbin/modprobe ip_conntrack_irc
 
 
########################################################################
###
#
# 3. /proc set up.
#
# Enable ip_forward if you have two or more networks, including the
# Internet, that needs forwarding of packets through this box. This is
# critical since it is turned off as default in Linux.
#
 
echo "1" > /proc/sys/net/ipv4/ip_forward
 
#
# Dynamic IP users:
#
#echo "1" > /proc/sys/net/ipv4/ip_dynaddr
 
########################################################################
###
#
# 4. IPTables rules set up.
#
# Set default policies for the INPUT, FORWARD and OUTPUT chains.
# Drop ALL packets
 
$IPTABLES -P INPUT DROP
$IPTABLES -P OUTPUT DROP
$IPTABLES -P FORWARD DROP
 
#
# bad_tcp_packets chain
#
# Take care of bad TCP packets that we don't want.
#
 
$IPTABLES -N bad_tcp_packets
$IPTABLES -A bad_tcp_packets -p tcp ! --syn -m state --state NEW -j LOG
\
--log-prefix "New not syn:"
$IPTABLES -A bad_tcp_packets -p tcp ! --syn -m state --state NEW -j DROP
 
#
# Do some checks for obviously spoofed IP's
#
 
$IPTABLES -A bad_tcp_packets -i $INET_IFACE -s 192.168.0.0/16 -j DROP
$IPTABLES -A bad_tcp_packets -i $INET_IFACE -s 10.0.0.0/8 -j DROP
$IPTABLES -A bad_tcp_packets -i $INET_IFACE -s 172.16.0.0/12 -j DROP
 
#
# Enable simple IP Forwarding and Network Address Translation
#
 
$IPTABLES -t nat -A POSTROUTING -o $INET_IFACE -j SNAT --to-source
$INET_IP
 
#
# Bad TCP packets we don't want
#
 
$IPTABLES -A FORWARD -p tcp -j bad_tcp_packets
 
#
# Accept the packets we actually want to forward
#
 
$IPTABLES -A FORWARD -i $LAN_IFACE -j ACCEPT
$IPTABLES -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -A FORWARD -m limit --limit 3/minute --limit-burst 3 -j LOG \
--log-level DEBUG --log-prefix "IPT FORWARD packet died: "
 
#
# Create separate chains for ICMP, TCP and UDP to traverse
#
 
$IPTABLES -N icmp_packets
$IPTABLES -N tcp_packets
$IPTABLES -N udpincoming_packets
 
#
# The allowed chain for TCP connections
#
 
$IPTABLES -N allowed
$IPTABLES -A allowed -p TCP --syn -j ACCEPT
$IPTABLES -A allowed -p TCP -m state --state ESTABLISHED,RELATED -j
ACCEPT
$IPTABLES -A allowed -p TCP -j DROP
 
#
# ICMP rules
#
 
# Changed rules totally
$IPTABLES -A icmp_packets -p ICMP -s 0/0 --icmp-type 8 -j ACCEPT
$IPTABLES -A icmp_packets -p ICMP -s 0/0 --icmp-type 11 -j ACCEPT
 
#
# TCP rules
#
 
$IPTABLES -A tcp_packets -p TCP -s 0/0 --dport 21 -j allowed
$IPTABLES -A tcp_packets -p TCP -s 0/0 --dport 22 -j allowed
$IPTABLES -A tcp_packets -p TCP -s 0/0 --dport 25 -j allowed
$IPTABLES -A tcp_packets -p TCP -s 0/0 --dport 80 -j allowed
$IPTABLES -A tcp_packets -p TCP -s 0/0 --dport 110 -j allowed
$IPTABLES -A tcp_packets -p TCP -s 0/0 --dport 113 -j allowed
$IPTABLES -A tcp_packets -p TCP -s 0/0 --dport 1723 -j allowed
 
#
# UDP ports
#
 
# nondocumented commenting out of these rules
#$IPTABLES -A udpincoming_packets -p UDP -s 0/0 --source-port 53 -j
ACCEPT
#$IPTABLES -A udpincoming_packets -p UDP -s 0/0 --source-port 123 -j
ACCEPT
$IPTABLES -A udpincoming_packets -p UDP -s 0/0 --source-port 2074 -j
ACCEPT
$IPTABLES -A udpincoming_packets -p UDP -s 0/0 --source-port 4000 -j
ACCEPT
 
##########################
# INPUT chain
#
# Bad TCP packets we don't want.
#
 
$IPTABLES -A INPUT -p tcp -j bad_tcp_packets
 
#
# Rules for incoming packets from the internet.
#
 
$IPTABLES -A INPUT -p ICMP -i $INET_IFACE -j icmp_packets
$IPTABLES -A INPUT -p TCP -i $INET_IFACE -j tcp_packets
$IPTABLES -A INPUT -p UDP -i $INET_IFACE -j udpincoming_packets
 
#
# VPN for incoming connections to 192.168.0.1
#
 
$IPTABLES -t nat -A PREROUTING -i eth0 -p tcp --dport 1723 -j DNAT --to
192.168.0.1
$IPTABLES -t nat -A PREROUTING -i eth0 -p 47 -j DNAT --to 192.168.0.1
$IPTABLES -A FORWARD -p tcp -d 192.168.0.1/16 --dport 1723 -j ACCEPT
$IPTABLES -A FORWARD -p 47 -d 192.168.0.1/16 -j ACCEPT
 
#
#E-Mail routes to 192.168.0.1 
#
 
$IPTABLES -t nat -A PREROUTING -i eth0 -p tcp --dport 25 -j DNAT --to
192.168.0.1
$IPTABLES -t nat -A PREROUTING -i eth0 -p tcp --dport 110 -j DNAT --to
192.168.0.1
$IPTABLES -A FORWARD -p tcp -d 192.168.0.1 --dport 25 -j ACCEPT
$IPTABLES -A FORWARD -p tcp -s 192.168.0.1 --dport 25 -j ACCEPT
 
# Rules for special networks not part of the Internet
#
 
$IPTABLES -A INPUT -p ALL -i $LAN_IFACE -d $LAN_BCAST_ADRESS -j ACCEPT
$IPTABLES -A INPUT -p ALL -i $LO_IFACE -s $LO_IP -j ACCEPT
$IPTABLES -A INPUT -p ALL -i $LO_IFACE -s $LAN_IP -j ACCEPT
$IPTABLES -A INPUT -p ALL -i $LO_IFACE -s $INET_IP -j ACCEPT
$IPTABLES -A INPUT -p ALL -i $LAN_IFACE -s $LAN_IP_RANGE -j ACCEPT
$IPTABLES -A INPUT -p ALL -d $INET_IP -m state --state
ESTABLISHED,RELATED \
-j ACCEPT
$IPTABLES -A INPUT -m limit --limit 3/minute --limit-burst 3 -j LOG \
--log-level DEBUG --log-prefix "IPT INPUT packet died: "
 
###############################
# OUTPUT chain
#
#
# Bad TCP packets we don't want.
#
 
$IPTABLES -A OUTPUT -p tcp -j bad_tcp_packets
 
#
# Special OUTPUT rules to decide which IP's to allow.
#
 
$IPTABLES -A OUTPUT -p ALL -s $LO_IP -j ACCEPT
$IPTABLES -A OUTPUT -p ALL -s $LAN_IP -j ACCEPT
$IPTABLES -A OUTPUT -p ALL -s $INET_IP -j ACCEPT
 
#
# Log weird packets that don't match the above.
#
 
$IPTABLES -A OUTPUT -m limit --limit 3/minute --limit-burst 3 -j LOG \
--log-level DEBUG --log-prefix "IPT OUTPUT packet died: "
 
 
 

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

^ permalink raw reply	[flat|nested] 64+ messages in thread
* port forwarding
@ 2002-12-05 20:56 Maxim Berlin
  2002-12-07  7:16 ` Andrew Smith
  0 siblings, 1 reply; 64+ messages in thread
From: Maxim Berlin @ 2002-12-05 20:56 UTC (permalink / raw)
  To: netfilter

Hello all,

Players at my office asks me to give them access to outside counterstrike
server, UDP 21705. unfortunatelly, i am brand new in iptables, so i've
read the docs and started make rules, but they does not work.
Then i've tried simple
root@woody~/iptables>cat 1.sh
#!/bin/sh
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -v -F -t nat
iptables -v -F
iptables -v -A FORWARD -p tcp --dport 205 -j ACCEPT
iptables -v -t nat -A PREROUTING -p tcp --dport 205 -j DNAT --to-destination 172.17.32.12:25

, then telnet to woody:205 and there is no refusal and no answer.

root@woody~/iptables>cat /proc/net/ip_conntrack
[...]
tcp      6 118 SYN_SENT src=172.17.32.5 dst=172.17.144.110 sport=2020 dport=205 [UNREPLIED] src=172.17.32.12 dst=172.17.32.5 sport=25 dport=2020 use=1

Can someone please tell me, what i am doing wrong? why [UNREPLIED]?
should i create rule to pass packets back from 172.17.32.5 to client?

p.s. iptables v1.2.6a, kernel 2.4.18

Best wishes,
 Maxim                          mailto:mak@rtsnet.ru



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

end of thread, other threads:[~2009-10-11 13:56 UTC | newest]

Thread overview: 64+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-11  0:30 Port Forwarding jen140
2009-10-11  1:36 ` John A. Sullivan III
2009-10-11  8:16 ` Brian Austin - Standard Universal
2009-10-11  8:37 ` Pascal Hambourg
  -- strict thread matches above, loose matches on Subject: below --
2009-10-11 13:56 jen140
2009-10-11  2:00 jen140
2009-05-28 19:50 Barry A Rich
2009-06-05 13:47 ` Aleksander Kamenik
2008-12-12 23:33 Port forwarding Błażej Ślusarek
2008-12-13 16:36 ` Elvir Kuric
2009-02-04 17:48 ` Błażej Ślusarek
2009-02-04 18:38   ` Ivan Petrushev
2006-02-28 13:27 Stian B. Barmen
2005-02-23  8:36 port forwarding DurgaPrasad Adusumalli
2004-11-16 17:01 port Forwarding diadicic
2004-11-16 16:44 diadicic
2004-11-16 16:48 ` Jason Opperisano
2004-10-28  4:30 Port forwarding Mike
2004-10-28 12:50 ` Jason Opperisano
     [not found] <20040917135140.AE3C66A5@mail.817west.com>
2004-09-17 13:57 ` Jason Opperisano
2004-09-17 14:09   ` KUCKAERTZ Régis - NVISION
     [not found]   ` <-4718906956710508172@unknownmsgid>
2004-09-19 10:06     ` Mohamed Eldesoky
     [not found] <20040917132253.B6B1E6A5@mail.817west.com>
2004-09-17 13:33 ` Jason Opperisano
2004-09-17 13:52   ` KUCKAERTZ Régis - NVISION
     [not found] <20040917123138.EC8FE6A5@mail.817west.com>
2004-09-17 12:55 ` Jason Opperisano
2004-09-17 13:23   ` KUCKAERTZ Régis - NVISION
2004-09-17 12:32 KUCKAERTZ Régis - NVISION
2004-06-28  9:16 Gunnar Frödin
2004-06-28  9:57 ` Antony Stone
2004-06-28 10:18   ` Gunnar Frödin
2004-06-28 10:34     ` Antony Stone
2004-06-28 12:20       ` Gunnar Frödin
2004-06-28 12:52         ` Antony Stone
2004-06-28 13:21           ` Gunnar Frödin
2003-12-04  5:43 Forwarding and masquerading got broken Lawrence G. Hunsicker
2003-12-03  8:26 ` Port Forwarding Remus
2003-12-03  8:44   ` Rob Sterenborg
2003-12-03  8:44   ` Ray Leach
2003-12-03 16:27   ` Mark E. Donaldson
2003-12-03 16:38     ` Rimas
2003-12-03 16:27 Mark E. Donaldson
2003-10-29  2:24 Fritz Mesedilla
2003-10-28 13:12 Babar Kazmi
2003-10-28 12:49 Gaby Schilders
2003-10-27 22:17 Jason Mallory
2003-10-28 10:54 ` Rob Sterenborg
2003-09-26  8:37 Aris  Santillan
2003-07-23  6:41 port forwarding George Vieira
2003-07-23  6:06 Sathi
2003-07-23  8:02 ` Nils Juergens
2003-06-05 23:08 Port forwarding George Vieira
2003-06-04 19:53 Question about nfmark Cedric Blancher
2003-06-05  9:48 ` Port forwarding Dhyanesh Ramaiya
2003-06-06  8:15   ` Philip Craig
2003-06-06 10:23     ` Dhyanesh Ramaiya
2003-04-27  9:09 port forwarding Fox
2003-04-27  9:37 ` Rob Sterenborg
2003-04-24  5:58 Port Forwarding Brei, Matt
2003-04-24 17:26 ` Dan Egli
2003-04-24  5:20 Port forwarding Brei, Matt
2002-12-05 20:56 port forwarding Maxim Berlin
2002-12-07  7:16 ` Andrew Smith
2002-12-07 12:11   ` Roy Sigurd Karlsbakk
2002-12-07 13:03     ` Andrew Smith
2002-12-07 13:45       ` Roy Sigurd Karlsbakk
2002-12-07 14:14         ` Andrew Smith

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).