How To: Whitelist An IP Address In IPTables


Most Linux distributions will use IPTables as the default firewall.

Here are the commands to whitelist an IP address on your Linux server, both incoming and outgoing.

Example: How to whitelist IP address

Step 1: Log into the server via SSH.

Step 2: Allow incoming connections from

# iptables -A INPUT -s -j ACCEPT

Step 3: Allow outgoing connections to

# iptables -A OUTPUT -d -j ACCEPT


Additional Options:

You can specify the destination port using the --dport option.

You can specify the protocol using the -p option

You can specify the interface using the -i option for input, and the -o option for output


# iptables -A INPUT -s -p tcp --dport 80 -i eth0 -j ACCEPT

This will allow connections from source only on port 80, only on any IP address associated with
eth0, only using TCP protocol.

# iptables -A OUTPUT -d -p tcp --dport 443 -o eth0 -j ACCEPT

This will allow outgoing connections to destination IP using protocol TCP,
only on destination port 443, only from the interface eth0.

Have more questions? Submit a request