Ich betreibe meinen Linux-Rechner (Debian 3.1) als am Netz hängenden Router für zwei (oder bei Bedarf auch mehr) andere Linux- als auch Windowsrechner.
Im Router selbst sind zwei Netzwerkkarten verbaut, beide mit statischer IP:
Code: Alles auswählen
eth0 Protokoll:Ethernet Hardware Adresse 00:60:97:31:5A:7D
inet Adresse:xxx.xxx.xxx.xxx Bcast:xxx.xxx.xxx.xxx Maske:255.255.254.0
inet6 Adresse: fe80::260:97ff:fe31:5a7d/64 Gültigkeitsbereich:Verbindung
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:896854 errors:0 dropped:0 overruns:0 frame:0
TX packets:691673 errors:0 dropped:0 overruns:0 carrier:0
Kollisionen:0 Sendewarteschlangenlänge:1000
RX bytes:630843260 (601.6 MiB) TX bytes:53906807 (51.4 MiB)
Interrupt:12 Basisadresse:0xdc00
eth1 Protokoll:Ethernet Hardware Adresse 00:50:04:0A:F8:EC
inet Adresse:10.80.12.1 Bcast:10.255.255.255 Maske:255.0.0.0
inet6 Adresse: fe80::250:4ff:fe0a:f8ec/64 Gültigkeitsbereich:Verbindung
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1850958 errors:0 dropped:0 overruns:0 frame:0
TX packets:3286908 errors:0 dropped:0 overruns:0 carrier:0
Kollisionen:0 Sendewarteschlangenlänge:1000
RX bytes:122613602 (116.9 MiB) TX bytes:4261482465 (3.9 GiB)
Interrupt:5 Basisadresse:0xf80
Code: Alles auswählen
#/bin/bash
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -s 10.80.12.2 -o eth0 -j SNAT --to xxx.xxx.xxx.xxx
iptables -t nat -A POSTROUTING -s 10.80.12.3 -o eth0 -j SNAT --to xxx.xxx.xxx.xxx
iptables -t filter -A OUTPUT -o eth0 -s 10.0.0.0/8 -j DROP
iptables --table nat --policy POSTROUTING DROP
Code: Alles auswählen
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
DROP 0 -- localnet/8 anywhere
DROP 0 -f localnet/8 anywhere
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
SNAT 0 -- 10.80.12.2 anywhere to:xxx.xxx.xxx.xxx
SNAT 0 -- 10.80.12.3 anywhere to:xxx.xxx.xxx.xxx
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Gelegentlich treten Pakete auf, die nicht korrekt geNATet werden.
Kleiner Auszug aus "tcpdump -i eth0 src host 10.80.12.3 -vv" bzw. "tcpdump -i eth0 src host 10.80.12.2 -vv" :
Code: Alles auswählen
tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes
10:55:33.697732 IP (tos 0x0, ttl 127, id 8573, offset 0, flags [none], proto: TCP (6), length: 40) 10.80.12.3.1082 > www.debian.org.www: R, cksum 0x5d77 (correct), 1990962368:1990962368(0) win 0
10:55:33.698178 IP (tos 0x0, ttl 127, id 8574, offset 0, flags [none], proto: TCP (6), length: 40) 10.80.12.3.1074 > www.google.de.www: R, cksum 0xe425 (correct), 1794908862:1794908862(0) win 0
19:47:50.170403 IP (tos 0x0, ttl 127, id 55010, offset 0, flags [DF], proto: TCP (6), length: 40) 10.80.12.2.1695 > www.kernel.org.ftp: R, cksum 0x9afd (correct), 1546006051:1546006051(0) win 0
Das Problem tritt sporadisch auf, läßt sich aber mit besonders verbindungslastigen Anwendungen (z.B. Torrent) ziemlich gut replizieren.
Allerdings habe ich das auch bei anderen Protokollen, nicht nur TCP, beobachten können.
Gibts eine Möglichkeit, IPTables so zu konfigurieren, das sichergestellt wird, das keine internen IP's ins Netz gelangen (also keine 10.x.x.x) ?
MfG
Merc