Bash iptable错误参数'ACCEPT';
我正在尝试以下几点Bash iptable错误参数'ACCEPT';,bash,shell,sh,Bash,Shell,Sh,我正在尝试以下几点 #!/bin/bash NOIPHOST=example.noip.me LOGFILE=iptables_update.log Current_IP=$(host $NOIPHOST | cut -f4 -d' ') if [ $LOGFILE = "" ] ; then /sbin/iptables -I INPUT -m tcp -p tcp -s $Current_IP -j ACCEPT echo $Current_IP > $LOGFILE e
#!/bin/bash
NOIPHOST=example.noip.me
LOGFILE=iptables_update.log
Current_IP=$(host $NOIPHOST | cut -f4 -d' ')
if [ $LOGFILE = "" ] ; then
/sbin/iptables -I INPUT -m tcp -p tcp -s $Current_IP -j ACCEPT
echo $Current_IP > $LOGFILE
else
Last_IP=$(cat $LOGFILE)
if [ "$Current_IP" = "$Last_IP" ] ; then
echo IP address has not changed
else
/sbin/iptables -D INPUT -m tcp -p tcp -s $Last_IP -j ACCEPT
/sbin/iptables -I INPUT -m tcp -p tcp -s $Current_IP -j ACCEPT
iptables-persistent save
echo $Current_IP > $LOGFILE
echo iptables have been updated
fi
fi
我得到了这个错误
错误参数ACCEPT'Try
iptables-h'或'iptables--help'了解更多信息
信息。iptables已经更新
我也试过用这些
iptables -D INPUT -m tcp -p tcp -s $Last_IP -j ACCEPT
iptables -I INPUT -m tcp -p tcp -s $Current_IP -j ACCEPT
但还是同样的错误
是否仍要修复此问题?是否确定
$Last\u IP
变量中没有任何换行符?
能否尝试在iptables-D..
行之前添加以下内容
Last_IP=$(echo $Last_IP|tr -d '\n')
您可以尝试运行您的脚本,但如果问题出在
iptables
(似乎很可能),superuser.com是解决此问题的更好网站。感谢您提供的有用信息