Common Tools

Website

Apple Laptop

Desktop

Command Line

System monitoring

Command Memo

iptables port mapping

Allow IP forwarding for the server

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

Port Forwarding

#!/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

Save

sudo /usr/libexec/iptables/iptables.init save
Last Updated:
Contributors: gcxfd