Juniper — различия между версиями

Материал из gptel_wiki
Перейти к: навигация, поиск
(q-in-q)
Строка 158: Строка 158:
  
 
[http://www.juniper.net/techpubs/en_US/junos14.1/topics/concept/policy-routing-policies-chain-evaluation-method.html Порядок выполнения полиси]
 
[http://www.juniper.net/techpubs/en_US/junos14.1/topics/concept/policy-routing-policies-chain-evaluation-method.html Порядок выполнения полиси]
 +
 +
 +
== полисеры ==
 +
 +
svc-pppoe-policer-10m {
 +
        interfaces {
 +
            pp0 {
 +
                unit "$junos-interface-unit" {
 +
                    family inet {
 +
                        filter {
 +
                            input policer-10m;
 +
                            output policer-10m;
 +
                        }
 +
                    }
 +
                }
 +
            }
 +
        }
 +
    }
 +
 +
firewall {
 +
    family inet {
 +
        filter policer-10m {
 +
            interface-specific;
 +
            term 1 {
 +
                from {
 +
                    destination-address {
 +
                        УУУ.ХХХ.6.38/32;
 +
                        УУУ.ХХХ.6.6/32;
 +
                    }
 +
                    source-prefix-list {
 +
                        NoMoneyHosts;
 +
                    }
 +
                    protocol [ tcp udp ];
 +
                    destination-port [ 80 53 ];
 +
                }
 +
                then accept;
 +
            }
 +
            term 2 {
 +
                from {
 +
                    source-prefix-list {
 +
                        NoMoneyHosts;
 +
                    }
 +
                    protocol [ tcp udp ];
 +
                    destination-port [ 80 53 ];
 +
                }
 +
                then {
 +
                    routing-instance neg_dep;
 +
                }
 +
            }
 +
            term 3 {
 +
                from {
 +
                    source-prefix-list {
 +
                        NoMoneyHosts;
 +
                    }
 +
                }
 +
                then {
 +
                    discard;
 +
                }
 +
            }
 +
            term default {
 +
                then policer 10m;
 +
            }
 +
        }
 +
 +
    policer 10m {
 +
        if-exceeding {
 +
            bandwidth-limit 10m;
 +
            burst-size-limit 640k;
 +
        }
 +
        then discard;
 +
    }

Версия 20:20, 25 октября 2016

Как в каком порядке работают policy

Начинает работать первый списку term в policy
если происходит срабатывание и под него прописано действие accept или reject
policy заканчивает обработку маршрута и начинает обрабатывать следующий маршрут с начального term-а. 

Пример: выставляем низкий приоритет для всех подсетей МТС

show policy-statement retn-in

term 10 {
    from {
        protocol bgp;
        as-path as-mts; ''если маршрут из номера автономки''
    }
    then {
        local-preference 209;  ''присваиваем localpref''
        accept;  ''и заканчиваем обработку этого маршрута''
    }
}
term 20 {
    then {
        local-preference 210;  ''или другой localpref остальным маршрутам''
        accept;
    }
}


Если действие accept-reject не указано обработка произойдет и будет переход с следующему в списке term-у.

Если применен операнд next-term то действие accept-reject будет проигнорировано и произойдет переход к следующему term-у.


community prepends

разрешаем кастомеру использовать community для самостоятельной установки препендов

policy-statement prepend {
 term 10 {
  from community prepend-1;
  then {
   as-path-expand last-as;
   accept;
   }
  }
 term 20 {
  from community prepend-2;
  then {
   as-path-expand last-as count 2;
   accept;
   }
  }
 }

community prepend-1 65000:1;
community prepend-2 65000:2;

community backup

разрешаем кастомеру использовать community backup для полного исключения входящего на него трафика т.е.

устанавливаем минимальный из диапазона используемых local preference

policy-options {
 community comm_backup members 42484:65535;
 policy-statement from-customer {
  from community comm_backup;
  then {
   metric 2;
   preference 10;
   next policy;
  }
 }
}

Полезные команды

root@jun# run test policy ANNOUNCE-OUT d.d.d.0/21

Откат конфигураций
root@junr# rollback {откат на последнюю конфигурацию}
root@jun# rollback? {просмотр откатов конфигурации}

Просмотр изменений в конфигурации ДО ее применения
root@junr# show | compare 

Просмотр изменений в конфигурации ПОСЛЕ ее применения
root@junr# show | compare rollback 0

Ввести конфигурацию в форматированном виде
load merge terminal

q-in-q

Table 1: Components of the Topology for Setting Up Q-in-Q Tunneling

Interface	Description

ge-0/0/11.0
Tagged S-VLAN trunk port

ge-0/0/12.0
Untagged customer-facing access port

ge-0/0/13.0
Untagged customer-facing access port

ge-0/0/14.0
Tagged S-VLAN trunk port

Configuration

[edit]

set vlans qinqvlan vlan-id 4001
set vlans qinqvlan dot1q-tunneling customer-vlans 1-100
set vlans qinqvlan dot1q-tunneling customer-vlans 201-300
set interfaces ge-0/0/11 unit 0 family ethernet-switching port-mode trunk
set interfaces ge-0/0/11 unit 0 family ethernet-switching vlan members 4001
set interfaces ge-0/0/12 unit 0 family ethernet-switching port-mode access
set interfaces ge-0/0/12 unit 0 family ethernet-switching vlan members 4001
set interfaces ge-0/0/13 unit 0 family ethernet-switching port-mode access
set interfaces ge-0/0/13 unit 0 family ethernet-switching vlan members 4001
set interfaces ge-0/0/14 unit 0 family ethernet-switching port-mode trunk
set interfaces ge-0/0/14 unit 0 family ethernet-switching vlan members 4001
set ethernet-switching-options dot1q-tunneling ether-type 0x9100

Verify that Q-in-Q tunneling was properly enabled on the switch.

user@switch> show vlans qinqvlan extensive
VLAN: qinqvlan, Created at: Thu Sep 18 07:17:53 2008
802.1Q Tag: 4001, Internal index: 18, Admin State: Enabled, Origin: Static
Dot1q Tunneling Status: Enabled
Customer VLAN ranges:
                     1-100
                     201-300
Protocol: Port Mode
Number of interfaces: Tagged 2 (Active = 0), Untagged  4 (Active = 0)
      ge-0/0/11.0, tagged, trunk
      ge-0/0/14.0, tagged, trunk
      ge-0/0/12.0, untagged, access
      ge-0/0/13.0, untagged, access

Полезные ссылки

Порядок выполнения полиси


полисеры

svc-pppoe-policer-10m {

       interfaces { 
           pp0 { 
               unit "$junos-interface-unit" { 
                   family inet { 
                       filter { 
                           input policer-10m; 
                           output policer-10m; 
                       } 
                   } 
               } 
           } 
       } 
   } 

firewall {

   family inet { 
       filter policer-10m { 
           interface-specific; 
           term 1 { 
               from { 
                   destination-address { 
                       УУУ.ХХХ.6.38/32; 
                       УУУ.ХХХ.6.6/32; 
                   } 
                   source-prefix-list { 
                       NoMoneyHosts; 
                   } 
                   protocol [ tcp udp ]; 
                   destination-port [ 80 53 ]; 
               } 
               then accept; 
           } 
           term 2 { 
               from { 
                   source-prefix-list { 
                       NoMoneyHosts; 
                   } 
                   protocol [ tcp udp ]; 
                   destination-port [ 80 53 ]; 
               } 
               then { 
                   routing-instance neg_dep; 
               } 
           } 
           term 3 { 
               from { 
                   source-prefix-list { 
                       NoMoneyHosts; 
                   } 
               } 
               then { 
                   discard; 
               } 
           } 
           term default { 
               then policer 10m; 
           } 
       } 
   policer 10m { 
       if-exceeding { 
           bandwidth-limit 10m; 
           burst-size-limit 640k; 
       } 
       then discard; 
   }