Author Topic: How to: Allow telnet and ssh through iptables under Linux  (Read 8451 times)

Offline admin

  • Administrator
  • Sr. Member
  • *****
  • Posts: 296
    • View Profile
How to: Allow telnet and ssh through iptables under Linux
« on: April 02, 2011, 01:26:35 AM »
How to: Allow telnet and ssh through iptables under Linux

Q. I run both RHEL / CentOS Linux server and by default firewall blocked out everything including telnet / ssh access. How do I allow telnet - port 23 and ssh port 22 thought Linux iptables firewall ?

A.By default firewall rules stored at /etc/sysconfig/iptables location / file under CentOS / RHEL. All you have to do is modify this file to add rules to open port 22 or 23.

Login as the root user.

Open /etc/sysconfig/iptables file, enter:
Code: [Select]
# vi /etc/sysconfig/iptablesFind line that read as follows:
Code: [Select]
COMMITTo open port 22 (ssh), enter (before COMMIT line):

Code: [Select]
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPTTo open port 23 (telnet), enter (before COMMIT line):

Code: [Select]
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 23 -j ACCEPTSave and close the file. Restart the firewall:
Code: [Select]
# /etc/init.d/iptables restart