写了个shell脚本,但是执行出错,大佬门帮我看看。
[*]#!/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
[*]复制代码
变量定义 =的左右,不要有空格
ltfun 发表于 2019-3-30 18:33
变量定义 =的左右,不要有空格
ok
谢谢大佬
页:
[1]