How to Allow All Traffic for Specific Port or IP (Linux VPS or Server)

Block all traffic incoming to your server with -d / –dport (destination port)

iptables -I FORWARD -p tcp -d 101.102.103.4 –dport 25 -j DROP;

The result will look like this in iptables:

[screenshot of the Source .. Destination .. Protocol info colums]

Run iptables-save to save this configuration if/when iptables is reloaded.

Block all traffic outgoing from your server with -s / –sport (sending port)

iptables -I FORWARD -p tcp -s 101.102.103.4 –sport 25 -j DROP

Do it for an entire IP range/subnet/network [keywords]

iptables -I FORWARD -p tcp -s 101.102.103.0/24 –sport 25 -j DROP

logo

Lightning-fast VPS hosting with enterprise SSD storage, global data centers, and 99.99% uptime. Built for developers, trusted by enterprises.

Get Help

support@solvps.com

1-888-256-8213

Live Chat Now

© 2025 Hostway Services, Inc. dba SolVPS. All trademarks, service marks, product names, and logos appearing on this website are the property of their respective owners.