一、firewall

  1. 查看firewall状态

    firewall-cmd --state

    防火墙开启:

    防火墙关闭:

  2. 如果firewall为关闭状态,先启动firewall

    systemctl start firewalld

  3. 添加firewall指令

    firewall-cmd --permanent --add-rich-rule='rule family=ipv4 forward-port port=162 protocol=udp to-port=20162'
    firewall-cmd --permanent --add-rich-rule='rule family=ipv4 forward-port port=161 protocol=udp to-port=20161'
    firewall-cmd --permanent --add-rich-rule='rule family=ipv4 forward-port port=514 protocol=udp to-port=20514'
    firewall-cmd --permanent --zone=public --add-port=8885/tcp
    firewall-cmd --permanent --zone=public --add-port=9092/tcp
    firewall-cmd --permanent --zone=public --add-port=161/tcp
    firewall-cmd --permanent --zone=public --add-port=162/tcp
    firewall-cmd --permanent --zone=public --add-port=514/udp
    firewall-cmd --permanent --zone=public --add-port=20161/tcp
    firewall-cmd --permanent --zone=public --add-port=20162/tcp
    firewall-cmd --permanent --zone=public --add-port=20514/udp
    firewall-cmd --permanent --zone=public --add-port=9996/udp
    firewall-cmd --permanent --zone=public --add-port=8082/tcp

  4. 重新加载firewall策略
    firewall-cmd --reload
  5. 查看新策略是否生效
    firewall-cmd --list-all

二、Iptables

  1. 安装iptables
    yum install iptables-services
  2. 启动iptables
    service iptables restart
  3. 查看iptables状态
    systemctl status firewalld.service
    启动状态:

    关闭状态:

  4. 添加iptables端口转发策略

    iptables -t nat -A PREROUTING -p udp -m udp --dport 162 -j REDIRECT --to-ports 20162

    iptables -t nat -A PREROUTING -p udp -m udp --dport 161 -j REDIRECT --to-ports 20161

    iptables -t nat -A PREROUTING -p udp -m udp --dport 514 -j REDIRECT --to-ports 20514

  5. 查看新策略是否生效
    iptables -t nat -L -n --line-numbers
  6. 删除规则
    iptables -L -n --line-numbers

firewall&iptables小记的更多相关文章

  1. firewall&iptables

    一.firewall 查看firewall状态 firewall-cmd --state 如果firewall为关闭状态,先启动firewall systemctl start firewalld 添 ...

  2. 防火墙 firewall iptables

    firewalld FirewallD 使用服务service 和区域zone来代替 iptables 的规则rule和链chain,默认情况下,有以下的区域zone可用: drop – 丢弃所有传入 ...

  3. [Firewall] iptables Configuration

    iptables usage: Add Rules: iptables -I INPUT -p tcp --dport -j ACCEPT iptables -I INPUT -p tcp --dpo ...

  4. Neutron 理解 (9): OpenStack 是如何实现 Neutron 网络 和 Nova虚机 防火墙的 [How Nova Implements Security Group and How Neutron Implements Virtual Firewall]

    学习 Neutron 系列文章: (1)Neutron 所实现的虚拟化网络 (2)Neutron OpenvSwitch + VLAN 虚拟网络 (3)Neutron OpenvSwitch + GR ...

  5. iptables rule

    和H3C中的acl很像,或者就是一会事,这就是不知道底层的缺陷,形式一变,所有的积累都浮云了 参考准确的说copy from http://www.ibm.com/developerworks/cn/ ...

  6. Linux: 20 Iptables Examples For New SysAdmins

    Linux comes with a host based firewall called Netfilter. According to the official project site: net ...

  7. [转] XEN, KVM, Libvirt and IPTables

    http://cooker.techsnail.com/index.php/XEN,_KVM,_Libvirt_and_IPTables XEN, KVM, Libvirt and IPTables ...

  8. Iptables 指南 1.1.19

    Iptables 指南 1.1.19 Oskar Andreasson oan@frozentux.net Copyright © 2001-2003 by Oskar Andreasson 本文在符 ...

  9. ubuntu 中 iptables 和 ufw 的关系

    我突然发现,自己平常使用的 iptables 和 ufw 到底是啥关系?平常其实iptables和ufw在配置防火墙,开启端口是,还是偶尔会使用到的. 没去思考过这两者是啥关系,哎...,这就不够好了 ...

随机推荐

  1. WIN10无法识别安卓设备,提示Windows 无法验证此设备所需的驱动程序的数字签名

    在设备管理器,显示ANDROID设备是感叹号, 不管更新驱动,还是下载什么手机助手自动安装驱动,均不可解. 从属性中查看提示的是“Windows 无法验证此设备所需的驱动程序的数字签名”, 解决办法: ...

  2. nodejs 程序(有的功能和前端js是不一样的)

    node文档:http://nodejs.cn/api/ 1.控制台输出 (node的输出是在命令框中输出的): 有颜色的输出 :console.log('\x1B[33m%s\x1b[0m:', p ...

  3. (转载)虚拟机出现无法连接虚拟设备sata0:0,因为主机上没有相应设备

    虚拟主机需要镜像文件, 如果是拷贝的虚拟机,还需要桥接联网的话,更改mac地址,

  4. 用maven搭建多模块项目

    首先,前面几次学习已经学会了安装maven,如何创建maven项目等,最近的学习,终于有点进展了,搭建一下企业级多模块项目. 好了,废话不多说,具体如下: 首先新建一个maven项目,pom.xml的 ...

  5. 请教怎么查询ORACLE的历史操作记录!

    请问如何查询ORACLE的历史操作记录!!!!!我用的是linux oracle 11g r2,想查一下前几天的数据库的历史操作记录,例如对表的insert,delete,update等等的操作记录, ...

  6. codeforces 584E Anton and Ira [想法题]

    题意简述: 给定一个$1$到$n(n<=2000)$的初始排列以及最终排列 我们每次可以选取位置为$i$和$j$的 并交换它们的位置 花费为$ |i-j| $ 求从初始状态变换到末状态所需最小花 ...

  7. JetBrains.dotPeek

    Free .NET Decompiler and Assembly Browser Decompile .NET assemblies to C# dotPeek is a free-of-charg ...

  8. idhttp提交post

    var Param:TStringList; RStream:TMemoryStream;begin Param:=TStringList.Create; RStream:=TMemoryStream ...

  9. USACO 5.5 章节

    Picture 题目大意 IOI 1998 求n (<=5000)个矩形 覆盖的图形 的周长(包括洞), 坐标范围[-10000,10000] 题解 一眼离散化+2维线段树,但仔细一想 空间不太 ...

  10. Android深度探索-卷1第一章心得体会

     本章介绍了安卓系统移植与驱动开发的概述,安卓的系统架构有四层:1 Linux内核,2 c/c++代码库, 3 Android SDK API, 4 应用程序 在读的过程中看到了专业名词,查了查,长点 ...