前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >华为防火墙和飞塔防火墙建立IPSec隧道,使两地局域网互通

华为防火墙和飞塔防火墙建立IPSec隧道,使两地局域网互通

作者头像
IT狂人日志
发布于 2022-05-18 09:42:00
发布于 2022-05-18 09:42:00
1.2K0
举报

以前写过总部与两个分支机构、三台华为防火墙配置ipsec,都是同一个品牌,相对来说配置比较简单。

今天这个案例,分支机构采用的是飞塔的防火墙,接入链路是电信的PPPOE拨号宽带,没有固定的公网IP;总部则是华为防火墙,有固定的公网IP。

一、客户需求

华为防火墙作为总部的企业网关,以模板方式与分支机构的飞塔防火墙建立IPSec隧道;由于分支机构的飞塔防火墙的出口公网地址不固定,因此,只能是分支主动发起协商建立IPSec隧道,总部不能主动发起协商。

IPSec配置参数规划如下图所示:

二、配置过程

1、华为防火墙的配置

华为防火墙采用模板方式的IPSec策略,不要求对端IP地址固定,且不管有多少分支,总部只需要配置1个IPSec策略,1个IKE对等体,配置较为简单;如果采用策略方式的IPSec策略,有N个分支,则总部需要配置N个IPSec策略,N个IKE对等体,配置较为复杂。

(1)配置接口,并将接口加入相应的安全区域。

配置口GE1/0/3接口,并将接口加入untrust安全区域。

[HUAWEI] interface GigabitEthernet 1/0/3

[HUAWEI-GigabitEthernet1/0/3] ip address 222.xx.xx.50 29

[HUAWEI-GigabitEthernet1/0/3] quit

[HUAWEI] firewall zone untrust

[HUAWEI-zone-untrust] add interface GigabitEthernet 1/0/3

[HUAWEI-zone-untrust] quit

配置GE1/0/5接口,并将接口加入trust安全区域。

[HUAWEI] interface GigabitEthernet 1/0/5

[HUAWEI-GigabitEthernet1/0/5] ip address 192.168.160.1 24

[HUAWEI-GigabitEthernet1/0/5] quit

[HUAWEI] firewall zone trust

[HUAWEI-zone-trust] add interface GigabitEthernet 1/0/5

[HUAWEI-zone-trust] quit

(2)配置安全策略。

配置untrust和trust之间的安全策略。

策略1:允许分支访问总部;策略2,允许总部访问分支。

[HUAWEI] security-policy

[HUAWEI-policy-security] rule name 1

[HUAWEI-policy-security-rule-1] source-zone untrust

[HUAWEI-policy-security-rule-1] destination-zone trust

[HUAWEI-policy-security-rule-1] source-address 192.168.60.0 24

[HUAWEI-policy-security-rule-1] destination-address 192.168.160.0 24

[HUAWEI-policy-security-rule-1] action permit

[HUAWEI-policy-security-rule-1] quit

[HUAWEI-policy-security] rule name 2

[HUAWEI-policy-security-rule-2] source-zone trust

[HUAWEI-policy-security-rule-2] destination-zone untrust

[HUAWEI-policy-security-rule-2] source-address 192.168.160.0 24

[HUAWEI-policy-security-rule-2] destination-address 192.168.60.0 24

[HUAWEI-policy-security-rule-2] action permit

[HUAWEI-policy-security-rule-2] quit

(3)配置local与untrust之间的安全策略。

策略3:允许华为防火墙发起IPSec隧道建立请求;策略4:允许华为防火墙接收IPSec隧道建立请求,源、目的IP地址为两端的出口公网地址。

[HUAWEI-policy-security] rule name 3

[HUAWEI-policy-security-rule-3] source-zone local

[HUAWEI-policy-security-rule-3] destination-zone untrust

[HUAWEI-policy-security-rule-3] source-address 222.xx.xx.50 29

[HUAWEI-policy-security-rule-3] action permit

[HUAWEI-policy-security-rule-3] quit

