小编d0x*_*d0x的帖子

如何在 Amazon EC2 VPC NAT Ami 上保留 iptables 配置?

我有一个像这样的小脚本来配置 iptables:

#!/bin/bash

PRE_STR="iptables -t nat -A PREROUTING -p tcp -j DNAT"
FOR_STR="iptables -A FORWARD -p tcp -j ACCEPT"


#####################################
# instances
CM="10.0.1.137"
MASTER="10.0.1.149"
MYSQL="10.0.1.83"
REPORTING="10.0.1.85"

#####################################
# Clear Iptables
iptables -F
iptables -t nat -F

#####################################
# Forward to enable Internet on private nodes
iptables -t nat -A POSTROUTING -j MASQUERADE


#####################################
# Port forwarding

forward()
{
        $PRE_STR --dport $1 --to $2:$3
        $FOR_STR --dport $3 -d $2
}

#what   from    to ip           to port
forward 3222    $CM             22
forward …
Run Code Online (Sandbox Code Playgroud)

nat iptables amazon-ec2 amazon-vpc

12
推荐指数
2
解决办法
2万
查看次数

标签 统计

amazon-ec2 ×1

amazon-vpc ×1

iptables ×1

nat ×1