All of lore.kernel.org
 help / color / mirror / Atom feed
* RE: Not quite understanding DNAT
@ 2003-07-24 17:14 Daniel Chemko
  2003-07-24 17:47 ` Ramin Dousti
  0 siblings, 1 reply; 8+ messages in thread
From: Daniel Chemko @ 2003-07-24 17:14 UTC (permalink / raw)
  To: Coutts, Ashe (Testing Account), netfilter

This behavior is to be expected, if not counter-intuitive to what you
could imagine, yes. ifconfig is b0rked in that way.

'ip addr' gives a more realistic appearance as to what is going on
internally if you use it instead of ifconfig or the like. I have had
issues with Redhat 9 and aliases, so I basically rewrote their aliasing
code to use 'ip addr' instead of ifconfig. It works a lot better than
eth:x even though I do create the aliases, I just use the ip addresses
for the real filtering.

Example:

I have 2 Interfaces

Internal: 192.168.1.0/27
External: 10.1.1.0/27

'ip addr' would look like this to me:

1: eth0: <BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast qlen 100
    link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.1/27 brd 192.168.1.31 scope global eth0
inet 192.168.1.2/27 brd 192.168.1.31 scope global secondary eth0:0
inet 192.168.1.3/27 brd 192.168.1.31 scope global secondary eth0:1
inet 192.168.1.4/27 brd 192.168.1.31 scope global secondary eth0:2
...
inet 192.168.1.30/27 brd 192.168.1.31 scope global secondary eth0:30

2: eth0: <BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast qlen 100
    link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
inet 10.1.1.1/27 brd 10.1.1.31 scope global eth1
inet 10.1.1.2/27 brd 10.1.1.31 scope global secondary eth1:0
inet 10.1.1.3/27 brd 10.1.1.31 scope global secondary eth1:1
inet 10.1.1.4/27 brd 10.1.1.31 scope global secondary eth1:2
...
inet 10.1.1.30/27 brd 10.1.1.31 scope global secondary eth1:30


Now when you want to use 192.168.1.4, or eth0:2 for ssh for instance,
you would just define it as:

iptables -A INPUT --destination 192.168.1.4 -p tcp --dport 22 -j ACCEPT

Some people might get anal and include the -i eth0 but that is pretty
redundant unless you are worried about spoofers and have rp_filter
/source route disabled, (bridging) etc..

That meets your requirements. All it means is that iptables needs to use
destination addresses instead of interface addresses to use
multiple-ip-per-if filtering. 

-----Original Message-----
From: Aldo S. Lagana [mailto:alagana@discmail.com] 
Sent: Thursday, July 24, 2003 9:44 AM
To: 'Coutts, Ashe (Testing Account)'; netfilter@lists.netfilter.org
Subject: RE: Not quite understanding DNAT

Ethernet aliases - are just aliases - that means they are a different
name
for the same thing.  So your eth0:x interface is actually eth0 to many
services that run on linux.  Netfilter (iptables) works perfectly well
with
aliases and you can specify rules with aliases.

It is the end server applications that are not very
alias-friendly...FreeS/WAN is one of them - and like you said - SHH is
one
too.


-----Original Message-----
From: netfilter-admin@lists.netfilter.org
[mailto:netfilter-admin@lists.netfilter.org] On Behalf Of Coutts, Ashe
(Testing Account)
Sent: Thursday, July 24, 2003 12:23 PM
To: netfilter@lists.netfilter.org

I have set up a very basic firewall for our system. 
We have 126 addresses to be used to/from the outside world
(204.48.178.0/25)

and are using 10.x numbers on the inside.

It is working almost as I expected except for the following. The DNAT 
connections come into the system fine but are seen as originating from
the 
eth0 interface rather than their eth0:x interface. So, when attaching to
a
linux 
cpu with ssh I am needing to place the ip# for the eth0 interface in the

hosts.allow file rather than the much more restrictive eth0:x ip#. Can
it be
set 
up so the connection is between the external eth0:x ip# and its linked
internal 
ip#?



^ permalink raw reply	[flat|nested] 8+ messages in thread
* RE: Not quite understanding DNAT
@ 2003-07-24 22:06 George Vieira
  0 siblings, 0 replies; 8+ messages in thread
From: George Vieira @ 2003-07-24 22:06 UTC (permalink / raw)
  To: netfilter

basically, I stay away from aliases now. I'd stick to iproute2 commands and put all the IPs into the eth0 devices and not aliases..

so then it becomes..

ip addr add 204.48.178.3/25 broadcast 204.48.178.127 dev eth0
ip addr add 204.48.178.4/25 broadcast 204.48.178.127 dev eth0
ip addr add 204.48.178.5/25 broadcast 204.48.178.127 dev eth0


ifconfig won't see the IPs added so you use iproute2 command to see them.

ip addr show


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

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


^ permalink raw reply	[flat|nested] 8+ messages in thread
* Re: DNAT question..
@ 2003-07-24  8:29 Philip Craig
  2003-07-24  8:56 ` Rio Martin.
  0 siblings, 1 reply; 8+ messages in thread
From: Philip Craig @ 2003-07-24  8:29 UTC (permalink / raw)
  To: Rio Martin.; +Cc: netfilter

Rio Martin. wrote:
> Dear all,
> I describe first about my network:
> 
> INTERNET --- eth0 [ NAT+Firewall Linux ] eth1 --- LAN
> 
> eth0 would be my public ip = 211.1.1.10
> eth1 would be my private ip = 192.168.1.1
> 
> On NAT+Firewall Linux i applied this rule:
> iptables -t nat -A PREROUTING -p tcp -d 211.1.1.10 --dport 80 -j DNAT --to 
> 192.168.1.2:80
> This is rule for redirecting to local webserver.
> 
> I tried to test it from outside network (internet), surf to http://211.1.1.10 
> and it succeed.
> But from inside LAN network (192.168.1.3) i am unable to browse to 
> http://211.1.1.10

You need to SNAT internal connections so that replies go via the
firewall instead of directly to the client, otherwise the firewall
cannot reverse the DNAT and the client drops the reply packet.

Try this rule:

iptables -t nat -A POSTROUTING -p tcp -s 192.168.1.0/24 -d 192.168.1.2 --dport 80 -j SNAT --to 192.168.1.1

-- 
Philip Craig - philipc@snapgear.com - http://www.SnapGear.com
SnapGear - Custom Embedded Solutions and Security Appliances



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

end of thread, other threads:[~2003-07-25 10:10 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-24 17:14 Not quite understanding DNAT Daniel Chemko
2003-07-24 17:47 ` Ramin Dousti
  -- strict thread matches above, loose matches on Subject: below --
2003-07-24 22:06 George Vieira
2003-07-24  8:29 DNAT question Philip Craig
2003-07-24  8:56 ` Rio Martin.
2003-07-24 16:22   ` Not quite understanding DNAT Coutts, Ashe (Testing Account)
2003-07-24 16:43     ` Aldo S. Lagana
2003-07-25  0:14     ` Philip Craig
2003-07-25  9:47     ` Chris Wilson
2003-07-25 10:10       ` Cedric Blancher

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.