Install yum install iptables-services on Linux systems
Then Vi/etc/sysconfig/iptables
# generated by Iptables-save v1.4.7 on Sun Aug 28 12:14:02 2016
*filter
: INPUT ACCEPT [0:0]
: FORWARD ACCEPT [0:0]
: OUTPUT ACCEPT [0:0]
-N Whitelist
-A whitelist-s 8.8.8.8-j ACCEPT
-A whitelist-s x.x.x.x-j ACCEPT
-A whitelist-s x.x.x.x-j ACCEPT
-A whitelist-s x.x.x.x-j ACCEPT
-A whitelist-s x.x.x.x-j ACCEPT
-A whitelist-s x.x.x.x-j ACCEPT
-A input-m state--state related,established-j ACCEPT
-A input-p icmp-j ACCEPT
-A input-i lo-j ACCEPT
-A input-m state--state new-m tcp-p TCP--dport 22-j Whitelist
-A input-m state--state new-m tcp-p TCP--dport 80-j Whitelist
-A input-m state--state new-m tcp-p TCP--dport 443-j Whitelist
-A input-m state--state new-m tcp-p TCP--dport 25-j Whitelist
-A input-j REJECT--reject-with icmp-host-prohibited
-A forward-j REJECT--reject-with icmp-host-prohibited
COMMIT
Top is the list of IP lists of whitelist
Below are some ports that are open for the contents of the whitelist
Write the accept on the top.
Write the contents of the reject down below.
So the white list of IP can access our restricted ports and services, and not in the whitelist IP will be rejected.
-A input-m state--state new-m tcp-p TCP--dport 22-j Whitelist This is for the white list of ports open, that is, only white list of IP can access through this port.
-A input-m State--state new-m tcp-p TCP--dport 22-j This is all white open, that is, any machine can access through this port.