本人是it界的一只小菜鸟,从今天(2017.7.20)开始记录工作及学习中遇到的与技术相关的点点滴滴,方便日后回顾。同时也欢迎大家评论,补充不足与之处错误。


昨天接到xx部门的需求,需要在juniper的交换机上做限速的配置。

之前没有怎么接触过juniper交换机啊,配置的方式和公司用的较多的Cisco,huawei等厂家的机器的配置方式不同。

总结起来主要的的配置如下,客户需求为对已经做好端口绑定的interface ae2进行限速。

在百度上查询了一番,选择的限速方式是通过firewall,主要思路为:

1.先设置对应的IN和OUT两个方向的policy:

set policy-options prefix-list xxxx-xxxx-xxxx(name)  xxx.xxx.xxx.xxx/xx(目标地址段)  作为source和destination


2.自己创建需要的限速规则:(以限速160M为例)

set firewall policer USER-160M if-exceeding bandwidth-limit 160M

set firewall policer USER-160M if burst-size-limit 16M(160M/10)

set firewal policer USER-160M then discard

(很重要,若少了这一步,最后commit的时候会报错,内容为

 'policer USER-160M'
    then clause not specified
error: configuration check-out failed

  提示该policer未定语,这样在配置模式中可以查询到USER-160M,但是去全局模式查询不到,个人理解为需要将配置好的policer丢到外面)


3.接下来就是把policer应用到端口或者vlan上面的过程了:

set firewall family inet filter ALL-USER-OUT term xxxx-xxxx-xxxx from destination-prefix-list xxxx-xxxx-xxxx
set firewall family inet filter ALL-USER-OUT term xxxx-xxxx-xxxx then policer USER-160M
set firewall family inet filter ALL-USER-OUT term xxxx-xxxx-xxxx then accept
set firewall family inet filter ALL-USER-IN term xxxx-xxxx-xxxx from source-prefix-list xxxx-xxxx-xxxx
set firewall family inet filter ALL-USER-IN term xxxx-xxxx-xxxx then policer USER-160M
set firewall family inet filter ALL-USER-IN term xxxx-xxxx-xxxx then accept

commmit

在应用前一定要把出和进时候的目的地址和源地址填写,不然配置成功但是不生效。


4.配置完成,退出配置模式(quit),保险起见,检查一下

通过命令:sh conf fire po ? 可以查询policer是否已经被discard出来了(个人这么认为)。

                 sh conf  查询对应的规则,可以看见是否配置成功。


至此,juniper的一个限速实例已经完成。其中仍需要继续深入了解的问题还有discard的详解,将找时间在后续的博文中给出后续学习结果,也欢迎如果有大牛看到给与解答,谢谢。