Quote:
Originally Posted by secrets88
For example I have 10 servers and wanted to do a configuration (at the iptables) for a single server, but this configuration should be taken into account by other servers.
|
When you run iptables on one server, it only affects this one server. You will have to run iptables on each of the other servers as well.
Quote:
SERVER="192.168.22.190"
for ROUTER in 171.135.1.23;
do
iptables -A INPUT -m state --state NEW -m tcp -s $SERVER -p tcp --match multiport --dports 22,8080 -j ACCEPT
done
|
This code opens ports 22 and 8080 for packets from 192.168.22.190. I don't understand the purpose of the
for loop - it does effectively nothing, and the ROUTER variable is not used at all. The semicolon is superfluous as well.
In other words, your code is 100% equivalent to
Code:
SERVER="192.168.22.190"
iptables -A INPUT -m state --state NEW -m tcp -s $SERVER -p tcp --match multiport --dports 22,8080 -j ACCEPT
If you want to open these ports on all your servers, perhaps something like this will be the solution:
Code:
for SERVER in <list of all your IP addresses or server hostnames>
do
ssh $SERVER iptables -A INPUT -m state --state NEW -m tcp -s 192.168.22.190 -p tcp --match multiport --dports 22,8080 -j ACCEPT
done