Содержание
    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

    🔹 Export policy: что отдаём 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 любит строгость — только ваши префиксы, никаких сюрпризов.

    🔹 Import policy: что принимаем от 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