PDA

Показать полную графическую версию : Windows XP SP2 в виртуальной машине: не удается проброс портов


Svet
15-06-2010, 17:01
Здравствуйте!

Даны:

Сервер: Ubuntu Server i386 8.04.3 LTS, Linux 2.6.24-21. Его адрес в локальной сети организации: Local_IP. На нем установлен VMware Server 2, в котором настроена виртуальная локальная сеть 172.16.1.0/24. В этой сети находятся две виртуальные машины: с Windows XP SP2 (172.16.1.154; пользователь: administrator) и с FreeBSD 8.0. На виртуальной машине с Windows XP установлены и запущены VMware Tools. Также установлен и запущен SSH-сервер OpenSSH. Брандмауэр включен, в нем разрешены исключения, и в число исключений добавлен порт 22. Маршрут в сеть 172.16.1.0/24 на сервере установлен.

ПК: Ubuntu i386 9.10 в другой локальной сети организации с доступом к этому серверу.

Требуется: наладить SSH-соединение от ПК к виртуальной машине с Windows XP.

Решение:

На сервере я сделал "проброс" портов по следующему правилу:

sudo iptables -t nat -A PREROUTING -p tcp --dport 50016 -j DNAT --to-destination 172.16.1.154:22


Не работает:

Зайти на виртуальную машину с Windows XP по SSH с ПК не удается:

ПК$ ssh -v -p 50016 administrator@Local_IP
OpenSSH_5.1p1 Debian-6ubuntu2, OpenSSL 0.9.8g 19 Oct 2007
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to Local_IP [Local_IP] port 50016.
debug1: connect to address Local_IP port 50016: Connection timed out
ssh: connect to host Local_IP port 50016: Connection timed out

При этом:

Адрес 172.16.1.154 с сервера не пингуется.

На виртуальную машину с Windows XP возможен доступ по SSH c сервера:


СЕРВЕР$ ssh administrator@172.16.1.154
Failed to add the host to the list of known hosts (/home/toor/.ssh/known_hosts).

****USAGE WARNING****
[...]

administrator@172.16.1.154's password:
Last login: Tue Jun 15 14:03:46 2010 from 172.16.1.1
Microsoft Windows XP [������ 5.1.2600]
(�) ��௮����� ����������, 1985-2001.

C:\Documents and Settings\administrator>exit
Connection to 172.16.1.154 closed.


Утилита nmap с сервера адрес 172.16.1.154 не видит:

СЕРВЕР$ nmap 172.16.1.154

Starting Nmap 4.53 ( http://insecure.org ) at 2010-06-15 14:47 MSD
Note: Host seems down. If it is really up, but blocking our ping probes, try -PN
Nmap done: 1 IP address (0 hosts up) scanned in 2.033 seconds

а если отменить проверку хоста перед сканированием портов, то выдает:

СЕРВЕР$ nmap -PN 172.16.1.154

Starting Nmap 4.53 ( http://insecure.org ) at 2010-06-15 16:01 MSD
Interesting ports on 172.16.1.154:
Not shown: 1710 closed ports
PORT STATE SERVICE
22/tcp open ssh
135/tcp open msrpc
139/tcp open netbios-ssn
445/tcp open microsoft-ds

Порт 50016 с ПК nmap видит как отфильтрованный.

Наверное, я должен настроить Windows XP? (Если да, то хотелось бы понять, как).

Отключение брандмауэра в Windows XP обеспечило только пингование адреса 172.16.1.154 с сервера.

Для сравнения:

Соединение по SSH от ПК к виртуальной машине с FreeBSD 8.0 по аналогичному правилу проброса портов работает. Если для этого проброса назначить тот же порт 50016, то nmap с ПК его увидит как открытый.

Svet
17-06-2010, 19:15
Дополнительная информация.

В Windows XP в службе "Просмотр событий" в разделе "Приложение" при попытках зайти по SSH не с сервера (с любого другого IP) публикуется несколько уведомлений вида:


sshd: PID 1492: Could not write ident string to IP


а при подключении с сервера (всегда успешном) печатает два уведомления вида:


sshd: PID 652 Accepted password for administrator from 172.16.1.1 port 60700 ssh2


и


sshd: PID 556: reverse mapping checking getaddrinfo for имя_сервера.1.16.172.in-addr.arpa failed - POSSIBLE BREAKIN ATTEMPT!.


C:\Program Files\OpenSSH\etc\sshd_config:


# $OpenBSD: sshd_config,v 1.65 2003/08/28 12:54:34 markus Exp $

# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin

# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options change a
# default value.

#Port 22
#Protocol 2,1
Protocol 2
#ListenAddress 0.0.0.0
#ListenAddress ::

# HostKey for protocol version 1
#HostKey /etc/ssh/ssh_host_key
# HostKeys for protocol version 2
#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key

# Lifetime and size of ephemeral version 1 server key
#KeyRegenerationInterval 1h
#ServerKeyBits 768

# Logging
#obsoletes QuietMode and FascistLogging
#SyslogFacility AUTH
#LogLevel INFO

# Authentication:

#LoginGraceTime 2m
PermitRootLogin yes

# The following setting overrides permission checks on host key files
# and directories. For security reasons set this to "yes" when running
# NT/W2K, NTFS and CYGWIN=ntsec.
StrictModes yes

RSAAuthentication no
#PubkeyAuthentication yes
#AuthorizedKeysFile .ssh/authorized_keys

# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#RhostsRSAAuthentication no
# similar for protocol version 2
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# RhostsRSAAuthentication and HostbasedAuthentication
IgnoreUserKnownHosts yes
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes

# To disable tunneled clear text passwords, change to no here!
PasswordAuthentication yes
#PermitEmptyPasswords no

# Change to no to disable s/key passwords
#ChallengeResponseAuthentication yes

# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCreds yes

# Set this to 'yes' to enable PAM authentication (via challenge-response)
# and session processing. Depending on your PAM configuration, this may
# bypass the setting of 'PasswordAuthentication'
#UsePAM no

#AllowTcpForwarding yes
#GatewayPorts no
#X11Forwarding no
#X11DisplayOffset 10
#X11UseLocalhost yes
#PrintMotd yes
#PrintLastLog yes
#KeepAlive yes
#UseLogin no
UsePrivilegeSeparation no
#PermitUserEnvironment no
#Compression yes
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS yes
#PidFile /var/run/sshd.pid
MaxStartups 10:30:60

# default banner path
Banner /etc/banner.txt

# override default of no subsystems
Subsystem sftp /usr/sbin/sftp-server

Svet
18-06-2010, 17:00
Все неожиданно решилось очень просто: ошибка была в адресе маршрутизатора виртуальной локальной сети, прописанном в графе "Основной шлюз" в Windows XP. После ее исправления все заработало. Глупо, но, что поделаешь.




© OSzone.net 2001-2012