iptables与firewall的配置:
说明:
(1)如果不使用iptables与firewall可以将它们关闭,关闭的命令如下:
[root@ceshiji ~]# iptables -F
[root@ceshiji ~]# /etc/init.d/iptables stop
[root@rhel7 ~]# systemctl stop firewalld
[root@rhel7 ~]# systemctl disable firewalld
(2)Linux7中不再有iptables,使用firewalld;在Linux7中安装并使用iptables的方法如下:
[root@rhel7 ~]# yum install -y iptables-services
开启iptables服务:
[root@rhel7 ~]# systemctl start iptables
查看iptables服务运行状态:
[root@rhel7 ~]# systemctl status iptables
开机自启动iptables服务:
[root@rhel7 ~]# systemctl enable iptables
使用iptables:
[root@rhel7 ~]# vim /etc/sysconfig/iptables
加入如下行“-A INPUT -p tcp -m state --state NEW --dport 23 -j ACCEPT”
说明:上面只是演示下linux7中iptables安装和使用,实际工作中在linux7中,我们使用的是firewall!
(3)开启iptables和firewall,让telnet的默认端口23可以通过防火墙和路由器。
在Linux 6系统中:
[root@ceshiji ~]# vim /etc/sysconfig/iptables
加入如下行“-A INPUT -p tcp -m state --state NEW --dport 23 -j ACCEPT”
保存退出!重启iptables服务。
[root@ceshiji ~]# service iptables restart
在Linux 7系统中:
[root@rhel7 ~]# firewall-cmd --permanent --add-port=23/tcp
[root@rhel7 ~]# firewall-cmd --reload