Knowledgebase
HOW TO: Whitelist An IP Address In IPTables
Posted by Asilah A. on 21 June 2022 10:38 AM

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 192.168.0.1

 

Step 1: Log into the server via SSH.

Step 2: Allow incoming connections from 192.168.0.1

# iptables -A INPUT -s 192.168.0.1 -j ACCEPT

Step 3: Allow outgoing connections to 192.168.0.1

# iptables -A OUTPUT -d 192.168.0.1 -j ACCEPT

 

Additional Options:

You can specify the destination port using the --dportoption.

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

 

i.e.

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

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

 

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

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

 

If you face any difficulties on the setup, please feel free to contact our support team by submitting a ticket on https://247livesupport.biz or emailing out support team at support@247livesupport.biz.

(0 vote(s))
Helpful
Not helpful

Comments (0)
Copyright © 1998 - 2021 Shinjiru International Inc. All Rights Reserved.