常用工具

网站

苹果笔记本

桌面

命令行

系统监视

命令备忘

iptables 端口映射

允许服务器的 IP 转发功能

sysctl -w net.ipv4.ip_forward=1
iptables -t nat -A POSTROUTING -j MASQUERADE

端口转发

#!/bin/bash
pro='tcp'
NAT_Host='192.168.56.101'
NAT_Port=3480
Dst_Host='192.168.56.102'
Dst_Port=80
iptables -t nat -A PREROUTING -m $pro -p $pro --dport $NAT_Port -j DNAT --to-destination $Dst_Host:$Dst_Port
iptables -t nat -A POSTROUTING -m $pro -p $pro --dport $Dst_Port -d $Dst_Host -j SNAT --to-source $NAT_Host

保存

sudo /usr/libexec/iptables/iptables.init save
更新:
来自: gcxfd