一、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. Testng报错:method-selectors?,parameter*,groups?,packages?,classes?

    以上的报错信息有两种可能的原因: 1.xml的格式确实有误 2.xml的格式正确,但是工程中testng的jar包不止一个,从而导致有歧义或者冲突(这个很可能发生在同一个workspace有多个工程的 ...

  2. struts2---访问WEB

    一:在Action中,可以通过以下方式访问WEB的HttpSession,HttpServletRequest,HttpServletResponse等资源 与Servlet API解耦的访问方式 通 ...

  3. [CSP-S模拟测试]:字符消除2(hash+KMP)

    题目背景 生牛哥终于打通了“字符消除”,可是他又被它的续集难倒了. 题目传送门(内部题52) 输入格式 第一行$n$表示数据组书.接下来每行一个字符串.(只包含大写字母) 输出格式 每组数据输出一个$ ...

  4. python,mock-server之moco

    python,mock-server之moco1.mock使用:mock除了用在单元测试过程中,还有一个用途,当前端开发在开发页面的时候,需要服务端提供API接口,此时服务端没开发完成,或者说没搭建测 ...

  5. Python Django 编写一个简易的后台管理工具3-运行项目

    编写view页面 def hello(request): return render(request,'hello.html') 编写html页面 <!DOCTYPE html> < ...

  6. asp.net mvc 特性路由(MapMvcAttributeRoutes)的应用

    版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/u012835032/article/details/51160824asp.net mvc 特性路由 ...

  7. js比较日期时间的大小

    var myDate = new Date(); var timed = myDate.toLocaleDateString(); var oDate1 = new Date(item.express ...

  8. C语言|博客作业6

    一.本周教学内容&目标 第3章 分支结构 3.1-3.2 使学生熟悉多分支结构.字符型数据类型和逻辑运算符. 二.本周作业头 问题 答案 这个作业属于那个课程 C语言程序设计II 这个作业要求 ...

  9. sublime text 3安装Anaconda插件之后写python出现白框

    sublime test 3安装anaconda插件之后写python代码会出现白框,这是应为anaconda自带了pep8语法检查, 有一些是语法错误,能够检查出来还是能有用的.但有一些不过是一些代 ...

  10. leetcode-7-整数翻转

    问题: package com.example.demo; public class Test7 { /** * 整数翻转 123,-123,120等数字 * 思路: * 1.获取原始数字的%10的余 ...