[HUAWEI-policy-security] rule name 4

[HUAWEI-policy-security-rule-4] source-zone untrust

[HUAWEI-policy-security-rule-4] destination-zone local

[HUAWEI-policy-security-rule-4]destination-address 222.xx.xx.50 29

[HUAWEI-policy-security-rule-4] action permit

[HUAWEI-policy-security-rule-4] quit

(4)配置路由

配置连接到Internet的缺省路由

[HUAWEI] ip route-static 0.0.0.0 0.0.0.0 222.xx.xx.49

(5)配置ACL

源地址为192.168.160.0/24,目的地址为192.168.60.0/24的报文,需要经过IPSec隧道传输。

[HUAWEI] acl 3000

[HUAWEI-acl-adv-3000] rule permit ip source 192.168.160.0 0.0.0.255 destination 192.168.60.0 0.0.0.255

[HUAWEI-acl-adv-3000] quit

(6)配置 IKE SA。

配置IKE安全提议,指定加密算法、认证算法、DH。

[HUAWEI] ike proposal 1

[HUAWEI-ike-proposal-1] encryption-algorithm 3des

[HUAWEI-ike-proposal-1] authentication-algorithm sha1

[HUAWEI-ike-proposal-1] dh group2

[HUAWEI-ike-proposal-1] quit

配置IKE对等体,指定协商模式、IKE版本、预共享密钥。

[HUAWEI] ike peer fortigate

[HUAWEI-ike-peer-fortigate] exchange-mode main

[HUAWEI-ike-peer-fortigate] undo version 2

[HUAWEI-ike-peer-fortigate] ike-proposal 1

[HUAWEI-ike-peer-fortigate] pre-shared-key Key@hcit333

[HUAWEI-ike-peer-fortigate] quit

(7)配置IPSec安全提议,指定封装模式、安全协议,加密算法、认证算法。

[HUAWEI] ipsec proposal tran1

[HUAWEI-ipsec-proposal-tran1] transform esp

[HUAWEI-ipsec-proposal-tran1] encapsulation-mode tunnel

[HUAWEI-ipsec-proposal-tran1] esp encryption-algorithm 3des

[HUAWEI-ipsec-proposal-tran1] esp authentication-algorithm sha1

[HUAWEI-ipsec-proposal-tran1] quit

(8)配置模板及策略,绑定IKE对等体、IPSe安全提议、ACL。

[HUAWEI] ipsec policy-template tem 1

[HUAWEI-ipsec-policy-template-tem-1] security acl 3000

[HUAWEI-ipsec-policy-template-tem-1] proposal tran1

[HUAWEI-ipsec-policy-template-tem-1] ike-peer fortigate

[HUAWEI-ipsec-policy-template-tem-1] ipsec policy map1 1 isakmp template tem

[HUAWEI-ipsec-policy-template-tem-1] quit

(9)在接口上应用IPSec策略。

[HUAWEI] interface GigabitEthernet 1/0/3

[HUAWEI-GigabitEthernet1/0/3] ipsec policy map1

[HUAWEI-GigabitEthernet1/0/3] quit

2、飞塔防火墙的配置

(1)配置接口

配置接口port03的宽带连接

Fortigate # config system interface

Fortigate (interface) # edit port03

Fortigate (port03) # set mode pppoe

Fortigate (port03) # set username xxxxxx

Fortigate (port03) # set password xxxxxx

Fortigate (port03) # set distance 5

*注意管理距离(distance),固定IP的distance值为10,PPPoE拨号的distance值为5

Fortigate (port03) # set dns-server-override enable

Fortigate (port03) # end

配置接口port10。

Fortigate # config system interface

Fortigate (interface) # edit port10

Fortigate (port10) # set ip 192.168.60.1/24

Fortigate (port10) # set allowaccess ping https telnet

Fortigate (port10) # end

(2)配置IKE SA,指定IKE SA的名称、绑定的接口、协商模式、加密算法、认证算法、预共享密钥、对端地址、DH。

Fortigate # config vpn ipsec phase1-interface

