Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- mc_port=25565
- regex="^([[:digit:]\.]+):[[:digit:]]+$"
- ips=()
- while read -r line ; do
- if [[ $line =~ $regex ]] ; then
- ips+=(${BASH_REMATCH[1]})
- fi
- done < <(netstat -n --protocol inet | grep ':22022' | awk '{print $5}')
- #flush existing rules
- /sbin/iptables -F
- for i in "${!ips[@]}" ; do
- #allow connection for ip ${ips[$i]}
- /sbin/iptables -A INPUT -p tcp --destination-port $mc_port -s ${ips[$i]} -j ACCEPT
- done
- #disallow all other connections
- /sbin/iptables -A INPUT -p tcp --destination-port $mc_port -j DROP
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement