[iptables] nat странная работа
Чето я в непонятках. Есть шлюз на Debian sid, Ядро 3.0.0. В один прекрасный день вдруг перестал ходить L2TP/IPSEC от машины за шлюзом. Со шлюзом ничего не делалось, сам он не обновляется. У провайдера binat.
Что я накопал - первые установочные пакеты на UDP 4500 проходят нормально через FORWARD попадают ко мне, а вот энкапсулированные ESP пакеты по направлению ко мне попадают в цепочку INPUT и соответственно до моей машины не доходят. Напомню, соединения я устанавливаю с машины за шлюзом, т.е. чистый FORWARD
# Generated by iptables-save v1.4.12 on Thu Sep 1 22:31:24 2011
*mangle
:PREROUTING ACCEPT [841:650073]
:INPUT ACCEPT [101:10118]
:FORWARD ACCEPT [736:639846]
:OUTPUT ACCEPT [90:11033]
:POSTROUTING ACCEPT [826:650879]
-A PREROUTING -s 80.X.X.130/32 -p udp -j LOG --log-prefix "MANGLE:"
COMMIT
# Completed on Thu Sep 1 22:31:24 2011
# Generated by iptables-save v1.4.12 on Thu Sep 1 22:31:24 2011
*filter
:INPUT ACCEPT [110:10478]
:FORWARD ACCEPT [737:639894]
:OUTPUT ACCEPT [109:13053]
-A INPUT -s 80.X.X.130/32 -j LOG --log-prefix "INPUT: "
COMMIT
# Completed on Thu Sep 1 22:31:24 2011
# Generated by iptables-save v1.4.12 on Thu Sep 1 22:31:24 2011
*nat
:PREROUTING ACCEPT [72:8050]
:INPUT ACCEPT [65:7345]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [1:237]
-A PREROUTING -s 80.X.X.130/32 -p udp -j LOG --log-prefix "NAT: "
-A POSTROUTING -s 172.19.0.0/24 -o eth2 -j SNAT --to-source 10.194.84.119
COMMIT
# Completed on Thu Sep 1 22:31:24 2011
br0 Link encap:Ethernet HWaddr 00:0d:b9:23:2e:4c
inet addr:172.19.0.2 Bcast:172.19.0.255 Mask:255.255.255.0
inet6 addr: fe80::20d:b9ff:fe23:2e4c/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:30810983 errors:0 dropped:0 overruns:0 frame:0
TX packets:21586458 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:40485219677 (37.7 GiB) TX bytes:11071318242 (10.3 GiB)
eth0 Link encap:Ethernet HWaddr 00:0d:b9:23:2e:4c
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:30765329 errors:0 dropped:0 overruns:0 frame:0
TX packets:21444810 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2337470610 (2.1 GiB) TX bytes:2342603223 (2.1 GiB)
Interrupt:10 Base address:0x1000
eth2 Link encap:Ethernet HWaddr 30:46:9a:83:ea:85
inet addr:10.194.84.119 Bcast:10.194.87.255 Mask:255.255.252.0
inet6 addr: fe80::3246:9aff:fe83:ea85/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:38144689 errors:0 dropped:9638 overruns:0 frame:0
TX packets:30775131 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3519026561 (3.2 GiB) TX bytes:2258832516 (2.1 GiB)
Interrupt:15 Base address:0x1800
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:6 errors:0 dropped:0 overruns:0 frame:0
TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:300 (300.0 B) TX bytes:300 (300.0 B)
mon.wlan0 Link encap:UNSPEC HWaddr F4-EC-38-A3-10-56-00-00-00-00-00-00-00-00-00-00
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1526748 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:465273483 (443.7 MiB) TX bytes:0 (0.0 B)
wlan0 Link encap:Ethernet HWaddr f4:ec:38:a3:10:56
inet6 addr: fe80::f6ec:38ff:fea3:1056/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:182462 errors:0 dropped:0 overruns:0 frame:0
TX packets:256379 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:22750207 (21.6 MiB) TX bytes:234355773 (223.4 MiB)
Ниже содержимое лога:
Sep 1 22:17:57 kernel: [88458.134143] MANGLE:IN=eth2 OUT= MAC=[del] SRC=80.X.X.130 DST=10.194.84.119 LEN=188 TOS=0x00 PREC=0x00 TTL=58 ID=0 DF PROTO=UDP SPT=500 DPT=500 LEN=168
Sep 1 22:17:57 kernel: [88458.157134] MANGLE:IN=eth2 OUT= MAC=[del] SRC=80.X.X.130 DST=10.194.84.119 LEN=232 TOS=0x00 [идентично] SPT=500 DPT=500 LEN=212
Sep 1 22:17:57 kernel: [88458.251145] MANGLE:IN=eth2 OUT= MAC=[del] SRC=80.X.X.130 DST=10.194.84.119 LEN=1068 TOS=0x00 [идентично] SPT=4500 DPT=4500 LEN=1048
Sep 1 22:17:57 kernel: [88458.256861] MANGLE:IN=eth2 OUT= MAC=[del] SRC=80.X.X.130 DST=10.194.84.119 LEN=204 TOS=0x00 [идентично] SPT=4500 DPT=4500 LEN=184
Sep 1 22:17:59 kernel: [88460.263008] MANGLE:IN=eth2 OUT= MAC=[del] SRC=80.X.X.130 DST=10.194.84.119 LEN=192 TOS=0x00 [идентично] SPT=4500 DPT=4500 LEN=172
Sep 1 22:17:59 kernel: [88460.263100] INPUT: IN=eth2 OUT= MAC=[del] SRC=80.X.X.130 DST=10.194.84.119 LEN=192 TOS=0x00 [идентично] SPT=4500 DPT=4500 LEN=172
Sep 1 22:17:59 kernel: [88460.263139] net_ratelimit: 3 callbacks suppressed
Sep 1 22:17:59 kernel: [88460.263255] MANGLE:IN=eth2 OUT= MAC=[del] SRC=80.X.X.130 DST=10.194.84.119 LEN=96 TOS=0x00 [идентично] SPT=4500 DPT=4500 LEN=76
Sep 1 22:17:59 kernel: [88460.263338] INPUT: IN=eth2 OUT= MAC=[del] SRC=80.X.X.130 DST=10.194.84.119 LEN=96 TOS=0x00 [идентично] SPT=4500 DPT=4500 LEN=76
Sep 1 22:18:00 kernel: [88461.262750] MANGLE:IN=eth2 OUT= MAC=[del] SRC=80.X.X.130 DST=10.194.84.119 LEN=192 TOS=0x00 [идентично] SPT=4500 DPT=4500 LEN=172
Sep 1 22:18:00 kernel: [88461.262840] INPUT: IN=eth2 OUT= MAC=[del] SRC=80.X.X.130 DST=10.194.84.119 LEN=192 TOS=0x00 [идентично] SPT=4500 DPT=4500 LEN=172
Sep 1 22:18:00 kernel: [88461.279414] MANGLE:IN=eth2 OUT= MAC=[del] SRC=80.X.X.130 DST=10.194.84.119 LEN=96 TOS=0x00 [идентично] SPT=4500 DPT=4500 LEN=76
Sep 1 22:18:00 kernel: [88461.279505] INPUT: IN=eth2 OUT= MAC=[del] SRC=80.X.X.130 DST=10.194.84.119 LEN=96 TOS=0x00 [идентично] SPT=4500 DPT=4500 LEN=76
Sep 1 22:18:01 kernel: [88462.262879] MANGLE:IN=eth2 OUT= MAC=[del] SRC=80.X.X.130 DST=10.194.84.119 LEN=192 TOS=0x00 [идентично] SPT=4500 DPT=4500 LEN=172
Sep 1 22:18:01 kernel: [88462.262970] INPUT: IN=eth2 OUT= MAC=[del] SRC=80.X.X.130 DST=10.194.84.119 LEN=192 TOS=0x00 [идентично] SPT=4500 DPT=4500 LEN=172
Sep 1 22:18:02 kernel: [88463.262835] MANGLE:IN=eth2 OUT= MAC=[del] SRC=80.X.X.130 DST=10.194.84.119 LEN=192 TOS=0x00 [идентично] SPT=4500 DPT=4500 LEN=172
Sep 1 22:18:02 kernel: [88463.262925] INPUT: IN=eth2 OUT= MAC=[del] SRC=80.X.X.130 DST=10.194.84.119 LEN=192 TOS=0x00 [идентично] SPT=4500 DPT=4500 LEN=172
Sep 1 22:18:02 kernel: [88463.949470] MANGLE:IN=eth2 OUT= MAC=[del] SRC=80.X.X.130 DST=10.194.84.119 LEN=108 TOS=0x00 [идентично] SPT=4500 DPT=4500 LEN=88
Sep 1 22:18:02 kernel: [88463.955421] MANGLE:IN=eth2 OUT= MAC=[del] SRC=80.X.X.130 DST=10.194.84.119 LEN=124 TOS=0x00 [идентично] SPT=4500 DPT=4500 LEN=104
Sep 1 22:18:03 kernel: [88464.262873] MANGLE:IN=eth2 OUT= MAC=[del] SRC=80.X.X.130 DST=10.194.84.119 LEN=138 TOS=0x00 [идентично] SPT=1701 DPT=1701 LEN=118
Sep 1 22:18:03 kernel: [88464.262962] NAT: IN=eth2 OUT= MAC=[del] SRC=80.X.X.130 DST=10.194.84.119 LEN=138 TOS=0x00 [идентично] SPT=1701 DPT=1701 LEN=118
Sep 1 22:18:03 kernel: [88464.263054] INPUT: IN=eth2 OUT= MAC=[del] SRC=80.X.X.130 DST=10.194.84.119 LEN=138 TOS=0x00 [идентично] SPT=1701 DPT=1701 LEN=118
Ну и результат tcpdump на внешнем и внутреннем интерфейсе:
listening on eth2, link-type EN10MB (Ethernet), capture size 65535 bytes
22:17:57.000306 IP 10.194.84.119.500 > 80.X.X.130.500: isakmp: phase 1 I ident
22:17:57.002786 IP 80.X.X.130.500 > 10.194.84.119.500: isakmp: phase 1 R ident
22:17:57.019718 IP 10.194.84.119.500 > 80.X.X.130.500: isakmp: phase 1 I ident
22:17:57.025786 IP 80.X.X.130.500 > 10.194.84.119.500: isakmp: phase 1 R ident
22:17:57.115844 IP 10.194.84.119.4500 > 80.X.X.130.4500: NONESP-encap: isakmp: phase 1 I ident[E]
22:17:57.119784 IP 80.X.X.130.4500 > 10.194.84.119.4500: NONESP-encap: isakmp: phase 1 R ident[E]
22:17:57.123046 IP 10.194.84.119.4500 > 80.X.X.130.4500: NONESP-encap: isakmp: phase 2/others I oakley-quick[E]
22:17:57.125512 IP 80.X.X.130.4500 > 10.194.84.119.4500: NONESP-encap: isakmp: phase 2/others R oakley-quick[E]
22:17:57.128114 IP 10.194.84.119.4500 > 80.X.X.130.4500: NONESP-encap: isakmp: phase 2/others I oakley-quick[E]
22:17:57.129404 IP 10.194.84.119.4500 > 80.X.X.130.4500: UDP-encap: ESP(spi=0xcbb3e6ad,seq=0x1), length 148
22:17:58.134973 IP 10.194.84.119.4500 > 80.X.X.130.4500: UDP-encap: ESP(spi=0xcbb3e6ad,seq=0x2), length 148
22:17:59.131661 IP 80.X.X.130.4500 > 10.194.84.119.4500: UDP-encap: ESP(spi=0x4acc7538,seq=0x1), length 164
22:17:59.131937 IP 80.X.X.130.4500 > 10.194.84.119.4500: UDP-encap: ESP(spi=0x4acc7538,seq=0x2), length 68
22:18:00.131404 IP 80.X.X.130.4500 > 10.194.84.119.4500: UDP-encap: ESP(spi=0x4acc7538,seq=0x3), length 164
22:18:00.146124 IP 10.194.84.119.4500 > 80.X.X.130.4500: UDP-encap: ESP(spi=0xcbb3e6ad,seq=0x3), length 148
22:18:00.148070 IP 80.X.X.130.4500 > 10.194.84.119.4500: UDP-encap: ESP(spi=0x4acc7538,seq=0x4), length 68
22:18:01.131533 IP 80.X.X.130.4500 > 10.194.84.119.4500: UDP-encap: ESP(spi=0x4acc7538,seq=0x5), length 164
22:18:02.131490 IP 80.X.X.130.4500 > 10.194.84.119.4500: UDP-encap: ESP(spi=0x4acc7538,seq=0x6), length 164
22:18:02.815983 IP 10.194.84.119.4500 > 80.X.X.130.4500: NONESP-encap: isakmp: phase 2/others I inf[E]
22:18:02.816092 IP 10.194.84.119.4500 > 80.X.X.130.4500: NONESP-encap: isakmp: phase 2/others I inf[E]
22:18:02.818123 IP 80.X.X.130.4500 > 10.194.84.119.4500: NONESP-encap: isakmp: phase 2/others R inf[E]
22:18:02.824069 IP 80.X.X.130.4500 > 10.194.84.119.4500: NONESP-encap: isakmp: phase 2/others R inf[E]
22:18:03.131515 IP 80.X.X.130.1701 > 10.194.84.119.1701: l2tp:[TLS](8/0)Ns=0,Nr=1 *MSGTYPE(SCCRP) *PROTO_VER(1.0) *FRAMING_CAP(AS) *BEARER_CAP() *FIRM_VER(1680) *HOST_NAME(kentek-router) *VENDOR_NAME(xelerance.com) *ASSND_TUN_ID(4836) *RECV_WIN_SIZE(4)
22:18:03.131937 IP 10.194.84.119 > 80.X.X.130: ICMP 10.194.84.119 udp port 1701 unreachable, length 146
listening on br0, link-type EN10MB (Ethernet), capture size 65535 bytes
22:17:57.000210 IP 172.19.0.25.500 > 80.X.X.130.500: isakmp: phase 1 I ident
22:17:57.002953 IP 80.X.X.130.500 > 172.19.0.25.500: isakmp: phase 1 R ident
22:17:57.019646 IP 172.19.0.25.500 > 80.X.X.130.500: isakmp: phase 1 I ident
22:17:57.025941 IP 80.X.X.130.500 > 172.19.0.25.500: isakmp: phase 1 R ident
22:17:57.115750 IP 172.19.0.25.4500 > 80.X.X.130.4500: NONESP-encap: isakmp: phase 1 I ident[E]
22:17:57.119954 IP 80.X.X.130.4500 > 172.19.0.25.4500: NONESP-encap: isakmp: phase 1 R ident[E]
22:17:57.122942 IP 172.19.0.25.4500 > 80.X.X.130.4500: NONESP-encap: isakmp: phase 2/others I oakley-quick[E]
22:17:57.125671 IP 80.X.X.130.4500 > 172.19.0.25.4500: NONESP-encap: isakmp: phase 2/others R oakley-quick[E]
22:17:57.128014 IP 172.19.0.25.4500 > 80.X.X.130.4500: NONESP-encap: isakmp: phase 2/others I oakley-quick[E]
22:17:57.129336 IP 172.19.0.25.4500 > 80.X.X.130.4500: UDP-encap: ESP(spi=0xcbb3e6ad,seq=0x1), length 148
22:17:58.134908 IP 172.19.0.25.4500 > 80.X.X.130.4500: UDP-encap: ESP(spi=0xcbb3e6ad,seq=0x2), length 148
22:18:00.146047 IP 172.19.0.25.4500 > 80.X.X.130.4500: UDP-encap: ESP(spi=0xcbb3e6ad,seq=0x3), length 148
22:18:02.815912 IP 172.19.0.25.4500 > 80.X.X.130.4500: NONESP-encap: isakmp: phase 2/others I inf[E]
22:18:02.816042 IP 172.19.0.25.4500 > 80.X.X.130.4500: NONESP-encap: isakmp: phase 2/others I inf[E]
22:18:02.818277 IP 80.X.X.130.4500 > 172.19.0.25.4500: NONESP-encap: isakmp: phase 2/others R inf[E]
22:18:02.824235 IP 80.X.X.130.4500 > 172.19.0.25.4500: NONESP-encap: isakmp: phase 2/others R inf[E]
Вопрос. Почему оно так и что делать?