小编Gok*_*kul的帖子

iptables 允许传入的 FTP

我想允许传入的 FTP 流量。

CentOS 5.4:

这是我的/etc/sysconfig/iptables文件。

# Generated by iptables-save v1.3.5 on Thu Oct  3 21:23:07 2013
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [133:14837]
-A INPUT -p tcp -m tcp --dport 21 -j ACCEPT
-A INPUT -p tcp -m state --state ESTABLISHED -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-port-unreachable
-A OUTPUT -p tcp -m tcp --sport 20 -j ACCEPT
COMMIT
# Completed on Thu Oct  3 21:23:07 2013
Run Code Online (Sandbox Code Playgroud)

此外,默认情况下, ip_conntrack_netbios_n 模块正在加载。

#service iptables restart …
Run Code Online (Sandbox Code Playgroud)

ftp iptables file-transfer vsftpd

36
推荐指数
4
解决办法
20万
查看次数

ssh 和运行命令的脚本不起作用

下面是脚本。

我想登录几台服务器并检查内核版本。

#!/bin/bash
#input server names line by line in server.txt
cat server.txt | while read line
do
sshpass -p password ssh root@$line << EOF
hostname
uname -r
EOF
done
Run Code Online (Sandbox Code Playgroud)

我希望输出像..

server1_hostname
kernel_version
server2_hostname
kernel_version
Run Code Online (Sandbox Code Playgroud)

等等..

我在 server.txt 中用大约 80 个服务器运行了这个脚本

我得到的输出就像......

Pseudo-terminal will not be allocated because stdin is not a terminal. 
Pseudo-terminal will not be allocated because stdin is not a terminal.
Pseudo-terminal will not be allocated because stdin is not a terminal.
Pseudo-terminal will not be allocated …
Run Code Online (Sandbox Code Playgroud)

bash ssh shell-script

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

iptables 规则只允许一个端口并阻止其他端口

我们有两个应用程序在运行(在 linux 之上)并且都通过端口 42605 进行通信。我想快速验证这是否是用于它们之间通信的唯一端口。我尝试了以下规则,但似乎不起作用。所以,只是想澄清一下,如果我做错了。

以下是我运行的命令序列

iptables -I INPUT -j REJECT
iptables -I INPUT -p tcp --dport 42605 -j ACCEPT
iptables -I INPUT -p icmp -j ACCEPT
iptables -I OUTPUT -p tcp --dport 42605 -j ACCEPT
Run Code Online (Sandbox Code Playgroud)

因此,由于我正在插入它,因此它将以相反的顺序添加。

我想允许来自和到 42605 的传入和传出通信。上述规则看起来不错还是我做错了?

另一个问题,这是否是测试的正确方法,或者我应该使用“netstat”命令来查看哪个端口与另一个 ip 建立了连接?

firewall iptables centos netstat

4
推荐指数
1
解决办法
1万
查看次数

Bash shell 脚本关于语法和基本名称的基本问题

考虑下面的脚本:

myname=`basename $0`;
for i in `ls -A`
do
 if [ $i = $myname ]
 then
  echo "Sorry i won't rename myself"
 else
  newname=`echo $i |tr a-z A-Z`
  mv $i $newname
 fi
done
Run Code Online (Sandbox Code Playgroud)

1) 我知道basename $0这里表示我的脚本名称。但是如何?请语法解释。什么$0意思?

2)在什么情况下“;” 在脚本中的语句末尾使用?例如,脚本的第一行以 ; 结尾。,而第 8 行没有。此外,我发现在某些行的末尾添加/删除分号(例如:第 1 行/第 6 行/第 8 行)并没有任何意义,无论有没有它,脚本都可以正常运行。

scripting bash shell-script basename

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

我如何将 tailf 和 grep 的输出重定向到文件

我想要的只是对正在进行的日志中的特定行进行 grep 并将其重定向到某个文件。

tailf log | grep "some words"
Run Code Online (Sandbox Code Playgroud)

现在,我希望上面的命令输出持续重定向到某个文件....

我试过,

tailf log | grep "some words" >> file
Run Code Online (Sandbox Code Playgroud)

但这似乎不起作用。我错过了什么?

grep bash tail output

2
推荐指数
1
解决办法
8647
查看次数

无法通过 git clone 命令更新 git

我正在阅读git 文档并使用源代码包安装 Git。现在,安装 Git 后,我​​想更新它(虽然此时可能没有必要,但我只想尝试确保它有效)。我运行了命令git clone git://git.kernel.org/pub/scm/git/git.git,它返回了 error -bash: /usr/bin/git: No such file or directory。原因可能很明显,因为为了安装 git,我使用了make prefix=/usr/local install安装 Git的命令/usr/local/bin/git

现在,如何解决这个问题?

我尝试使用相同的 git clone 命令--git-dir=/usr/local/bin/git返回相同的错误-bash: /usr/bin/git: No such file or directory

git software-installation

1
推荐指数
1
解决办法
229
查看次数