找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 32|回复: 2

写了个shell脚本,但是执行出错,大佬门帮我看看。

[复制链接]

134

主题

303

回帖

1070

积分

金牌会员

积分
1070
发表于 2019-3-30 18:28:13 | 显示全部楼层 |阅读模式
[ol]
  • #!/bin/bash
  • PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
  • export PATH
  • beginport = "10000"
  • endport = "20000"
  • transferip = "172.31.192.41"
  • destinationip = "45.76.146.203"
  • systemctl stop firewalld.service
  • systemctl disable firewalld.service
  • yum  -y install iptables-services
  • systemctl enable iptables.service
  • echo -e "net.ipv4.ip_forward=1" >> /etc/sysctl.conf
  • sysctl -p
  • iptables -t nat -A PREROUTING -p tcp -m tcp --dport ${beginport}:${endport} -j DNAT --to-destination ${destinationip}
  • iptables -t nat -A PREROUTING -p udp -m udp --dport ${beginport}:${endport} -j DNAT --to-destination ${destinationip}
  • iptables -t nat -A POSTROUTING -d ${destinationip} -p tcp -m tcp --dport ${beginport}:${endport} -j SNAT --to-source ${transferip}
  • iptables -t nat -A POSTROUTING -d ${destinationip} -p udp -m udp --dport ${beginport}:${endport} -j SNAT --to-source ${transferip}
  • service iptables save
  • [/ol]复制代码



  • 本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    ×
    回复

    使用道具 举报

    0

    主题

    6

    回帖

    16

    积分

    新手上路

    积分
    16
    发表于 2019-3-30 18:33:47 | 显示全部楼层
    变量定义 =  的左右,不要有空格
    回复

    使用道具 举报

    134

    主题

    303

    回帖

    1070

    积分

    金牌会员

    积分
    1070
     楼主| 发表于 2019-3-30 18:47:43 | 显示全部楼层

    ltfun 发表于 2019-3-30 18:33

    变量定义 =  的左右,不要有空格

    ok
    谢谢大佬
    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    Archiver|手机版|小黑屋|Discuz! X

    GMT+8, 2025-5-9 00:22 , Processed in 0.021220 second(s), 3 queries , Gzip On, Redis On.

    Powered by Discuz! X3.5

    © 2001-2024 Discuz! Team.

    快速回复 返回顶部 返回列表