sed -i '9r'<(
echo "
# nat table rules
*nat
:PREROUTING ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
# port forwarding
-A PREROUTING -p tcp --dport 19685 -j DNAT --to-destination 目标IP:443
-A PREROUTING -p udp --dport 19685 -j DNAT --to-destination 目标IP:443
-A POSTROUTING -p tcp -d 目标IP --dport 443 -j SNAT --to-source $(hostname -I)
-A POSTROUTING -p udp -d 目标IP --dport 443 -j SNAT --to-source $(hostname -I)
# commit to apply changes
COMMIT") /etc/ufw/before.rules
# 执行如下命令启动即可
ufw enable