Hosts file syntax when want to deny multiple IP subnets or partial hostnames?




i would like to use /etc/hosts.deny / hosts.allow

to block all connections except connections from two IP subnets and one hostname (partial match).

these i want to allow:

.tmc is a part of the hostname

So far i found this to add into hosts.deny:

sockd : ALL EXCEPT

but i need to add two more allow rules..

Can i do:

sockd : ALL EXCEPT /etc/hosts.allow

and into /etc/hosts.allow add:

i assume *.tmc* is wrong syntax

I assume my hosts file syntax is wrong as i tried to disable ssh port 1234 connections but they are still there :(

# echo "" && echo "Number of connections per port" && netstat -tuna | awk -F':+| +' 'NR>2{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n | grep 1234 && echo "" && echo "Netstat port 1234:" && netstat -tlnp | grep 1234 && echo "" && echo "Hosts.deny and ssh contianing lines:" && cat /etc/hosts.deny|grep ssh

Number of connections per port
51 1234

Netstat port 1234:
tcp 0 0* LISTEN 1865/ssh

Hosts.deny and ssh contianing lines:
ssh : ALL EXCEPT /etc/hosts.allow2

Members online