Fortigate (phase1-interface) # edit firewall

Fortigate (firewall) # set interface port03

Fortigate (firewall) # set mode main

Fortigate (firewall) # set proposal 3des-sha1

Fortigate (firewall) # set psksecret Key@hcit333

Fortigate (firewall) # set remote-gw 222.xx.xx.50

Fortigate (firewall) # set dhgrp 2

Fortigate (firewall) # end

(3)配置IPSec SA,指定IPSec SA的名称、绑定的IKE SA、加密算法、认证算法,DH。

Fortigate # config vpn ipsec phase2-interface

Fortigate (phase2-interface) # edit firewall

new entry 'firewall' added

Fortigate (firewall) # set phase1name firewall

Fortigate (firewall) # set dhgrp 2

Fortigate (firewall) # set proposal 3des-sha1

Fortigate (firewall) # set dst-subnet 192.168.160.0 255.255.255.0

Fortigate (firewall) # set src-subnet 192.168.60.0 255.255.255.0

Fortigate (firewall) # end

(3)将Tunnel口加入到untrust区域中。

Fortigate # config system zone

Fortigate (zone) # edit untrust

Fortigate (untrust) # set interface firewall

Fortigate (untrust) # end

(4)配置安全策略。

配置port03与port10之间的安全策略。

配置策略66,保证总部能够正常访问分支;

Fortigate # config firewall policy

Fortigate (policy) # edit 66

Fortigate (66) # set srcintf port03

Fortigate (66) # set dstintf port10

Fortigate (66) # set srcaddr all

Fortigate (66) # set dstaddr all

Fortigate (66) # set action accept

Fortigate (66) # set schedule always

Fortigate (66) # set service ANY

Fortigate (66) # end

配置策略99,保证分支能够访问总部。

Fortigate # config firewall policy

Fortigate (policy) # edit 99

Fortigate (99) # set srcintf port10

Fortigate (99) # set dstintf port03

Fortigate (99) # set srcaddr all

Fortigate (99) # set dstaddr all

Fortigate (99) # set action accept

Fortigate (99) # set schedule always

Fortigate (99) # set service ANY

Fortigate (99) # end

配置untrust与port10的安全策略,也就是Tunnel接口与port10之间的安全策略。

配置策略96,保证经过Tunnel接口的流量能够进入分支内网;

Fortigate # config firewall policy

Fortigate (policy) # edit 96

Fortigate (96) # set srcintf untrust

Fortigate (96) # set dstintf port10

Fortigate (96) # set srcaddr all

Fortigate (96) # set dstaddr all

Fortigate (96) # set action accept

Fortigate (96) # set schedule always

Fortigate (96) # set service ANY

Fortigate (96) # end

配置策略76,保证经过Tunnel接口的流量能够透传到外网。

Fortigate # config firewall policy

Fortigate (policy) # edit 76

Fortigate (76) # set srcintf port10

Fortigate (76) # set dstintf untrust

Fortigate (76) # set srcaddr all

Fortigate (76) # set dstaddr all

Fortigate (76) # set action accept

Fortigate (76) # set schedule always

Fortigate (76) # set service ANY

Fortigate (76) # end

(5)配置路由。

配置静态路由,将流量引入到Tunnel接口。

Fortigate # config route static

Fortigate (static) # edit 76

Fortigate (76) # set device firewall

Fortigate (76) # set dst 192.168.160.0 255.255.255.0

Fortigate (76) # end

三、验证配置

直接WEB登录华为防火墙,看一下IPSec是否已连接。

