TCP: 한 PC는 다른 PC의 수신 대기 포트에 연결할 수 있지만 그 반대는 불가능합니다.

TCP: 한 PC는 다른 PC의 수신 대기 포트에 연결할 수 있지만 그 반대는 불가능합니다.

저는 로컬 네트워크를 가지고 있습니다(VPN인지 실제 로컬 네트워크인지는 중요하지 않습니다. 둘 다 시도해 보았습니다).

Linux Mint를 실행하는 컴퓨터가 소켓을 엽니다.

mint$ nc -l 4242

OpenSUSE를 실행하는 두 번째 항목은 소켓에 연결하고 메시지를 보낼 수 있습니다.

suse$ nc 10.8.0.10 4242

그러나 Suse에서 소켓을 열고 Mint에서 연결하려고 하면 연결이 설정되지 않습니다. ufwSuse에는 방화벽이 전혀 설치되어 있지 않습니다 .

Mint에서 Windows PC로 TCP 패킷을 보내려고 했는데 잘 작동했으므로 Suse 시스템에 문제가 있는 것 같습니다.

만일을 대비해 더 높은 포트 번호(예: 55555)를 선택해 보았지만 성공하지 못했습니다.

iptables -L -v수스 소개:

Chain INPUT (policy DROP 0 packets, 0 bytes)
pkts bytes target     prot opt in     out     source               destination         
 272 23240 ACCEPT     all  --  lo     any     anywhere             anywhere            
  28  5183 ACCEPT     all  --  any    any     anywhere             anywhere             ctstate ESTABLISHED
   0     0 ACCEPT     icmp --  any    any     anywhere             anywhere             ctstate RELATED
  15  4984 input_ext  all  --  any    any     anywhere             anywhere            
   0     0 LOG        all  --  any    any     anywhere             anywhere             limit: avg 3/min burst 5 LOG level warning tcp-options ip-options prefix "SFW2-IN-ILL-TARGET "
   0     0 DROP       all  --  any    any     anywhere             anywhere            

Chain FORWARD (policy DROP 0 packets, 0 bytes)
pkts bytes target     prot opt in     out     source               destination         
   0     0 LOG        all  --  any    any     anywhere             anywhere             limit: avg 3/min burst 5 LOG level warning tcp-options ip-options prefix "SFW2-FWD-ILL-ROUTING "

Chain OUTPUT (policy ACCEPT 47 packets, 7142 bytes)
pkts bytes target     prot opt in     out     source               destination         
 272 23240 ACCEPT     all  --  any    lo      anywhere             anywhere            

Chain forward_ext (0 references)
pkts bytes target     prot opt in     out     source               destination         

Chain input_ext (1 references)
pkts bytes target     prot opt in     out     source               destination         
   2  1956 DROP       all  --  any    any     anywhere             anywhere             PKTTYPE = broadcast
   0     0 ACCEPT     icmp --  any    any     anywhere             anywhere             icmp source-quench
   0     0 ACCEPT     icmp --  any    any     anywhere             anywhere             icmp echo-request
  13  3028 DROP       all  --  any    any     anywhere             anywhere             PKTTYPE = multicast
   0     0 DROP       all  --  any    any     anywhere             anywhere             PKTTYPE = broadcast
   0     0 LOG        tcp  --  any    any     anywhere             anywhere             limit: avg 3/min burst 5 tcp flags:FIN,SYN,RST,ACK/SYN LOG level warning tcp-options ip-options prefix "SFW2-INext-DROP-DEFLT "
   0     0 LOG        icmp --  any    any     anywhere             anywhere             limit: avg 3/min burst 5 LOG level warning tcp-options ip-options prefix "SFW2-INext-DROP-DEFLT "
   0     0 LOG        udp  --  any    any     anywhere             anywhere             limit: avg 3/min burst 5 ctstate NEW LOG level warning tcp-options ip-options prefix "SFW2-INext-DROP-DEFLT "
   0     0 DROP       all  --  any    any     anywhere             anywhere            

Chain reject_func (0 references)
pkts bytes target     prot opt in     out     source               destination         
   0     0 REJECT     tcp  --  any    any     anywhere             anywhere             reject-with tcp-reset
   0     0 REJECT     udp  --  any    any     anywhere             anywhere             reject-with icmp-port-unreachable
   0     0 REJECT     all  --  any    any     anywhere             anywhere             reject-with icmp-proto-unreachable

이 문제의 원인은 무엇입니까?

답변1

다음 명령을 사용하십시오.

sudo iptables -I INPUT -p tcp --dport 4242 -j ACCEPT

수세 체인의 마지막 줄은 다음 INPUT과 같습니다.

   0     0 DROP       all  --  any    any     anywhere             anywhere            

이는 DROP모든 INPUT패킷을 의미합니다. 이 명령을 사용하십시오.

sudo iptables -I INPUT -p tcp --dport 4242 -j ACCEPT

I입력 패킷을 최상위에서 받아들이고 규칙보다 먼저 실행하기 위한 DROP새로운 규칙을 삽입합니다 .

그리고 이 규칙은 새로운 연결에는 적용되지 않습니다.

ACCEPT     all  --  any    any     anywhere             anywhere             ctstate ESTABLISHED

이 통계가 ESTABLISHED의미하는 바는 다음과 같습니다.

관련됨 - 새 연결이지만 이미 허용된 다른 연결과 관련되어 있습니다. ESTABLISHED - 연결이 설정되었습니다.

관련 정보