If you want to allow a full subnet you have to specify the subnet as source.
Also, if you want to allow any services you should remove -p tcp
because it just allows TCP protocol.
Then, you will need to drop unwanted traffic.
iptables -A INPUT -s 10.168.1.0/24 -j ACCEPT
iptables -P INPUT DROP
You certainly don't need the OUTPUT
chain if you setup iptables to be stateful.
In that case, the rules will be :
iptables -A INPUT -s 10.168.1.0/24 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -P INPUT DROP
If, for some reason, the server has to initiate connexions to subnet hosts, the use of OUTPUT
chain is needed, but the source ip -s
should be your server IP address (but can also be omitted), and you can specify the destination to only allow the given subnet :
iptables -A OUTPUT -s serverip -d 10.168.1.0/24 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
# or
iptables -A OUTPUT -d 10.168.1.0/24 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
# in both cases
iptables -P OUTPUT DROP