linux防火墙+端口查看设置


防火墙
 1 firewalld.server  一般是linux系统自带的系统服务,
     /usr/lib/systemd/system/
   在/usr/lib/systemd/system下的服务,可以使用systemctl指令去操作
 
 2 iptables 服务一般是需要自己手动安装
 
 上面两种都是启到防火墙的作用,一般而言,二者是平级的,对于firewall调用了iptable service,
 他们都需要调用linux内核
 
 3 系统服务的操作指令 systemctl ,该指令兼容了service和chkconfig的功能于一体。  
   对于安装的系统服务,我们之前使用service指令进行启停服务,现在完全可以使用systemctl操作
   
   
 4 实例
   4.1 对于sshd服务使用service启动和使用chkconfig配置开机启动,需要使用两个指令分别操作
    # 启动sshd服务
    service sshd start
    # 设置sshd服务开机启动
    chkconfig sshd start
   
  
   4.2 systemctl融合了上面两者的指令
   systemctl start sshd.service   //启动sshd服务
   systemctl enable sshd.service   //设置开机自动启动
   
   
 5 查看防火墙服务
   
   5.1  使用service启动系统服务
   # 查看状态   显示是否激活
   $ service firewall status
   # 开启firewall服务
   $ service firewall start
   # 关闭服务
   $ service firewall stop
   # 重启服务
   $ service firewall reload
   
   chkconfig firewall start  //开记启动
   chkconfig firewall stop  //禁止开机启动
   
    
   
   5.2 使用systemctl操作系统服务
   # 查看状态 
   $ systemctl status firewalld.service
   $ systemctl start  firewalld.service
   $ systemctl reload firewalld.service
   $ systemctl stop   firewalld.service
   # 配置是否开机启动
   $ systemctl enable firewalld.service   //开机启动
   $ systemctl disable firewalld.service  //禁止开启启动
 

   
   $ yum
查看端口
  # 指定端口,查看被那个应用占用
  $ lsof -i:<port>
  
  使用 netstat命令各个参数说明如下:

  -t : 指明显示TCP端口

  -u : 指明显示UDP端口

  -l : 仅显示监听套接字(所谓套接字就是使应用程序能够读写与收发通讯协议(protocol)与资料的程序)

  -p : 显示进程标识符和程序名称,每一个套接字/端口都属于一个程序。

  -n : 不进行DNS轮询,显示IP(可以加速操作)
  
   $ netstat -tunpl | grep <port>

  • 3
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值