Зміст

    Налаштування BGP на маршрутизаторах Juniper

    04.02.2026

    Вхідні дані

    ПараметрЗначення
    Наш AS49570
    Cogent AS174
    Наш IP (на лінку)38.120.0.5/31
    Cogent IP (gateway)38.120.0.4/31
    Наш анонсований префікс91.105.208.0/21
    Домашній IP185.0.0.21

    1️⃣ Налаштування chassis

    set chassis aggregated-devices ethernet device-count 2
    set chassis fpc 0 ir-mode R
    set chassis alarm management-ethernet link-down ignore

     2️⃣ Інтерфейс (якщо ще не налаштований)

    Припустимо, що це xe-0/0/0.0 (інтерфейс підстав свій)

    set interfaces xe-0/0/0 unit 0 family inet address 38.120.0.5/31
    set chassis aggregated-devices ethernet device-count 2

    3️⃣   Policy-options — фільтри

    🔹 Prefix-list: що ми анонсуємо Cogent

    set policy-options prefix-list OUR-PREFIXES 91.105.208.0/21

    🔹 Експортна політика: що віддаємо Cogent

    set policy-options policy-statement EXPORT-TO-COGENT term ALLOW-OUR-NETS from prefix-list OUR-PREFIXES
    set policy-options policy-statement EXPORT-TO-COGENT term ALLOW-OUR-NETS then accept
    
    set policy-options policy-statement EXPORT-TO-COGENT term DENY-ALL then reject

    ➡️ Cogent любить строгість — тільки ваші префікси, ніяких сюрпризів.

    🔹 Імпортна політика: що приймаємо від Cogent

    Найпростіший і найчастіше використовуваний варіант — приймати все:

    set policy-options policy-statement IMPORT-FROM-COGENT term ACCEPT-ALL then accept
    

    💡 Пізніше можна ускладнити: max-prefix, local-pref, communities тощо.

    4️⃣ BGP configuration

    🔹 Основна група eBGP

    set protocols bgp group COGENT type external
    set protocols bgp group COGENT peer-as 174
    set protocols bgp group COGENT local-as 49570

    🔹 BGP neighbor

    set protocols bgp group COGENT neighbor 38.120.0.4
    

    🔹 Застосовуємо політики

    set protocols bgp group COGENT export EXPORT-TO-COGENT
    set protocols bgp group COGENT import IMPORT-FROM-COGENT
    set protocols bgp group COGENT description "Cogent Communications"

    🔹 Реєстрація сесії

    set protocols bgp group COGENT log-updown
    

    5️⃣ Firewall

    Обмежуємо доступ до маршрутизатора по SSH

    🔹 Список IP-адрес, з яких буде відкритий доступ

    set policy-options prefix-list ssh-access 185.0.0.21/32

    🔹 Правила Firewall

    set firewall family inet filter juniper-access-ipv4 term ALLOW_BGP_DYNAMIC from source-prefix-list BGP_PEERS_DYNAMIC
    set firewall family inet filter juniper-access-ipv4 term ALLOW_BGP_DYNAMIC from protocol tcp
    set firewall family inet filter juniper-access-ipv4 term ALLOW_BGP_DYNAMIC from port bgp
    set firewall family inet filter juniper-access-ipv4 term ALLOW_BGP_DYNAMIC then accept
    
    set firewall family inet filter juniper-access-ipv4 term allow-ssh-access from source-prefix-list ssh-access
    set firewall family inet filter juniper-access-ipv4 term allow-ssh-access then accept
    set firewall family inet filter juniper-access-ipv4 term discard-ssh-access from protocol tcp
    set firewall family inet filter juniper-access-ipv4 term discard-ssh-access from destination-port ssh
    set firewall family inet filter juniper-access-ipv4 term discard-ssh-access then discard
    

    🔹 Призначаємо правила Firewall на порт

    set interfaces lo0 unit 0 family inet filter input juniper-access-ipv4
    set interfaces lo0 unit 0 family inet address 127.0.0.1/32

    6️⃣   Перевірка після commit

    show bgp summary
    show route advertising-protocol bgp 38.120.0.4
    show route receive-protocol bgp 38.120.0.4