Решено: Открытие портов

Обсуждение настройки и работы сервисов, резервирования, сетевых настроек и вопросов безопасности ОС для молодых и начинающих системных администраторов.

Модераторы: SLEDopit, Модераторы разделов

Аватара пользователя
SLEDopit
Модератор
Сообщения: 4824
Статус: фанат консоли (=
ОС: GNU/Debian, RHEL

Решено: Открытие портов

Сообщение SLEDopit »

Мне кажется, что я определенно в этом чего то не понимаю.
Решил таки настроить проброс портов для работы торрент клиента (ktorrent, хотя это, как я понимаю, не особо принципиально).
Прокинул в роутере (asus 520gc) необходимый порт (7000) [прокидывать порты я умею, т.к. аналогично прокидывал порты для веб, фтп и ssh и все работают], и решил просканить nmap'ом с удаленной машины свой ip (статика). на что мне выдалось милое сообщение

Код: Выделить всё

 # nmap -PN my.domain -p 7000

Starting Nmap 4.62 ( http://nmap.org ) at 2010-04-19 12:37 MSD
Interesting ports on ---- (m.y.i.p):
PORT     STATE  SERVICE
7000/tcp closed afs3-fileserver

Nmap done: 1 IP address (1 host up) scanned in 0.116 seconds
Странно. Решил просканить nmap'ом локалхост:

Код: Выделить всё

 # nmap localhost -p 7000

Starting Nmap 5.00 ( http://nmap.org ) at 2010-04-19 01:54 MSD
Warning: Hostname localhost resolves to 2 IPs. Using 127.0.0.1.
Interesting ports on localhost (127.0.0.1):
PORT     STATE  SERVICE
7000/tcp closed afs3-fileserver

Nmap done: 1 IP address (1 host up) scanned in 0.14 seconds
результат идентичен. что тоже странно.
в настройках ktorrent'a указан порт 7000. и он в данный момент работает.
Изображение
Собственно вопрос: почему порт находится в закрытом состоянии и как его все-таки открыть?

зы iptables вроде ничего не режет.
на всякий случай включил

Код: Выделить всё

iptables -A INPUT -p tcp -i eth0 --dport 7000 -j ACCEPT

ну и сами правила iptables:

Код: Выделить всё

 # iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
fail2ban-apache-overflows  tcp  --  anywhere             anywhere            multiport dports www,https
fail2ban-apache  tcp  --  anywhere             anywhere            multiport dports www,https
fail2ban-ssh-ddos  tcp  --  anywhere             anywhere            multiport dports ssh
fail2ban-vsftpd  tcp  --  anywhere             anywhere            multiport dports ftp,ftp-data,ftps,ftps-data
fail2ban-apache-multiport  tcp  --  anywhere             anywhere            multiport dports www,https
fail2ban-ssh  tcp  --  anywhere             anywhere            multiport dports ssh
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:afs3-fileserver

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

Chain fail2ban-apache (1 references)
target     prot opt source               destination
RETURN     all  --  anywhere             anywhere

Chain fail2ban-apache-multiport (1 references)
target     prot opt source               destination
RETURN     all  --  anywhere             anywhere

Chain fail2ban-apache-overflows (1 references)
target     prot opt source               destination
RETURN     all  --  anywhere             anywhere

Chain fail2ban-ssh (1 references)
target     prot opt source               destination
RETURN     all  --  anywhere             anywhere

Chain fail2ban-ssh-ddos (1 references)
target     prot opt source               destination

Chain fail2ban-vsftpd (1 references)
target     prot opt source               destination
RETURN     all  --  anywhere             anywhere
И тот же tcpdump показывает что какая то активность на 7000 порту все же есть.
Что не так то?
UNIX is basically a simple operating system, but you have to be a genius to understand the simplicity. © Dennis Ritchie
The more you believe you don't do mistakes, the more bugs are in your code.
Спасибо сказали:
Аватара пользователя
Alex2ndr
Сообщения: 443
ОС: Debian Lenny

Re: Решено: Открытие портов

Сообщение Alex2ndr »

Читаем man nmap:

The output from Nmap is a list of scanned targets, with supplemental information on each depending on the options used. Key among that information
is the ”interesting ports table”. That table lists the port number and protocol, service name, and state. The state is either open, filtered,
closed, or unfiltered. Open means that an application on the target machine is listening for connections/packets on that port. Filtered means
that a firewall, filter, or other network obstacle is blocking the port so that Nmap cannot tell whether it is open or closed. Closed ports have
no application listening on them, though they could open up at any time.
Ports are classified as unfiltered when they are responsive to Nmapґs
probes, but Nmap cannot determine whether they are open or closed. Nmap reports the state combinations open|filtered and closed|filtered when it
cannot determine which of the two states describe a port. The port table may also include software version details when version detection has been
requested. When an IP protocol scan is requested (-sO), Nmap provides information on supported IP protocols rather than listening ports.

Таким образом получается, что приложение не слушает их, но они могут быть открыты в любой момент. Думаю здесь так же как в ftp - сначала идет диалог установки связи, потом данные идут по related соединению как раз через ваш порт. Таким образом порт действительно никто не слушает - по нему только идут данные. Чтобы точно знать надо читать протокол bittorrent. Я его изучал, но только в части обмена информации с трекером по http. Как там работает транспорт я только догадываюсь.
Спасибо сказали:
Аватара пользователя
SLEDopit
Модератор
Сообщения: 4824
Статус: фанат консоли (=
ОС: GNU/Debian, RHEL

Re: Решено: Открытие портов

Сообщение SLEDopit »

Понятно. Спасибо.
UNIX is basically a simple operating system, but you have to be a genius to understand the simplicity. © Dennis Ritchie
The more you believe you don't do mistakes, the more bugs are in your code.
Спасибо сказали:
Аватара пользователя
*Sasha*
Сообщения: 2519
Статус: Мимо шёл
ОС: Debian

Re: Решено: Открытие портов

Сообщение *Sasha* »

Должен быть открыт всегда если запущен, возможно он слушает inet6, вывод
netstat -tunap | grep ktorrent
Спасибо сказали:
Аватара пользователя
SLEDopit
Модератор
Сообщения: 4824
Статус: фанат консоли (=
ОС: GNU/Debian, RHEL

Re: Решено: Открытие портов

Сообщение SLEDopit »

*Sasha* писал(а):
19.04.2010 14:50
Должен быть открыт всегда если запущен, возможно он слушает inet6, вывод
netstat -tunap | grep ktorrent

Код: Выделить всё

 # netstat -tunap | grep ktorrent
tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN      2418/ktorrent
tcp        0      0 192.168.1.60:40414      69.133.99.134:50000     ESTABLISHED 2418/ktorrent
tcp        0      1 192.168.1.60:36044      95.221.115.13:37882     SYN_SENT    2418/ktorrent
tcp        0      1 192.168.1.60:50554      188.123.241.13:13152    SYN_SENT    2418/ktorrent
tcp        0      0 192.168.1.60:56956      195.241.2.17:60499      ESTABLISHED 2418/ktorrent
tcp        0      1 192.168.1.60:36800      91.77.234.74:13286      SYN_SENT    2418/ktorrent
tcp        0      0 192.168.1.60:57713      69.133.99.134:50000     ESTABLISHED 2418/ktorrent
tcp        0      1 192.168.1.60:39883      95.79.201.1:52980       SYN_SENT    2418/ktorrent
tcp        0      0 192.168.1.60:55702      62.182.50.187:33893     ESTABLISHED 2418/ktorrent
tcp        0      0 192.168.1.60:43950      62.182.50.187:33896     ESTABLISHED 2418/ktorrent
tcp        0      0 192.168.1.60:43806      69.133.99.134:50000     ESTABLISHED 2418/ktorrent
tcp        0      1 192.168.1.60:43644      93.84.219.192:53616     SYN_SENT    2418/ktorrent
tcp        1      0 192.168.1.60:53928      195.82.146.120:80       CLOSE_WAIT  29816/ktorrentid241
tcp        0  16397 192.168.1.60:52919      94.99.64.196:36052      ESTABLISHED 2418/ktorrent
tcp        0      0 192.168.1.60:33806      85.89.171.59:52152      ESTABLISHED 2418/ktorrent
tcp        0  63356 192.168.1.60:37415      109.64.147.31:17020     ESTABLISHED 2418/ktorrent
tcp        0  39092 192.168.1.60:59994      109.107.166.94:23615    ESTABLISHED 2418/ktorrent
tcp        0      0 192.168.1.60:57323      109.184.215.31:53518    ESTABLISHED 2418/ktorrent
tcp        0      0 192.168.1.60:60854      69.133.99.134:50000     ESTABLISHED 2418/ktorrent
tcp        0      0 192.168.1.60:40902      69.133.99.134:50000     ESTABLISHED 2418/ktorrent
tcp        0      1 192.168.1.60:49899      99.31.52.11:50984       SYN_SENT    2418/ktorrent
tcp        0      1 192.168.1.60:50401      94.232.14.32:63335      SYN_SENT    2418/ktorrent
tcp        0      1 192.168.1.60:52901      213.138.70.53:19953     SYN_SENT    2418/ktorrent
tcp6       0      0 :::7000                 :::*                    LISTEN      2418/ktorrent
udp6       0      0 :::7001                 :::*                                2418/ktorrent
UNIX is basically a simple operating system, but you have to be a genius to understand the simplicity. © Dennis Ritchie
The more you believe you don't do mistakes, the more bugs are in your code.
Спасибо сказали:
Аватара пользователя
*Sasha*
Сообщения: 2519
Статус: Мимо шёл
ОС: Debian

Re: Решено: Открытие портов

Сообщение *Sasha* »

SLEDopit писал(а):
19.04.2010 17:23
tcp6 0 0 :::7000 :::* LISTEN 2418/ktorrent

Так и есть, если просканишь вот так nmap -6 ::1 -p 7000, то увидишь что он открыт.
Спасибо сказали:
Аватара пользователя
SLEDopit
Модератор
Сообщения: 4824
Статус: фанат консоли (=
ОС: GNU/Debian, RHEL

Re: Решено: Открытие портов

Сообщение SLEDopit »

*Sasha* писал(а):
19.04.2010 17:57
Так и есть, если просканишь вот так nmap -6 ::1 -p 7000, то увидишь что он открыт.
И правда. Все так и есть.
Теперь понятно куда копать. Спасибо.
UNIX is basically a simple operating system, but you have to be a genius to understand the simplicity. © Dennis Ritchie
The more you believe you don't do mistakes, the more bugs are in your code.
Спасибо сказали: