Реклама: |
Spoofing services? What does that have to do with anything? Plenty. Lets pretend that
we have a web server running on 20.20.20.5, and since we've gotten increasingly suspicious
of our network security, we desire to not run this server on port 80 since that requires a
brief lifespan as the root user. But how do we run it on a less privledged port of 8000 in
this world of "anything dot com"? How will anyone find our server? We can use
the redirection facilities of NAT to solve this problem by instructing it to remap any
connections destined for 20.20.20.5:80 to really point to 20.20.20.5:8000. This uses the rdr
keyword:
rdr tun0 20.20.20.5/32 port 80 -> 192.168.0.5 port 8000
We can also specify the protocol here, if we wanted to redirect a UDP service,
instead of a TCP service (which is the default). For example, if we had a honeypot on our
firewall to impersonate the popular Back Orifice for Windows, we could shovel our entire
network into this one place with a simple rule:
rdr tun0 20.20.20.0/24 port 31337 -> 127.0.0.1 port 31337 udp
An extremely important point must be made about rdr: You cannot
easily[[dagger]] use this feature as a "reflector". E.g:
rdr tun0 20.20.20.5/32 port 80 -> 20.20.20.6 port 80 tcp
will not work in the situation where .5 and .6 are on the same LAN segment.
[[footnote: [[dagger]] Yes. There is a way to do this. It's so convoluted that I refuse to
use it, though. Smart people who require this functionality will transparently redirect
into something like TIS plug-gw on 127.0.0.1. Stupid people will set up a dummy loop
interface pair and double rewrite. ]] The rdr function is applied to packets that
enter the firewall on the specified interface. When a packet comes in that matches a rdr
rule, its destination address is then rewritten, it is pushed into ipf for
filtering, and should it successfully run the gauntlet of filter rules, it is then sent to
the unix routing code. Since this packet is still inbound on the same interface
that it will need to leave the system on to reach a host, the system gets confused.
Reflectors don't work. Neither does specifying the address of the interface the packet
just came in on. Always remember that rdr destinations must exit out of the
firewall host on a different interface. [[dagger]][[dagger]] [[footnote:
[[dagger]][[dagger]] This includes 127.0.0.1, by the way. That's on lo0. Neat, huh? ]]