0

I have a CentOS terminal working as a router with APF installed.

Also 1 terminal with 3 NICs (3 IPs) is using that router as a Gateway to access the internet.

What I want is APF to block SSH access, on the 2 of 3 NICs (IPs). So in result, SSH is only accessible for a specific IP and not all three.

How can I achieve that directly on the router with APF or iptables?

What I have tried: iptables -A INPUT -s xxx.xxx.xxx.xxx -p tcp --destination-port 22 -j DROP

2
  • 2
    What research have you done on this on your own - iptables examples and guides are not exactly difficult to find online, and the commands you'll need to run are quite simple.
    – EEAA
    Mar 14, 2014 at 22:25
  • I have tried: iptables -A INPUT -s xxx.xxx.xxx.xxx -p tcp --destination-port 22 -j DROP but it is not working . I want to do this on the router than configuring port access to each subnet terminal.
    – mallix
    Mar 15, 2014 at 10:49

2 Answers 2

1
iptables -A FORWARD -i <banned_interface> -d DESTINATION.IP -p tcp --dport 22 -j DROP
iptables -A FORWARD -i <banned_interface2> -d DESTINATION.IP -p tcp --dport 22 -j DROP

you could of course change the policy in the table to DROP by using iptables -P FORWARD DROP and specify just the allowed entries but if you mess something up you'll be locked-out or forwarding would just not work.

0
iptables -A FORWARD -p tcp --dport 22 -d xxx.xxx.xxx.xxx -j DROP

That did it. An easy one but I am new with iptables.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .