I have spent all day looking this up with no luck.So, I own the IP range xxx.xxx.xxx.xxx/27 and I want to open port 22 on IP xxx.xxx.xxx.66 yet close port 22 on all others, then open port 80/443/4567 on IP xxx.xxx.xxx.90 and finally open port 25565 on ports xxx.xxx.xxx.(70|80).This is what I have tried so far:# Generated by iptables-save v1.4.7 on Mon Sep 14 07:23:06 2015*filter:INPUT ACCEPT [4:240]:FORWARD ACCEPT [0:0]:OUTPUT ACCEPT [31:3004]-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT # Allow HTTP/HTTPS connections from anywhere (normal ports for websites and SSL)-A INPUT -s xxx.xxx.xxx.90 -p tcp --dport 80 -j ACCEPT-A OUTPUT -d xxx.xxx.xxx.90 -p tcp --dport 80 -j ACCEPT-A INPUT -s xxx.xxx.xxx.90 -p tcp --dport 443 -j ACCEPT-A OUTPUT -d xxx.xxx.xxx.90 -p tcp --dport 443 -j ACCEPT# Lets allow some TS3 server ports, they'll be running on xxx.xxx.xxx.89-A INPUT -p tcp --dport 10011 -j ACCEPT-A OUTPUT -p tcp --dport 10011 -j ACCEPT-A INPUT -p tcp --dport 30033 -j ACCEPT -A OUTPUT -p tcp --dport 30033 -j ACCEPT -A INPUT -p udp --dport 9987 -j ACCEPT -A OUTPUT -p udp --dport 9987 -j ACCEPT # Lets allow NodeBB to use this machine..# Well run it on 45.35.58.66 as no one **should** be finding out this IP.-A INPUT -s xxx.xxx.xxx.66 -p tcp --dport 4567 -j ACCEPT -A OUTPUT -d xxx.xxx.xxx.66 -p tcp --dport 4567 -j ACCEPT # We're going to block icmp on all other IPs, but all it on our main IP.-A INPUT -s 45.35.58.66 -p icmp -j ACCEPT -A INPUT -p icmp -j REJECT # Drop all other inbound - default deny unless explicitly allowed policy-A INPUT -j DROP-A FORWARD -j DROPCOMMITAll help is appreciated.
Open port on one IP
iptables
IptablesYou can use iptables using the following syntaxiptables -A INPUT -s [source IP] -p [protocol] --dport [destination port] -j [ACTION]You need to ACCEPT the connection from the specific IP and then DROP it to all traffic.E.g.$ sudo iptables -A INPUT -s XXX.XXXX.XXX.66 -p tcp --dport 22 -j ACCEPT$ sudo iptables -A INPUT -p tcp --dport 22 -j DROPTo get familiarized with iptables you can give a look in here