iptables i przekierowywanie portów
: 16 grudnia 2009, 21:43
Mam taki mały problem (^__^) chce przekierować port 3333 w routerze na 10.0.0.100 na port 222 a port 4444 w routerze na 10.0.0.101 na port 222 tak jak na rysunku poniżej:
i na podstawie tego co znalazłem w sieci udało mi się napisać takie coś:
tylko, że to przekieruje port 3333 na 10.0.0.100:3333 a port 4444 na 10.0.0.101:4444 i teraz moje pytanie jak powinny wyglądać te regułki.
Kod: Zaznacz cały
+--------------+
| |
+--- eth0 HOST 1 |
połączenie z / | |
internetu na / +--------------+
port 3333 / eth0: 10.0.0.100
\ / PORT: 222
\ /
\ | /
\ | eth1: 10.0.0.254 /
+-----| +-----------+ +----------+
| | | | |
+--- eth0 ROUTER eth1 --- | SWITCH |
| | | | |
+-----| +-----------+ +----------+
/ | eth0: DHCP \
/ | \
/ \
/ \
połączenie z \
internetu na \ +--------------+
port 4444 \ | |
+--- eth0 HOST 2 |
| |
+--------------+
eth0: 10.0.0.101
PORT: 222
Kod: Zaznacz cały
$IPT -A FORWARD -p TCP -i eth0 --destination-port 3333 \
--destination 10.0.0.100 -j ACCEPT
$IPT -A FORWARD -p TCP -i eth0 --destination-port 4444 \
--destination 10.0.0.101 -j ACCEPT
$IPT -t nat -A PREROUTING -p TCP -i eth0 --destination-port 3333 \
-j DNAT --to-destination 10.0.0.100:3333
$IPT -t nat -A PREROUTING -p TCP -i eth0 --destination-port 4444 \
-j DNAT --to-destination 10.0.0.101:4444