summaryrefslogtreecommitdiff
path: root/gemfeed/stunnel-nfs-quick-reference.txt
blob: ca7f577a35c831b28a72e5928793e2cec120a28d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
STUNNEL + NFS QUICK REFERENCE FOR r1 AND r2
===========================================

COMPLETE SETUP (run as root on r1 and r2):
------------------------------------------

# 1. Install stunnel
dnf install -y stunnel

# 2. Copy certificate from f0 (run on f0)
scp /usr/local/etc/stunnel/stunnel.pem root@r1:/etc/stunnel/
scp /usr/local/etc/stunnel/stunnel.pem root@r2:/etc/stunnel/

# 3. Create stunnel config on r1/r2
mkdir -p /etc/stunnel
cat > /etc/stunnel/stunnel.conf <<'EOF'
cert = /etc/stunnel/stunnel.pem
client = yes

[nfs-ha]
accept = 127.0.0.1:2323
connect = 192.168.1.138:2323
EOF

# 4. Create systemd service
cat > /etc/systemd/system/stunnel.service <<'EOF'
[Unit]
Description=SSL tunnel for network daemons
After=network.target

[Service]
Type=forking
ExecStart=/usr/bin/stunnel /etc/stunnel/stunnel.conf
ExecStop=/usr/bin/killall stunnel
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
EOF

# 5. Enable and start stunnel
systemctl daemon-reload
systemctl enable --now stunnel

# 6. Create mount point
mkdir -p /data/nfs/k3svolumes

# 7. Test mount
mount -t nfs4 -o port=2323 127.0.0.1:/data/nfs/k3svolumes /data/nfs/k3svolumes

# 8. Verify mount works
ls -la /data/nfs/k3svolumes/

# 9. Add to fstab for persistence
echo "127.0.0.1:/data/nfs/k3svolumes /data/nfs/k3svolumes nfs4 port=2323,_netdev 0 0" >> /etc/fstab

# 10. Test fstab mount
umount /data/nfs/k3svolumes
mount /data/nfs/k3svolumes

VERIFICATION COMMANDS:
----------------------
systemctl status stunnel
mount | grep k3svolumes
df -h /data/nfs/k3svolumes
echo "test" > /data/nfs/k3svolumes/test-$(hostname).txt

TROUBLESHOOTING:
----------------
# Check stunnel logs
journalctl -u stunnel -f

# Test connectivity
telnet 127.0.0.1 2323

# Restart services
systemctl restart stunnel
umount /data/nfs/k3svolumes && mount /data/nfs/k3svolumes