0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

メモ: DNAT、SNAT の設定

Last updated at Posted at 2020-10-06

images1.png

DNAT

Yamaha

nat descriptor masquerade static 2 1 172.16.1.2 udp 500=500
nat descriptor masquerade static 2 2 172.16.1.2 udp 4500=4500

VyOS

set nat destination rule 10 description 'Port Forward: HTTP to 192.168.0.100'

set nat destination rule 10 destination port '80'
set nat destination rule 10 inbound-interface 'eth0'
set nat destination rule 10 protocol 'tcp'
set nat destination rule 10 translation address '192.168.0.100'

Linux (iptables)

OS側の準備

/etc/sysctl.d/99-ipv4_ip_forward.conf
net.ipv4.ip_forward=1
sysctl -p

DNAT ( 送信先アドレスを変換 )

  • 参考
  • 入ってくるパケットのIPを変換
    • インターネットからLAN内にアクセスする時に、送信先のパブリックIPアドレス → ローカルIPに変換
  • 192.168.100.1:80 に来た通信 を 192.168.0.117:80 に転送
iptables -t nat \
 -A PREROUTING \
 -p tcp \
 -d 192.168.100.1 \
 --dport 80 -j DNAT \
 --to-destination 192.168.0.117:80

SNAT ( 送信元アドレスを変換 )

iptables -t nat \
 -A POSTROUTING \
 -p tcp \
 -d 192.168.0.117 \
 --dport 80 \
 -j SNAT \
 --to-source 192.168.0.118
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?