내 웹 서버를 공개적으로 액세스할 수 있도록 설정

내 웹 서버를 공개적으로 액세스할 수 있도록 설정

내 Debian 서버에는 eth0 인터페이스(192.168.10.x)가 있고 방금 eth1(176.31.36.x)을 추가했습니다. SSH, 웹 등에 대한 공개 액세스를 설정하고 싶습니다.

allow-hotplug eth1
iface eth1 inet static
        address 176.31.36.x
        netmask 255.255.255.240
        network 176.31.36.x
        broadcast 171.31.36.x
        dns-nameservers 8.8.8.8
        gateway 176.31.36.x
        dns-search mydomain.com

다음 경로를 추가했습니다.

iptables -I INPUT -p tcp --dport 80 -j ACCEPT -m comment --comment "Allow HTTP"
iptables -I INPUT -p tcp --dport 443 -j ACCEPT -m comment --comment "Allow HTTPS"
iptables -I INPUT -p tcp -m state --state NEW --dport 22 -j ACCEPT -m comment --comment "Allow SSH"

그 후 서버가 다시 시작됩니다. 시스템에 대한 핑은 제대로 작동하지만 ssh나 웹 모두 응답하지 않습니다.

예:

ssh -v 176.31.36.x
OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 176.31.36.x [176.31.36.x] port 22.
debug1: Connection established.
debug1: identity file /home/admin/.ssh/id_rsa type -1
debug1: identity file /home/admin/.ssh/id_rsa-cert type -1
debug1: identity file /home/admin/.ssh/id_dsa type -1
debug1: identity file /home/admin/.ssh/id_dsa-cert type -1
debug1: identity file /home/admin/.ssh/id_ecdsa type -1
debug1: identity file /home/admin/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/admin/.ssh/id_ed25519 type -1
debug1: identity file /home/admin/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.0p1 Debian-3ubuntu1
debug1: match: OpenSSH_6.0p1 Debian-3ubuntu1 pat OpenSSH* compat 0x04000000
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA 10:59:34:f5:bb:bb:6b:3f:7a:39:1b:26:24:45:18:cb
debug1: Host '176.31.36.x' is known and matches the ECDSA host key.
debug1: Found key in /home/admin/.ssh/known_hosts:57
debug1: ssh_ecdsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /home/admin/.ssh/id_rsa
debug1: Trying private key: /home/admin/.ssh/id_dsa
debug1: Trying private key: /home/admin/.ssh/id_ecdsa
debug1: Trying private key: /home/admin/.ssh/id_ed25519
debug1: No more authentication methods to try.
Permission denied (publickey).

업데이트: netstat의 출력:

sudo netstat -lpn | grep ^tcp
tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN      508/beam        
tcp        0      0 127.0.0.1:44400         0.0.0.0:*               LISTEN      508/beam        
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      10968/sshd      
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      846/exim4       
tcp        0      0 0.0.0.0:8443            0.0.0.0:*               LISTEN      508/beam        
tcp        0      0 127.0.0.1:11211         0.0.0.0:*               LISTEN      443/memcached   
tcp6       0      0 :::80                   :::*                    LISTEN      906/apache2     
tcp6       0      0 ::1:25                  :::*                    LISTEN      846/exim4       
tcp6       0      0 :::443                  :::*                    LISTEN      906/apache2    

답변1

교환 후에 이것이 라우팅 문제라는 것이 분명해졌습니다. 일부 다른 호스트는 176.31.36.x에 응답하고 있으며 ssh는 해당 호스트에 대한 연결을 설정합니다.

연결이 실제로 올바른 LAN으로 라우팅되었는지 확인하세요(가급적이면 두 개 이상의 네트워크에 있는 클라이언트에서). sudo traceroute 176.31.36.x여기 에서 유용할 sudo traceroute -I 176.31.36.xsudo traceroute -T 176.31.36.x있습니다.

그리고 LAN의 다른 장치가 해당 주소를 받고 있지 않은지(176.31.36.x) 확인하세요.

여전히 모든 것이 올바르다면 (176.31.36.x) LAN 라우터의 설정을 확인하세요. 예를 들어 다른 곳에서 SSH 연결을 위해 포트 전달이 구성되어 있을 수 있습니다.

이제 나는 그것이 그들 중 하나라고 확신합니다. 아니면 내 상상의 실패일지도 모르지만, 그럴 가능성은 점점 희박해 보입니다. ;-)

관련 정보