nat и две сети с одинаковыми адресами
man iptables
DNAT
This target is only valid in the nat table, in the PREROUTING and OUTPUT chains, and user-defined chains which are only called from
those chains. It specifies that the destination address of the packet should be modified (and all future packets in this connection
will also be mangled and rules should cease being examined. It takes one type of option:
--to-destination ipaddr[-ipaddr][:port-port]
which can specify a single new destination IP address, an inclusive range of IP addresses, and optionally, a port range (which
is only valid if the rule also specifies -p tcp or -p udp). If no port range is specified, then the destination port will
never be modified.
In Kernels up to 2.6.10 you can add several --to-destination options. For those kernels, if you specify more than one destina-
tion address, either via an address range or multiple --to-destination options, a simple round-robin (one after another in
cycle) load balancing takes place between these addresses. Later Kernels (>= 2.6.11-rc1) don't have the ability to NAT to mul-
tiple ranges anymore.
SNAT
This target is only valid in the nat table, in the POSTROUTING chain. It specifies that the source address of the packet should be
modified (and all future packets in this connection will also be mangled and rules should cease being examined. It takes one type
of option:
--to-source ipaddr[-ipaddr][:port-port]
which can specify a single new source IP address, an inclusive range of IP addresses, and optionally, a port range (which is
only valid if the rule also specifies -p tcp or -p udp). If no port range is specified, then source ports below 512 will be
mapped to other ports below 512: those between 512 and 1023 inclusive will be mapped to ports below 1024, and other ports will
be mapped to 1024 or above. Where possible, no port alteration will occur.
In Kernels up to 2.6.10, you can add several --to-source options. For those kernels, if you specify more than one source
address, either via an address range or multiple --to-source options, a simple round-robin (one after another in cycle) takes
place between these addresses. Later Kernels (>= 2.6.11-rc1) don't have the ability to NAT to multiple ranges anymore.
Я когда-то делал похожее, используя вот это (man iptables)
NETMAP
This target allows you to statically map a whole network of addresses onto another network of addresses. It can only be used from
rules in the nat table.
--to address[/mask]
Network address to map to. The resulting address will be constructed in the following way: All ’one’ bits in the mask are
filled in from the new ‘address’. All bits that are zero in the mask are filled in from the original address.
Пару лет назад мне приходилось все гонять через кольцевой туннель.
Сейчас NETMAP может стал лучше
кхм, а такой таргет как NETMAP и незаметил
Пару лет назад мне приходилось все гонять через кольцевой туннель.А можешь подробно написать, зачем понадобился "кольцевой туннель" ?
Непонятно зачем нужен "кольцевой туннель", имея NETMAP.
Проблема была в том, что нетмап не хотел работать на "входе", работал только в POSTROUTING
Соответственно приходящий трафик я днатил на левый адрес, загонял в кольцевой туннель и в нем делал NETMAP
На лупбеке не вышло, так как он не воспринимался как внешний фейс.
Судя по документации в сети, сейчас нетмап этому уже научился и наверно обойдется все без гемора
NETMAP
This target allows you to statically map a whole network of addresses onto another network of addresses. It can only be used from
rules in the nat table.
--to address[/mask]
Network address to map to. The resulting address will be constructed in the following way: All 'one' bits in the mask are
filled in from the new `address'. All bits that are zero in the mask are filled in from the original address.
В PREROUTING я его заставить работать не смог ;(
Но, повторюсь, это было давно.
если подаришь мне второй маршрутизатор - не вопрос, так и сделаю
Второй маршрутизатор как-раз и заменяется кольцевым туннелем и бубном в ip ru/ip ro
eth1 подключен к Net1, ip адрес eth1 - 192.168.1.3 mask 24Удивительно, как у тебя всё ещё работает при такой адресации
eth2 подключен к Net2, ip адрес eth2 - 192.168.1.33 mask 23
можно одну первую замапить как 192.168.2.x для второй
и 192,168,2,x вторую для первой. и подсовывать свои днсы каждой сети. они обе будут думать, что их сеть 192.168.1/24, а чужая 192.168.2/24
вот когда есть 2 сети и там 10.имя-дома.имя-комнаты.количество-букв-в-имени - вообще не понятно как делать, не руками ж прописывать что куда мапиться при кол-ве адресов порядка 500-1000.
Вопрос только в том, зачем это нужно делать? И чем этот способ лучше, нежели сделать отдельные сети и запустить обычный роутинг между сетями, тогда клиенты ната будут получать ресурсы обоих сеток.
Но ваще постановка задачи жосткая
Оставить комментарий
krishtaf
Есть машина с тремя интерфейсами: eth1, eth2, eth3На машине стоит linux с ядром 2.6.x. В linux-ядре включена опция "Advanced Routing" (поддержка нескольких таблиц маршрутизации).
eth1 подключен к Net1, ip адрес eth1 - 192.168.1.3 mask 24
eth2 подключен к Net2, ip адрес eth2 - 192.168.1.33 mask 23
eth3 подключен к Net3, ip адрес eth3 - 192.168.2.5 mask 24
Причем Net1 и Net2 - это физически разные сети, но с одинаковой адресацией.
Также эта машина форвардит и натит пакеты для хостов сети Net3.
Вопрос:
Как смапить адреса сети Net1 (допустим на 172.16.1.0/24 чтобы одновременно можно было пользоваться ресурсами сетей Net1 и Net2 из сети Net3 ?
Если это возможно то, что будет происходить с arp-таблицей ?
P.S.
Можно ли решить такую задачу с помощью FreeBSD и как ?