/etc/init.d/iptables status       #查看防火墙信息

[root@localhost mysql]# /etc/init.d/iptables status
Table: filter
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination
1    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED
2    ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0
3    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0
4    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22
5    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited Chain FORWARD (policy ACCEPT)
num  target     prot opt source               destination
1    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination       

vim /etc/sysconfig/iptables

yy 复制   -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT

p  粘贴

[root@localhost mysql]# vim /etc/sysconfig/iptables
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A INPUT -m state --state NEW -m tcp -p tcp --dport 21 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8081 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

u  撤销

: wq  保存退出

  • 重启防火墙使改动生效
[root@localhost mysql]# /etc/init.d/iptables restart
iptables: Setting chains to policy ACCEPT: filter [  OK  ]
iptables: Flushing firewall rules: [  OK  ]
iptables: Unloading modules: [  OK  ]
iptables: Applying firewall rules: [  OK  ]
  • 关闭防火墙
  • [root@localhost liufuwen]# service iptables stop
Usage: iptables {start|stop|reload|restart|condrestart|status|panic|save}
[root@localhost mysql]# /etc/init.d/iptables stop
iptables: Setting chains to policy ACCEPT: filter [  OK  ]
iptables: Flushing firewall rules: [  OK  ]
iptables: Unloading modules: [  OK  ]

永久关闭防火墙

[root@localhost liufuwen]# chkconfig iptables off

永久关闭后启用

[root@localhost liufuwen]# chkconfig iptables on

CentOS6.5 开启防火墙iptables端口,如3306,8080相关推荐

  1. ubuntu/linux服务器 使用ufw iptables 开启防火墙和端口

    一.ufw 1.查看本地的防火墙/端口开启情况 sudo ufw status 2.开启防火墙 sudo ufw enable 3.打开端口 sudo ufw allow 端口 4.防火墙重启(ubu ...

  2. centos开启防火墙指定端口

    sudo /sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT

  3. LINUX服务器开启防火墙并屏蔽恶意IP

    如果有恶意IP不断访问服务器,那么将有可能导致服务器CPU等资源用尽,解决办法是开启防火墙IPTABLES并将该恶意IP屏蔽. 方法如下: 开启防火墙: #chkconfig iptables on ...

  4. linux设置mysql防火墙端口映射_Linux防火墙默认是关闭3306端口,iptables实现端口转发、端口映射及双向通路...

    iptables实现端口转发.端口映射及双向通路其实不难配置,看下文: 允许数据包转发: #echo 1 > /proc/sys/net/ipv4/ip_forward 转发TCP 8081到x ...

  5. CentOS6.7防火墙(Iptables)的开启与关闭

    Linux防火墙(iptables)的开启与关闭 . Linux中的防火墙主要是对iptables的设置和管理. 1. Linux防火墙(Iptables)重启系统生效 开启: chkconfig i ...

  6. firewalld/iptables防火墙维护和状态查询命令(防火墙重载,区域操作命令,开启服务或端口,堵塞端口,iptables规则添加和删除)

    文章目录 firewalld防火墙维护和状态查询命令 firewalld防火墙状态查询命令 firewalld防火墙重载配置命令 重新加载firewalld的配置 查询预定义信息命令 firewall ...

  7. 配置防火墙,开启80端口、3306端口

    通过下面这个方式可以查看是否连通服务器, ping 10.252.130.73 如果可以正常连通,那么查看3306接口是否能通: telnet 10.252.130.73 3306 如果连通不了,那就 ...

  8. 在iptables防火墙下开启vsftpd的端口

    来源:Linux社区  作者:tongcheng [字体:大 中 小] 在开启vsftpd端口后发现用客户端工具能登陆,但无法浏览文件和新建文件.此时看了一下ftp的协议,发现ftp有主动模式和被动模 ...

  9. centos6 防火墙iptables操作整理

    使用语句 前言:  iptables的启动文件位置再:  /etc/init.d/iptables , srevice iptables调用的就是这里的执行文件 查看防火墙状态   service i ...

  10. 防火墙开放21端口linux,linux防火墙开放80,3306,21,443端口

    大家都知道服务器里的一些端口和防火墙之类的,在使用过程中能够起到很重要的作用,这里整理了一些关于配置防火墙,开启80端口.3306端口 vi /etc/sysconfig/iptables -A IN ...

最新文章

  1. LeetCode实战:环形链表
  2. 【学术相关】毕业论文速成指南来了!
  3. [vue] vue父子组件双向绑定的方法有哪些?
  4. CPU又烧了,说起来汝可能不信
  5. 坐标转换工具类:84坐标系,火星坐标系,与百度坐标系之间的互相转换
  6. excel 无法求和
  7. idea local history说明
  8. Docker编译安装httpd
  9. 【题解】284E. Coin Troubles(dp+图论建模)
  10. 【Linux】Ubuntu16.04使用拾遗2
  11. DMCTF writeup
  12. 将数组倒置java_java数组元素倒置
  13. 虚拟化 oracle rac,数据库虚拟化之战:VM与Oracle RAC
  14. 主机电源全是黑线怎么短接_电脑电源故障 绿线和黑线短接后风扇转一下就停了。...
  15. Shell- 获取ESXI主机虚拟交换机中MAC表
  16. 经常用的命令一(linux)
  17. 追MM与Java的23种设计模式(转)_三木_新浪博客
  18. 中国诗歌艺术之人文之魂1,2(四川大学文学与新闻学院王红)
  19. java.lang.UnsupportedOperationException解决方法【转】
  20. 降低node/npm 到指定版本(Mac)详细教程

热门文章

  1. 程序员面试:未来五年的规划是怎样的?
  2. ZigBee中协调器如何向子节点发消息?
  3. 清除Chrome的缓存、Cookie
  4. android 像素密度,屏幕密度,values-sw480dp
  5. 日常一记(7)--excel合并两列数据并删除重复项
  6. 二叉树求解前序序列、中序序列、后序序列
  7. 拉卡拉服务器响应超时,拉卡拉传统POS机11个常见问题及解决方法
  8. 忘记MySQL密码如何重置再到重新设置密码
  9. 对硬盘进行分区时,GPT和MBR有什么区别?
  10. 苹果怎么信任企业级开发者_苹果企业签名是什么意思?