unux
26.09.07, 08:55
Hallo zusammen,
hänge gerade an einem kleinen Routing-Problemchen, vl sieht ja jemand auf Anhieb was ich falsch gemacht habe.
Fallbeschreibung:
Server ist an 2 Subnets angeschlossen. Für das Subnet A spielt der Server Router, das Subnet B besitzt einen eigenen WAN Zugang. Vor meinem Server im Subnet A befinden sich mehrere Firewalls, die Connections vom WAN ins LAN blocken, daher will ich mich über den WAN Zugang von Subnet B in den Server per SSH einloggen.
Das ganze will ich über Policy-Routing bewerkstelligen, allerdings will mir das bis jetzt noch nicht so ganz gelingen.
Server:
OS: Debian Linux Etch
Kernel: 2.6.22.8 aus Vanilla Sourcen
Fiktive Subnets:
Subnet A: 10.100.1.0/24, Device: eth0
Subnet B: 10.100.2.0/24, Device: eth1
IP in Subnet B: 10.100.2.1
Gateway in Subnet B: 10.100.2.254
Zuerst habe ich mir einen 2. Routingtable angelegt, geflushed und die passende Regel für das Subnet und das default Gateway eingetragen:
echo "1 test" >> /etc/iproute2/rt_tables
ip route flush table test
ip route add table test 10.100.2.0/24 dev eth1 proto kernel scope link src 10.100.2.1
ip route add table test default via 10.100.2.254 dev eth1
Danach habe ich das Marking definiert und die markierten Pakete einem Routingtable zugewiesen:
iptables -t mangle -A INPUT -i eth1 -p tcp --dport 22 -j MARK --set-mark 1
ip rule add fwmark 1 table test
Abschließend noch ein schneller Cache-Flush:
ip route flush cache
Test-Routingtable:
[root@server][~]: ip route show table test
10.100.2.0/24 dev eth1 proto kernel scope link src 10.100.2.1
default via 10.100.2.254 dev eth1
IP Rules:
[root@server][~]: ip rule show
0: from all lookup 255
32765: from all fwmark 0x1 lookup test
32766: from all lookup main
32767: from all lookup default
Table Mangle:
[root@server][~]: iptables -t mangle -nvL
Chain PREROUTING (policy ACCEPT 4252 packets, 1180K bytes)
pkts bytes target prot opt in out source destination
Chain INPUT (policy ACCEPT 2614 packets, 231K bytes)
pkts bytes target prot opt in out source destination
23 1280 MARK tcp -- eth1 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:22 MARK set 0x1
Chain FORWARD (policy ACCEPT 1550 packets, 922K bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 1590 packets, 317K bytes)
pkts bytes target prot opt in out source destination
Chain POSTROUTING (policy ACCEPT 3140 packets, 1239K bytes)
pkts bytes target prot opt in out source destination
tcpdump:
[root@server][~]: tcpdump dst port 22 -vv -i eth1
tcpdump: listening on eth1, link-type EN10MB (Ethernet), capture size 96 bytes
10:16:56.224521 IP (tos 0x0, ttl 51, id 20373, offset 0, flags [DF], proto: TCP (6), length: 64) host.49261 > 10.100.2.1.ssh: S, cksum 0xdcaa (correct), 3419837221:3419837221(0) win 65535 <mss 1452,nop,wscale 0,nop,nop,timestamp 496876324 0,sackOK,eol>
Leider kommt keine Connection zusammen, da mein Server immer noch versucht über das default GW von Subnet A zu antworten.
Vielen Dank für eure Hilfe vorab
Greetz UnuX
hänge gerade an einem kleinen Routing-Problemchen, vl sieht ja jemand auf Anhieb was ich falsch gemacht habe.
Fallbeschreibung:
Server ist an 2 Subnets angeschlossen. Für das Subnet A spielt der Server Router, das Subnet B besitzt einen eigenen WAN Zugang. Vor meinem Server im Subnet A befinden sich mehrere Firewalls, die Connections vom WAN ins LAN blocken, daher will ich mich über den WAN Zugang von Subnet B in den Server per SSH einloggen.
Das ganze will ich über Policy-Routing bewerkstelligen, allerdings will mir das bis jetzt noch nicht so ganz gelingen.
Server:
OS: Debian Linux Etch
Kernel: 2.6.22.8 aus Vanilla Sourcen
Fiktive Subnets:
Subnet A: 10.100.1.0/24, Device: eth0
Subnet B: 10.100.2.0/24, Device: eth1
IP in Subnet B: 10.100.2.1
Gateway in Subnet B: 10.100.2.254
Zuerst habe ich mir einen 2. Routingtable angelegt, geflushed und die passende Regel für das Subnet und das default Gateway eingetragen:
echo "1 test" >> /etc/iproute2/rt_tables
ip route flush table test
ip route add table test 10.100.2.0/24 dev eth1 proto kernel scope link src 10.100.2.1
ip route add table test default via 10.100.2.254 dev eth1
Danach habe ich das Marking definiert und die markierten Pakete einem Routingtable zugewiesen:
iptables -t mangle -A INPUT -i eth1 -p tcp --dport 22 -j MARK --set-mark 1
ip rule add fwmark 1 table test
Abschließend noch ein schneller Cache-Flush:
ip route flush cache
Test-Routingtable:
[root@server][~]: ip route show table test
10.100.2.0/24 dev eth1 proto kernel scope link src 10.100.2.1
default via 10.100.2.254 dev eth1
IP Rules:
[root@server][~]: ip rule show
0: from all lookup 255
32765: from all fwmark 0x1 lookup test
32766: from all lookup main
32767: from all lookup default
Table Mangle:
[root@server][~]: iptables -t mangle -nvL
Chain PREROUTING (policy ACCEPT 4252 packets, 1180K bytes)
pkts bytes target prot opt in out source destination
Chain INPUT (policy ACCEPT 2614 packets, 231K bytes)
pkts bytes target prot opt in out source destination
23 1280 MARK tcp -- eth1 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:22 MARK set 0x1
Chain FORWARD (policy ACCEPT 1550 packets, 922K bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 1590 packets, 317K bytes)
pkts bytes target prot opt in out source destination
Chain POSTROUTING (policy ACCEPT 3140 packets, 1239K bytes)
pkts bytes target prot opt in out source destination
tcpdump:
[root@server][~]: tcpdump dst port 22 -vv -i eth1
tcpdump: listening on eth1, link-type EN10MB (Ethernet), capture size 96 bytes
10:16:56.224521 IP (tos 0x0, ttl 51, id 20373, offset 0, flags [DF], proto: TCP (6), length: 64) host.49261 > 10.100.2.1.ssh: S, cksum 0xdcaa (correct), 3419837221:3419837221(0) win 65535 <mss 1452,nop,wscale 0,nop,nop,timestamp 496876324 0,sackOK,eol>
Leider kommt keine Connection zusammen, da mein Server immer noch versucht über das default GW von Subnet A zu antworten.
Vielen Dank für eure Hilfe vorab
Greetz UnuX