IPSec能连接,并且两端局域网能够互通,就表示配置正确;如果IPSec无法连接,大概率是两端参数配置不同,请仔细对比;如果IPSec已连接,但是两端局域网无法互通,请检查安全策略以及路由配置是否正确。

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2022-05-02,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 IT狂人日志58446291 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
暂无评论
推荐阅读
Springboot集成RedisTemplate使用HyperLogLog实现UV统计
Redis是一个高性能的键值对数据库,它支持多种类型的数据结构,包括字符串、列表、集合、有序集合等。自Redis 2.8.9版本起,Redis引入了HyperLogLog这一数据结构,它主要用于基数估算,即估算一个集合中不同元素的数量。HyperLogLog以其极低的内存消耗和高效的估算能力,在大数据量的统计中发挥着重要作用。
知识浅谈
2025/05/16
820
Reids(4)——神奇的HyperLoglog解决统计问题
HyperLogLog 是最早由 Flajolet 及其同事在 2007 年提出的一种 估算基数的近似最优算法。但跟原版论文不同的是,好像很多书包括 Redis 作者都把它称为一种 新的数据结构(new datastruct) (算法实现确实需要一种特定的数据结构来实现)。
乔戈里
2020/03/13
6120
初识Redis的数据类型HyperLogLog
未来一段时间开发的项目或者需求会大量使用到Redis,趁着这段时间业务并不太繁忙,抽点时间预习和复习Redis的相关内容。刚好看到博客下面的UV和PV统计,想到了最近看书里面提到的HyperLogLog数据类型,于是花点时间分析一下它的使用方式和使用场景(暂时不探究HyperLogLog的实现原理)。Redis中HyperLogLog数据类型是Redid 2.8.9引入的,使用的时候确保Redis版本>= 2.8.9。
Throwable
2020/06/18
6980
初识Redis的数据类型HyperLogLog
【Redis基础】Redis新数据类型(Bitmaps,HyperLoglog,Geospatial)命令简介与案例演示
Bitmaps 并不是实际的数据类型,而是定义在String类型上的一个面向字节操作的集合。因为字符串是二进制安全的块,他们的最大长度是512M,最适合设置成2^32个不同字节。 bitmaps的位操作分成两类:1.固定时间的单个位操作,比如把String的某个位设置为1或者0,或者获取某个位上的值 2.对于一组位的操作,对给定的bit范围内,统计设定值为1的数目(比如人口统计)。 bitmaps最大的优势是在存储数据时可以极大的节省空间,比如在一个项目中采用自增长的id来标识用户,就可以仅用512M的内存来记录40亿用户的信息(比如用户是否希望收到新的通知,用1和0标识)
小尘要自信
2023/10/10
3100
技术总结|十分钟了解UV统计算法HyperLogLog
考虑到上述问题的扩展性,除了统计APP每日的独立用户登录数,还需要统计打开每个页面的独立用户数。
用户1904552
2025/02/27
1270
技术总结|十分钟了解UV统计算法HyperLogLog
Redis6发布订阅及Redis新数据类型
Redis 发布订阅 (pub/sub) 是一种消息通信模式:发送者 (pub) 发送消息,订阅者 (sub) 接收消息
大忽悠爱学习
2021/11/15
5430
2023-06-13:统计高并发网站每个网页每天的 UV 数据,结合Redis你会如何实现?
2023-06-13:统计高并发网站每个网页每天的 UV 数据,结合Redis你会如何实现?
福大大架构师每日一题
2023/06/21
5010
2023-06-13:统计高并发网站每个网页每天的 UV 数据,结合Redis你会如何实现?
hyperloglog的java版使用
对于海量数据来说,数据内存占用会变得很高. Probabilistic数据结构牺牲了一下准确率去换取更低内存占用。比如一个HyperLogLog的数据结构只需要花费12KB内存,就可以计算接近2^64个不同元素的基数,而错误率在1.625%.
code4it
2018/09/17
1.5K0
redis hyperloglog实现原理
HyperLogLog 是一种基数估算算法。所谓基数估算,就是估算在一批数据中,不重复元素的个数有多少。最常见的场景就是统计uv。首先要说明,HyperLogLog实际上不会存储每个元素的值,它使用的是概率算法,通过存储元素的hash值的第一个1的位置,来计算元素数量。这样做存在误差,不适合绝对准确计数的场景。redis中实现的HyperLogLog,只需要12K内存,在标准误差0.81%的前提下,能够统计2的64次方个数据。
程序员小饭
2022/03/03
1.2K0
redis  hyperloglog实现原理
走近源码:神奇的HyperLogLog
HyperLogLog是Redis的高级数据结构,是统计基数的利器。前文我们已经介绍过HyperLogLog的基本用法,如果只求会用,只需要掌握HyperLogLog的三个命令即可,如果想要更进一步了解HyperLogLog的原理以及源码实现,相信这篇文章会给你带来一些启发。
Jackeyzhe
2020/03/11
9560
走近源码:神奇的HyperLogLog
⑧【HyperLoglog】Redis数据类型:HyperLoglog [使用手册]
pfmerge destkey sourcekey [sourcekey ...]
.29.
2023/11/26
1850
⑧【HyperLoglog】Redis数据类型:HyperLoglog [使用手册]
如何借助Redis更高效统计UV?——Hyperloglog篇
在今天的互联网时代,数据如潮水般汹涌而来。从用户行为数据、系统日志到实时交互数据,如何高效、准确地统计这海量数据中的唯一元素数量,成为了一个不小的挑战。
南山竹
2024/07/18
3810
如何借助Redis更高效统计UV?——Hyperloglog篇
Redis基础教程(十):HyperLogLog
在大数据处理中,精确计数唯一元素(如网站的独立访客数、用户行为分析中的唯一操作次数等)常常会面临存储和性能的双重挑战。传统的计数方法,如使用集合(Set)存储每个唯一元素,虽然能提供精确的结果,但在处理海量数据时会消耗大量的内存资源。这时,HyperLogLog 算法便展现出了其独特的优势。Redis 自版本 2.8.9 起,引入了 HyperLogLog 数据结构,为近似计数唯一元素提供了高效且节省内存的解决方案。本文将深入探讨 Redis HyperLogLog 的工作原理、使用方法及实战案例,帮助你理解并掌握这一强大的数据结构。
用户11147438
2024/07/12
2610
Redis系列(十八)独立功能之hyperloglog
Redis 提供了很多精巧的独立功能,本文介绍 HyperLogLog, 它可以称作唯一性统计的利器了。
呼延十
2020/12/23
2.5K0
Redis系列(十八)独立功能之hyperloglog
HyperLogLog统计网站UV 太丝滑
网站的UV(Unique Visitor)是指独立访客的数量,用于衡量网站的访问量和流量。在网站统计中,通常使用UV来度量网站的独立访客数量。
柯柏技术笔记
2024/01/26
2881
redis的HyperLogLog实战
作用域单个HyperLogLog时,复杂度为O(1),作用于多个HyperLogLog时,复杂度为O(N)
code4it
2018/09/17
1.3K0
如何用redis统计海量UV?
我们先思考一个常见的业务问题:如果你负责开发维护一个大型的网站,有一天老板找产品经理要网站每个网页每天的 UV 数据,然后让你来开发这个统计模块,你会如何实现?
程序员小饭
2021/08/13
1.3K0
学透 Redis HyperLogLog,看这篇就够了
在移动互联网的业务场景中,数据量很大,系统需要保存这样的信息:一个 key 关联了一个数据集合,同时对这个数据集合做统计做一个报表给运营人员看。
码哥字节
2023/09/26
2.5K1
学透 Redis HyperLogLog,看这篇就够了
Redis HyperLogLog:数据统计的轻量级解决方案
这次,阿七将介绍一种名为 HyperLogLog 的算法,它在 Redis 中的实现让大规模数据统计变得简单且高效。
伍六七AI编程
2023/12/19
3110
Redis HyperLogLog:数据统计的轻量级解决方案
Redis之HyperLogLog类型解读
HyperLogLog 是用来做基数统计的算法,HyperLogLog 的优点是,在输入元素的数量或者体积非常非常大时,计算基数所需的空间总是固定 的、并且是很小的。
一个风轻云淡
2023/09/23
5600
推荐阅读
相关推荐
Springboot集成RedisTemplate使用HyperLogLog实现UV统计
更多 >
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档