-
[IPFS] 노드간의 연결 문제(NAT Problem)IPFS 2023. 2. 28. 00:11728x90반응형
IPFS 두 번째 글인데
조금 많은 실험도 해보고있지만
언제나 발생했던 문제점이 있었다.
바로 노드간의 연결할 때 생기는 문제점이었다.
그런데 이게 집에서 할 때는 연결이 되지 않는 점도 있고 카페에서 할 때는 연결이 되는 점이 발생하니
디바이스의 문제보다는 와이파이의 문제라고 항상 인식하고 있었다.
ipfs dht findpeer <PeerID> ipfs connect /ip4/<ip addr>/hash등의 수동적으로 연결시키는 명령어를 이용하여 실행도 해보았다.
위의 두 명령어에 관하여 연결이 실패한다면
https://docs.ipfs.tech/how-to/troubleshooting/#check-that-your-ipfs-daemon-is-running
Troubleshooting | IPFS Docs
Troubleshooting If you're running into problems with IPFS, use this page to debug your issues and find a solution quickly. Check that your IPFS daemon is running If you're getting unexpected behavior when trying to run common commands such as ipfs get retu
docs.ipfs.tech
위의 페이지의 내용에 따라
- Nobody online has it.- There is one node that has the data, but it's behind a NAT.- The node that has it has not yet advertised the data in a way that your node can find it.세가지 문제점이 있다고 하였으며 기본적인 online은 당연히 연결되어있고 두번째가 제일 문제점으로 꼽았다.그렇게 해결하려고 살펴보니디버그를 해야 할 필요가 있었고 ipfs daemon에서 디버그를 info level로 설정하여 진행하였더니
2023-02-10T12:01:59.065+0900 INFO basichost basic/natmgr.go:93 DiscoverNAT error:no NAT found
위의 결과가 나왔다. 역시 NAT에 관한 문제였다.
NAT 문제를 본격적으로 해결하려고하며 DEBUG level에서도 한 번 봤는데
2023-02-13T09:36:53.692+0900 WARN net/identify identify/peer_loop.go:93failed to send Identify Push {"peer": "12D3KooWNC2d8LLnFhbxodkUuCHxZpFUZxoCwFd5SrGHtvSxGsFj", "error": "failed to open push stream: transient connection to peer"}
다음의 문제도 발견하게 되었고 transient connection to peer라고 나오는 것을 보아하니 일시적으로만 연결된다고하여 peer_loop.go 파일을 들어가서 해결을 하려했다. 하지만, peer_loop.go를 담당하는 libp2p에는 이미 업데이트가되어 해당 파일은 존재하지않아 더욱 어려움을 겪었고 어디서부터 시작해야 할 지 몰랐지만 NAT이 핵심 문제라고 생각했기에 그 부분을 다시 찾아보았다.
https://docs.ipfs.tech/how-to/nat-configuration/#background
Configure NAT and port forwarding | IPFS Docs
Configure NAT and port forwarding A common issue for new users running IPFS Kubo, especially on home networks, is that their IPFS node is behind a NAT (network address translation) layer (such as a residential network router). This can cause users to exper
docs.ipfs.tech
그렇게 찾아보니 나온 곳에서 잘 설명되어 있었으며라우터를 열어보고 그곳에서 UPnP, IPv6 등을 활성화 시키라고 되어있었다.이 부분을 하지 않는다면 수동으로 하라고해서 수동으로 하려했고nano .ipfs/config를 실행하여"AppendAnnounce": [ "/ip4/<public-ip>/tcp/<port>", "/ip4/<public-ip>/udp/<port>/quic", "/ip4/<public-ip>udp/<port>/quic-v1", "/ip4/<public-ip>/udp/<port>/quic-v1/webtransport", ],해당 부분을 추가했다. public-ip는 상대방에게 보이는 나의 ip 주소이고 port는 4001번을 권장한다.
하지만 여기서 가장 중요한 점은 이 부분만 바꾸면 안되었다.
이 부분을 바꾸기 전 라우터에 들어가 직접 포트포워딩을 해줘야하는데 라즈베리파이를 이용하는 나는 각각 다른 지역에 있어 고충을 또 겪었다.
그래도 역시 원격으로 접속해서도 다 할 수 있기에 찾아보니
sudo apt-get install ufw sudo ufw allow 4001을 해주면 해결이 되었다.
이 부분을 할 때, 해결이 안되는 사람도 있는데 이런 오류가 뜰 수 있다.
ERROR: COULDN’T DETERMINE IPTABLES VERSION
이런 오류 메세지를 발견하면
sudo update-alternatives --set iptables /usr/sbin/iptables-legacy이 코맨드를 입력하면 해결된다.
그렇게 하면 완벽히 연결까지 되는 것을 확인할 수 있다.
이제 나도 실험 자유롭게 할 수 있는 환경이 구축됐달까...
되게 고충이 많았는데 해결이돼서 다행인듯한...
앞으로 더 꾸준히 공부해서 올려보도록!
728x90반응형'IPFS' 카테고리의 다른 글
[IPFS] 분산 탈중앙 시스템에 Access control을 제공하는 Macaroons (0) 2023.05.19 [IPFS] Peer selection을 하는 방법 (0) 2023.05.04 [IPFS] IPFS (0) 2023.02.02