Skip to contentSkip to conversation

Problem with rdate and iptables

DISCUSSION Eric Bauman 3 participants 6 messages Apr 23, 2010 – Apr 26, 2010

lore
Share & tools
lore
#0 lore raw

Hi there,

I'm having an issue with getting rdate working over UDP.
I'm using the rule "--append INPUT --match state --state ESTABLISHED,RELATED --jump ACCEPT". It works fine over TCP, but times out when using UDP.

Any ideas?

Cheers,
Eric

#1 lore raw

Hello,

Quoted 5 lines · Eric Bauman

I'm having an issue with getting rdate working over UDP. I'm using the rule "--append INPUT --match state --state ESTABLISHED,RELATED --jump ACCEPT". It works fine over TCP, but times out when using UDP.

Is this on the server or client ? That rule does not care about the protocol, but a rule alone without the rest of the ruleset does not tell much.

Quoted 1 line

Any ideas?

Rather a suggestion. You could trace relevant traffic with a packet sniffer and/or iptables LOG rules and try to see what's going on. Disable all filtering and check if it works. Does the rdate server accept UDP queries ?

#2 lore raw
Quoted 10 lines · Pascal Hambourg

Is this on the server or client ? That rule does not care about the protocol, but a rule alone without the rest of the ruleset does not tell much.

Quoted 1 line

Any ideas?

Rather a suggestion. You could trace relevant traffic with a packet sniffer and/or iptables LOG rules and try to see what's going on. Disable all filtering and check if it works. Does the rdate server accept UDP queries ?

Hi there, thank-you for the reply.

This is an rdate client accessing a timeserver.

The only only other rules I have are default policies (DROP for INPUT and FORWARD, and ACCEPT for OUTPUT), ACCEPT for all loopback traffic, and ACCEPT for various incoming ports (eg. HTTP etc.).

It works fine with all rules removed, and it works fine over TCP with all rules enabled.

Cheers,
Eric

#3 lore raw
Quoted 9 lines · Eric Bauman

This is an rdate client accessing a timeserver.

The only only other rules I have are default policies (DROP for INPUT and FORWARD, and ACCEPT for OUTPUT), ACCEPT for all loopback traffic, and ACCEPT for various incoming ports (eg. HTTP etc.).

It works fine with all rules removed, and it works fine over TCP with all rules enabled.

Could you capture the time query and reply packets (port 37) with a packet sniffer such as tcpdump or wireshark ?

#4 lore raw
Quoted 2 lines · Pascal Hambourg

Could you capture the time query and reply packets (port 37) with a packet sniffer such as tcpdump or wireshark ?

Yes, I just tried that, and I think it shows the problem. It turns out that a TIME request is being made to IP A, but the response is coming from IP B! So I'm not surprised iptables isn't matching it as established or related.

That leads me to ask, who is in the wrong? Should iptables be matching the response, should the TIME server be responding with the address from which it receives a query, or is it my fault for not knowing that a request/response IP mismatch is legal behaviour and crafting an appropriate rule?

Cheers,
Eric

#5 lore raw
Quoted 4 lines · Eric Bauman
Quoted 2 lines · Pascal Hambourg

Could you capture the time query and reply packets (port 37) with a packet sniffer such as tcpdump or wireshark ?

Quoted 8 lines

Yes, I just tried that, and I think it shows the problem. It turns out that a TIME request is being made to IP A, but the response is coming from IP B! So I'm not surprised iptables isn't matching it as established or related.

That leads me to ask, who is in the wrong? Should iptables be matching the response, should the TIME server be responding with the address from which it receives a query, or is it my fault for not knowing that a request/response IP mismatch is legal behaviour and crafting an appropriate rule?

RFC 868 does not specify any addresses for UDP. I guess someone exploited that in a bogus implementation already ...

Use NTP instead? :-)