Oracle Cloud 설정

Oracle Cloud 설정

요약: Oracle Cloud 기본 설정 요약

Oracle Cloud에 VM 생성하기 전에 네트워크를 우선 설정한다. 설정 방법은 블로그 글을 참고한다.

Oracle Cloud의 Ubuntu 이미지에서는 iptables를 사용하며 22외 모든 포트는 닫혀있다. 먼저 서버 운영을 위해 필요한 최소한의 포트인 HTTP, HTTPS, WireGuard을 오픈한다. 추후 서버에 서비스 설치하며 필요한 포트는 그때 그때 오픈한다.

Oracle Cloud에는 2가지 firewall이 설정되어 있다. 이는 외부 Oracle Cloud의 firewall과 Ubuntu의 firewall 이다. 패킷이 외부에서 Ubuntu까지 오려면 2개의 firewall을 오픈해야 한다. 외부 Oracle Cloud firewall 오픈방법은 이 블로그를 참고한다.

Ubuntu Firewall 설정

Ubuntu firewall 설정 방법은 다음과 같다.

# Check iptables
sudo iptables -L

# Add rules
sudo apt install iptables-persistent
sudo iptables -I INPUT 5 -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
sudo iptables -I INPUT 5 -p tcp --dport 81 -m state --state NEW,ESTABLISHED -j ACCEPT
sudo iptables -I INPUT 5 -p tcp --dport 443 -m state --state NEW,ESTABLISHED -j ACCEPT

# WireGuard
sudo iptables -I INPUT 8 -p udp --dport 51820 -m state --state NEW,ESTABLISHED -j ACCEPT
sudo iptables -I INPUT 8 -p tcp --dport 51821 -m state --state NEW,ESTABLISHED -j ACCEPT

# Save rules
sudo netfilter-persistent save

참고: https://library.gabia.com/contents/infrahosting/2214/

WireGuard (VPN) 설정

WireGuard는 linux server 버전의 WireGuard를 사용했다. WireGuard의 key를 복사하고 client (i.e., 접속하고자하는 peer)에 추가한다.

less config/peer1/peer1.conf
[interface]
Address = 10.0.10.2
PrivateKey = xxx
ListenPort = 51820
DNS = 10.0.10.1

[Peer]
PublicKey = xxx
PresharedKey = xxx
Endpoint = 123.123.123.123:51820
AllowedIPs = 0.0.0.0/0, ::/0