一、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. MongoDB笔记【2】——基本概念和基本指令

    - 基本概念 数据库(database) 集合(collection) 文档(document) - 在MongoDB中,数据库和集合都不需要手动创建,当我们创建文档时,如果文档所在的集合或数据库不存 ...

  2. DOS基础使用专题(强烈推荐)2

    DOS下硬件设备的使用与设置 由于电脑的普及和应用的日益深入,为了满足人们的需要,电脑的功能随着它的发展变得越来越强大,硬件设备也越来越多,如从原来的ISA及PCI声卡.调制解调器等到现在的USB硬盘 ...

  3. VS中C语言scanf函数报错

    在VS中创建C项目使用scanf方法时会如下报错 解决方案 方法1:文件中设置 在第一行设置代码    #define _CRT_SECURE_NO_WARNINGS 或者添加警告忽略     #pr ...

  4. JDK 与 JRE

    JDK就是Java Development Kit.简单的说JDK是面向开发人员使用的SDK,它提供了Java的开发环境和运行环境.SDK是Software Development Kit 一般指软件 ...

  5. GET and POST

    有待补充:

  6. Python 与 C 对比

    到目前为止,我接触最多两种语言应该就是python 和 C 语言了. 个人理解 1. 执行速度不同, python为解释性语言,C是编译型语言(需要编译器) 2. python 是基于C的实现,C中很 ...

  7. python 装饰器 对类和函数的装饰

    #装饰器:对类或者函数进行功能的扩展  很多需要缩进的没有进行缩进'''#第一步:基本函数def laxi(): print('拉屎')#调用函数laxi()laxi() print('======= ...

  8. 一步一步学Vue(九) 路由元数据

    一步一步学Vue(九):https://www.cnblogs.com/Johnzhang/p/7260888.html

  9. Rikka with Nickname (简单题)

    Rikka with Nickname  链接:https://www.nowcoder.com/acm/contest/148/J来源:牛客网 时间限制:C/C++ 2秒,其他语言4秒空间限制:C/ ...

  10. 分布式ID的雪花算法及坑

    分布式ID生成是目前系统的常见刚需,其中以Twitter的雪花算法(Snowflake)比较知名,有Java等各种语言的版本及各种改进版本,能生成满足分布式ID,返回ID为Long长整数 但是这里有一 ...