Я управляю (отредактировал: размещен на VPS хостере) небольшой машиной для пары игровых серверов и сервера веб-сайта (apache) вместе с некоторыми друзьями. Проблема в том, что брандмауэр иногда отбрасывает пакеты UDP. Причина, по которой я сказал "иногда", заключается в том, что я не мог найти никакого правила для этого. Я объясню немного больше, несколько строк ниже.
Машина работает на Ubuntu 14.04.3 LTS (GNU/Linux 3.14.32-xxxx-grs-ipv6-64 x86_64). Для настройки брандмауэра я использую UFW. Я использую серверы apache2, mysql, ftp, ssh, arma3, arma2, csgo и повстанцев.
UDP "соединения" работают нормально:
- во время игры, после того, как "соединение" было правильно установлено
- после получения TCP пакетов
UDP-соединения не работают:
- когда случайно "пингует" (например, через netcat -u)
- иногда, когда gametracker пытается запросить игровые серверы
- когда любой другой сервер списка лобби запрашивает серверы
- практически каждый раз при отправке первого пакета от клиента за короткий промежуток времени
IP-адрес сервера заменен на 123.123.12.123.
ufw status verbose
дает:
Status: active
Logging: on (low)
Default: deny (incoming), allow (outgoing), allow (routed)
New profiles: skip
To Action From
-- ------ ----
22/tcp ALLOW IN Anywhere
21/tcp ALLOW IN Anywhere
80/tcp ALLOW IN Anywhere
2300:2305/udp ALLOW IN Anywhere
2380:2385/udp ALLOW IN Anywhere
27015 ALLOW IN Anywhere
27000:27014/udp ALLOW IN Anywhere
27016:27030/udp ALLOW IN Anywhere
4380/udp ALLOW IN Anywhere
28015 ALLOW IN Anywhere
28000:28014/udp ALLOW IN Anywhere
28016:28030/udp ALLOW IN Anywhere
26901/udp ALLOW IN Anywhere
53 ALLOW IN Anywhere
26902/udp ALLOW IN Anywhere
42367 ALLOW IN Anywhere
22/tcp (v6) ALLOW IN Anywhere (v6)
21/tcp (v6) ALLOW IN Anywhere (v6)
80/tcp (v6) ALLOW IN Anywhere (v6)
2300:2305/udp (v6) ALLOW IN Anywhere (v6)
2380:2385/udp (v6) ALLOW IN Anywhere (v6)
27015 (v6) ALLOW IN Anywhere (v6)
27000:27014/udp (v6) ALLOW IN Anywhere (v6)
27016:27030/udp (v6) ALLOW IN Anywhere (v6)
4380/udp (v6) ALLOW IN Anywhere (v6)
28015 (v6) ALLOW IN Anywhere (v6)
28000:28014/udp (v6) ALLOW IN Anywhere (v6)
28016:28030/udp (v6) ALLOW IN Anywhere (v6)
26901/udp (v6) ALLOW IN Anywhere (v6)
53 (v6) ALLOW IN Anywhere (v6)
26902/udp (v6) ALLOW IN Anywhere (v6)
42367 (v6) ALLOW IN Anywhere (v6)
netstat -ntl
дает:
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:28015 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:953 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:27015 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN
tcp6 0 0 :::80 :::* LISTEN
tcp6 0 0 ::1:53 :::* LISTEN
tcp6 0 0 :::22 :::* LISTEN
tcp6 0 0 ::1:953 :::* LISTEN
netstat -nul
дает:
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
udp 0 0 123.123.12.123:26901 0.0.0.0:*
udp 0 0 123.123.12.123:26902 0.0.0.0:*
udp 0 0 123.123.12.123:27005 0.0.0.0:*
udp 0 0 123.123.12.123:27015 0.0.0.0:*
udp 0 0 123.123.12.123:27020 0.0.0.0:*
udp 0 0 123.123.12.123:28005 0.0.0.0:*
udp 0 0 123.123.12.123:28015 0.0.0.0:*
udp 0 0 123.123.12.123:28020 0.0.0.0:*
udp 0 0 127.0.0.1:53 0.0.0.0:*
udp 0 0 0.0.0.0:2302 0.0.0.0:*
udp 0 0 0.0.0.0:2303 0.0.0.0:*
udp 0 0 0.0.0.0:2304 0.0.0.0:*
udp 0 0 0.0.0.0:2305 0.0.0.0:*
udp 0 0 123.123.12.123:2382 0.0.0.0:*
udp 0 0 123.123.12.123:2383 0.0.0.0:*
udp 0 0 123.123.12.123:2384 0.0.0.0:*
udp 0 0 123.123.12.123:2385 0.0.0.0:*
udp6 0 0 ::1:53 :::*
iptables -L
дает:
Chain INPUT (policy DROP)
target prot opt source destination
ufw-before-logging-input all -- anywhere anywhere
ufw-before-input all -- anywhere anywhere
ufw-after-input all -- anywhere anywhere
ufw-after-logging-input all -- anywhere anywhere
ufw-reject-input all -- anywhere anywhere
ufw-track-input all -- anywhere anywhere
Chain FORWARD (policy ACCEPT)
target prot opt source estination
ufw-before-logging-forward all -- anywhere anywhere
ufw-before-forward all -- anywhere anywhere
ufw-after-forward all -- anywhere anywhere
ufw-after-logging-forward all -- anywhere anywhere
ufw-reject-forward all -- anywhere anywhere
ufw-track-forward all -- anywhere anywhere
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
ufw-before-logging-output all -- anywhere anywhere
ufw-before-output all -- anywhere anywhere
ufw-after-output all -- anywhere anywhere
ufw-after-logging-output all -- anywhere anywhere
ufw-reject-output all -- anywhere anywhere
ufw-track-output all -- anywhere anywhere
Chain ufw-after-forward (1 references)
target prot opt source destination
Chain ufw-after-input (1 references)
target prot opt source destination
ufw-skip-to-policy-input udp -- anywhere anywhere udp dpt:netbios-ns
ufw-skip-to-policy-input udp -- anywhere anywhere udp dpt:netbios-dgm
ufw-skip-to-policy-input tcp -- anywhere anywhere tcp dpt:netbios-ssn
ufw-skip-to-policy-input tcp -- anywhere anywhere tcp dpt:microsoft-ds
ufw-skip-to-policy-input udp -- anywhere anywhere udp dpt:bootps
ufw-skip-to-policy-input udp -- anywhere anywhere udp dpt:bootpc
ufw-skip-to-policy-input all -- anywhere anywhere ADDRTYPE match dst-type BROADCAST
Chain ufw-after-logging-forward (1 references)
target prot opt source destination
Chain ufw-after-logging-input (1 references)
target prot opt source destination
LOG all -- anywhere anywhere limit: avg 3/min burst 10 LOG level warning prefix "[UFW BLOCK] "
Chain ufw-after-logging-output (1 references)
target prot opt source destination
Chain ufw-after-output (1 references)
target prot opt source destination
Chain ufw-before-forward (1 references)
target prot opt source destination
ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED
ACCEPT icmp -- anywhere anywhere icmp destination-unreachable
ACCEPT icmp -- anywhere anywhere icmp source-quench
ACCEPT icmp -- anywhere anywhere icmp time-exceeded
ACCEPT icmp -- anywhere anywhere icmp parameter-problem
ACCEPT icmp -- anywhere anywhere icmp echo-request
ufw-user-forward all -- anywhere anywhere
Chain ufw-before-input (1 references)
target prot opt source destination
ACCEPT all -- anywhere anywhere
ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED
ufw-logging-deny all -- anywhere anywhere ctstate INVALID
DROP all -- anywhere anywhere ctstate INVALID
ACCEPT icmp -- anywhere anywhere icmp destination-unreachable
ACCEPT icmp -- anywhere anywhere icmp source-quench
ACCEPT icmp -- anywhere anywhere icmp time-exceeded
ACCEPT icmp -- anywhere anywhere icmp parameter-problem
ACCEPT icmp -- anywhere anywhere icmp echo-request
ACCEPT udp -- anywhere anywhere udp spt:bootps dpt:bootpc
ufw-not-local all -- anywhere anywhere
ACCEPT udp -- anywhere 224.0.0.251 udp dpt:mdns
ACCEPT udp -- anywhere 239.255.255.250 udp dpt:1900
ufw-user-input all -- anywhere anywhere
Chain ufw-before-logging-forward (1 references)
target prot opt source destination
Chain ufw-before-logging-input (1 references)
target prot opt source destination
Chain ufw-before-logging-output (1 references)
target prot opt source destination
Chain ufw-before-output (1 references)
target prot opt source destination
ACCEPT all -- anywhere anywhere
ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED
ufw-user-output all -- anywhere anywhere
Chain ufw-logging-allow (0 references)
target prot opt source destination
LOG all -- anywhere anywhere limit: avg 3/min burst 10 LOG level warning prefix "[UFW ALLOW] "
Chain ufw-logging-deny (2 references)
target prot opt source destination
RETURN all -- anywhere anywhere ctstate INVALID limit: avg 3/min burst 10
LOG all -- anywhere anywhere limit: avg 3/min burst 10 LOG level warning prefix "[UFW BLOCK] "
Chain ufw-not-local (1 references)
target prot opt source destination
RETURN all -- anywhere anywhere ADDRTYPE match dst-type LOCAL
RETURN all -- anywhere anywhere ADDRTYPE match dst-type MULTICAST
RETURN all -- anywhere anywhere ADDRTYPE match dst-type BROADCAST
ufw-logging-deny all -- anywhere anywhere limit: avg 3/min burst 10
DROP all -- anywhere anywhere
Chain ufw-reject-forward (1 references)
target prot opt source destination
Chain ufw-reject-input (1 references)
target prot opt source destination
Chain ufw-reject-output (1 references)
target prot opt source destination
Chain ufw-skip-to-policy-forward (0 references)
target prot opt source destination
ACCEPT all -- anywhere anywhere
Chain ufw-skip-to-policy-input (7 references)
target prot opt source destination
DROP all -- anywhere anywhere
Chain ufw-skip-to-policy-output (0 references)
target prot opt source destination
ACCEPT all -- anywhere anywhere
Chain ufw-track-forward (1 references)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere ctstate NEW
ACCEPT udp -- anywhere anywhere ctstate NEW
Chain ufw-track-input (1 references)
target prot opt source destination
Chain ufw-track-output (1 references)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere ctstate NEW
ACCEPT udp -- anywhere anywhere ctstate NEW
Chain ufw-user-forward (1 references)
target prot opt source destination
Chain ufw-user-input (1 references)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp dpt:ssh
ACCEPT tcp -- anywhere anywhere tcp dpt:ftp
ACCEPT tcp -- anywhere anywhere tcp dpt:http
ACCEPT udp -- anywhere anywhere multiport dports 2300:2305
ACCEPT udp -- anywhere anywhere multiport dports 2380:2385
ACCEPT tcp -- anywhere anywhere tcp dpt:27015
ACCEPT udp -- anywhere anywhere udp dpt:27015
ACCEPT udp -- anywhere anywhere multiport dports 27000:27014
ACCEPT udp -- anywhere anywhere multiport dports 27016:27030
ACCEPT udp -- anywhere anywhere udp dpt:4380
ACCEPT tcp -- anywhere anywhere tcp dpt:28015
ACCEPT udp -- anywhere anywhere udp dpt:28015
ACCEPT udp -- anywhere anywhere multiport dports 28000:28014
ACCEPT udp -- anywhere anywhere multiport dports 28016:28030
ACCEPT udp -- anywhere anywhere udp dpt:26901
ACCEPT tcp -- anywhere anywhere tcp dpt:domain
ACCEPT udp -- anywhere anywhere udp dpt:domain
ACCEPT udp -- anywhere anywhere udp dpt:26902
ACCEPT tcp -- anywhere anywhere tcp dpt:42367
ACCEPT udp -- anywhere anywhere udp dpt:42367
Chain ufw-user-limit (0 references)
target prot opt source destination
LOG all -- anywhere anywhere limit: avg 3/min burst 5 LOG level warning prefix "[UFW LIMIT BLOCK] "
REJECT all -- anywhere anywhere reject-with icmp-port-unreachable
Chain ufw-user-limit-accept (0 references)
target prot opt source destination
ACCEPT all -- anywhere anywhere
Chain ufw-user-logging-forward (0 references)
target prot opt source destination
Chain ufw-user-logging-input (0 references)
target prot opt source destination
Chain ufw-user-logging-output (0 references)
target prot opt source destination
Chain ufw-user-output (1 references)
target prot opt source destination
Когда я пытаюсь отследить маршрут извне (gra-3a-a9.fr.eu не моя машина):
traceroute to 123.123.12.123 (123.123.12.123), 30 hops max, 60 byte packets
1 * * *
2 weservit.openpeering.telecity2.jointtransit.nl (217.170.23.236) 1.679 ms 1.626 ms 1.699 ms
3 telecity-ixr.openpeering.nl (217.170.0.244) 2.192 ms 2.174 ms 2.250 ms
4 * * *
5 gra-g2-a9.fr.eu (213.251.128.28) 10.383 ms 10.367 ms 10.342 ms
6 gra-3a-a9.fr.eu (37.187.231.88) 9.001 ms gra-3b-a9.fr.eu (37.187.231.92) 9.386 ms 9.331 ms
7 * * *
8 * * *
9 * * *
10 * * *
11 * * *
12 * * *
13 * * *
14 * * *
15 * * *
16 * * *
17 * * *
18 * * *
19 * * *
20 * * *
21 * * *
22 * * *
23 * * *
24 * * *
25 * * *
26 * * *
27 * * *
28 * * *
29 * * *
30 * * *
Я попытался сделать небольшой эксперимент:
// SERVER:
user@server:~$ sudo ufw status verbose | grep 42367
42367 ALLOW IN Anywhere
42367 (v6) ALLOW IN Anywhere (v6)
user@server:~$ netcat -ul 42367
^C
user@server:~$ netcat -l 42367
b
it does work
user@server:~$ netcat -ul 42367
c
it does work
^C
user@server:~$
// CLIENT:
user@client:~$ netcat -u 123.123.12.123 42367
a
it doesnt work
^C
user@client:~$ netcat 123.123.12.123 42367
b
it does work
^C
user@client:~$ netcat -u 123.123.12.123 42367
c
it does work
^C
user@client:~$
Я почти уверен, что пропустил что-то действительно важное (и глупое, да) во время настройки, и поэтому оно не работает. Вопрос: что я пропустил, и теперь он не позволяет UDP работать должным образом?
Если нужна какая-либо другая информация - комментируйте.
Спасибо за любой ответ заранее! Извините за длинный пост; нет картошки