Na debianie na vps'ie mam zainstalowanego ufw do firewalla.
Chce zrobić przekierowanie z zewnętrznego adresu na danym porcie 59050 przekierowanie na interfejs wireguard'a na dany adres ip
Czyli 45.x.x.x:59050 -> 10.9.0.2:5900 więc dopisałem takie coś na końcu pliku /etc/ufw/before.rules
cat /etc/ufw/before.rules
# allow MULTICAST UPnP for service discovery (be sure the MULTICAST line above
# is uncommented)
-A ufw-before-input -p udp -d 239.255.255.250 --dport 1900 -j ACCEPT
# don't delete the 'COMMIT' line or these rules won't be processed
COMMIT
*nat :PREROUTING ACCEPT [0:0]
-A PREROUTING -p udp -i eth0 --dport 59050 -j DNAT \ --to-destination 10.9.0.2:5900
COMMIT
Niestety ta reguła raczej nie działa
root@vps:~# iptables -t nat -L -n -v
Chain PREROUTING (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain POSTROUTING (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
37 3012 MASQUERADE all -- * eth0 0.0.0.0/0 0.0.0.0/0
root@vps:~#
Przekierowanie to zrobiłem według tego opisu
https://serverfault.com/questions/41153 … another-ip
Adres 10.9.0.2 to adres mojego komputera z podstawionym vnc serwerem.
Edit:
Ruch z przekierowaniem już jest widoczny w iptables ale jednak jeszcze nie działa
iptables -t nat -L -n -v
Chain PREROUTING (policy ACCEPT 74 packets, 9566 bytes)
pkts bytes target prot opt in out source destination
2 104 DNAT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:59050 to:10.9.0.2:5900
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain POSTROUTING (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
22 1772 MASQUERADE all -- * eth0 0.0.0.0/0 0.0.0.0/0
root@vps:~#