I have a Linux PC which is behind 3 routers, of which 3rd one is internet gateway. This PC is running a software which listens on a TCP socket. Port is forwarded on all 3 routers to connect the software running on the PC from outside world. Is it possible to block all network traffic except connection from a couple of WAN IPs using iptables command? (Basically whitelisting the IP of remote PC's internet IP).
Somone suggested that I can use commands given below.
#Flush existing rules iptables -F # Set up default DROP rule for eth0 iptables -P INPUT DROP # Allow connections from WAN iptables -A INPUT -o eth0 -d <WAN IP1> -j ACCEPT iptables -A INPUT -o eth0 -d <WAN IP2> -j ACCEPT
If the above approach is correct, is it safe from hackers?