mrlesmithjr.frr

目次 generated with DocToc

ansible-frr

FRRをインストール/設定するためのAnsibleロール

NOTE: FRRouting (FRR)は、LinuxおよびUnixプラットフォーム用のIPルーティングプロトコルスイートで、BFD、BGP、IS-IS、LDP、OSPF、PIM、およびRIPのプロトコルデーモンを含みます。

ビルドステータス

GitHub Actions

モレキュールテスト

Travis CI

ビルドステータス

要件

必要なAnsibleロールについては、以下を参照してください: requirements.yml

役割変数

defaults/main.yml

依存関係

サンプルプレイブック

playbook.yml

ルートマップとプレフィックスリスト

ルートマップ

ルートマップの設定

以下はルートマップ設定の例です:

frr_route_map:
  RTBH:
    permit 10:
      interface: blackhole
      prefix_list: Bad_IPs
      origin: igp
      community: "12345:100"
      src: 2001:db8::bf03
  RTBH_IN:
    deny 10: []

一般オプション

IP/IPv6 フォワーディング

以下はIPおよびIPv6のフォワーディングを有効にする例です:

frr_ip_forwarding: true
frr_ipv6_forwarding: true

カーネルフォワーディングを有効にするために、役割はnet.ipv4.ip_forwardおよびnet.ipv6.conf.all.forwardingというsysctl変数を設定します。sysctl設定の場所をカスタマイズするには、以下の変数を使用できます:

frr_sysctl_file: /etc/sysctl.d/100-ansible-frr.conf

デフォルト経由のネクストホップ追跡

デフォルトルートを使用してネクスタップを解決します。 BGPピアがデフォルトゲートウェイ経由でのみ到達可能な場合に便利です(デフォルトでは無効)。

有効にするには:

frr_nht_resolve_default: true

プレフィックスリスト

プレフィックスリストの設定

以下はプレフィックスリスト設定の例です:

frr_prefix_list:
  Bad_IPs:
    05 permit:
      prefix: 192.168.88.0/24
      match: ge 32
    10 permit:
      prefix: 172.16.0.0/16
      match: le 32
frr_prefix_list_v6:
  Bad_IPs:
    05 permit:
      prefix: 1234:5678::/32
      match: ge 128

アクセスリスト

アクセスリストの設定

以下は例です:

frr_access_list:
  - "10 permit 10.10.10.21/32"
  - "10 permit 192.168.0.0/17"
  - "101 permit ip 10.0.0.0 0.0.0.255 any"

双方向フォワーディング検出 (BFD)

BFDの有効化

BFDを有効にするには、以下のようにbfdd: trueが設定されていることを確認してください:

frr_daemons:
  bfdd: true
  bgpd: false
  isisd: false
  ldpd: false
  nhrpd: false
  ospf6d: false
  ospfd: false
  pimd: false
  ripd: false
  ripngd: false
  zebra: true

BFDの設定

BFDの設定はBGP隣接設定の下で行います。OSPF用のBFDはまだサポートされていません。

サポートされているルーティングプロトコル

プロトコル 実装状態 メモ
BGP X 初期設定のみ
OSPF X 初期設定のみ
STATIC X 初期設定のみ

BGP

BGPの有効化

BGPルーティングを有効にするには、以下のようにbgpd: trueが設定されていることを確認してください:

frr_daemons:
  bfdd: false
  bgpd: false
  isisd: false
  ldpd: false
  nhrpd: false
  ospf6d: false
  ospfd: false
  pimd: false
  ripd: false
  ripngd: false
  zebra: true

BGPの設定

BGPを設定するには、必要に応じて以下を定義します:

frr_bgp:
  asns:
    65000:
      log_neighbor_changes: true
      no_ebgp_requires_policy: true
      timers: '3 9'
      other:
        - "bgp bestpath as-path multipath-relax"
        - "no bgp network import-check"
      neighbors:
        group1:
          asn: 66000
          is_peer_group: true
          multihop: 255
        192.168.250.11:
          asn: 65000
          default_originate: false
          description: node1
          next_hop_self: true
          timers_connect: 5
          v6only: true
          bfd_peer: true
          bfd_peer_detect_multiplier: 3
          bfd_peer_receive_interval: 50
          bfd_peer_transmit_interval: 50
          bfd_peer_echo_interval: 50
          bfd_peer_passive_mode: true
          bfd_peer_minimum_ttl: 253
          other:
            - "capability dynamic"
        192.168.250.12:
          asn: 65000
          default_originate: false
          description: node2
          next_hop_self: true
          v4_route_reflector_client: true
          password: secret
          bfd_peer: true
          bfd_peer_transmit_interval: 2000
          bfd_peer_echo_mode: true
          other:
            - "prefix-list Bad_IPs in"
        192.168.250.12:
          peer_group: group1
          description: far_away
      listen_range:
        192.168.250.0/24: group1
      networks:
        - "{{ frr_router_id }}/32"
        - "{{ hostvars[inventory_hostname]['ansible_enp0s8']['ipv4']['address'] }}/24"
      redistribute:
        - bgp
        - connected
        - kernel
        - ospf
        - static
      redistribute_v6:
        - bgp
        - connected
        - kernel

BGPの例

以下はBGP設定の例です:

frr_bgp:
  asns:
    65000:
      log_neighbor_changes: true
      af_v4:
        - "maximum-paths 2"
      af_v6:
        - "maximum-paths 2"
      af_evpn:
        - "advertise-all-vni"
        - "rd {{ frr_router_id }}:1"
      neighbors:
        192.168.250.11:
          asn: 65000
          default_originate: false
          description: node1
          next_hop_self: true
          af_v4:
            - "soft-reconfiguration inbound"
        192.168.250.12:
          asn: 65000
          default_originate: false
          description: node2
          next_hop_self: true
        "::1":
          asn: 65000
          default_originate: false
          description: node1
          next_hop_self: true
          af_v6:
            - "activate"
            - "soft-reconfiguration inbound"
        172.16.250.10:
          asn: internal
          timers_connect: 5
          description: "L2VPN EVPN neighbor"
          af_evpn:
            - "activate"
          other:
            - "capability extended-nexthop"
      networks:
        - "{{ frr_router_id }}/32"
        - "{{ hostvars[inventory_hostname]['ansible_enp0s8']['ipv4']['address'] }}/24"
        - "{{ hostvars[inventory_hostname]['ansible_enp0s9']['ipv4']['address'] }}/24"
        - "{{ hostvars[inventory_hostname]['ansible_enp0s10']['ipv4']['address'] }}/24"
        - "{{ hostvars[inventory_hostname]['ansible_enp0s16']['ipv4']['address'] }}/24"
      networks_v6:
        - "1::3/64"

以下はこの設定に基づいたBGPの概要です:

BGPテーブルバージョンは13で、ローカルルーターIDは1.1.1.1です
ステータスコード: s suppresssed, d damped, h history, * valid, > best, = multipath,
              i internal, r RIB-failure, S Stale, R Removed
オリジンコード: i - IGP, e - EGP, ? - 不完全

   ネットワーク         次のホップ            メトリック LocPrf Weight パス
*> 1.1.1.1/32       0.0.0.0                  0         32768 i
*>i2.2.2.2/32       192.168.250.11           0    100      0 i
*>i3.3.3.3/32       192.168.250.12           0    100      0 i
*> 192.168.10.0     0.0.0.0                  0         32768 i
*>i192.168.11.0     192.168.250.11           0    100      0 i
*>i192.168.12.0     192.168.250.12           0    100      0 i
*> 192.168.20.0     0.0.0.0                  0         32768 i
*>i192.168.21.0     192.168.250.11           0    100      0 i
*>i192.168.22.0     192.168.250.12           0    100      0 i
*> 192.168.30.0     0.0.0.0                  0         32768 i
*>i192.168.31.0     192.168.250.11           0    100      0 i
*>i192.168.32.0     192.168.250.12           0    100      0 i
* i192.168.250.0    192.168.250.11           0    100      0 i
* i                 192.168.250.12           0    100      0 i
*>                  0.0.0.0                  0         32768 i

表示されたルートは13で、合計パスは15です

OSPF

OSPFの有効化

OSPFルーティングを有効にするには、以下のようにospfd: trueが設定されていることを確認してください:

frr_daemons:
  bfdd: false
  bgpd: false
  isisd: false
  ldpd: false
  nhrpd: false
  ospf6d: false
  ospfd: false
  pimd: false
  ripd: false
  ripngd: false
  zebra: true

OSPFの設定

OSPFを設定するには、必要に応じて以下を定義します:

frr_ospf:
  areas:
    0:
      networks:
        - "{{ frr_router_id }}/32"
    1:
      networks:
        - "{{ hostvars[inventory_hostname]['ansible_enp0s8']['ipv4']['address'] }}/24"
      auth: true

    2:
      networks:
        - "{{ hostvars[inventory_hostname]['ansible_enp0s9']['ipv4']['address'] }}/24"
      type: nssa

  log_adjacency_changes: true
  passive_interfaces: # パッシブに設定するインターフェースのリスト
    - default
  redistribute: # 再配布するプロトコルのリスト
    - bgp
    - connected
    - kernel
    - ospf
    - static
  distribute_list:
    - name: 10
      dir: out
      protocol: connected

VRF対応OSPF

frr_ospf_vrf_enabledの各キーはVRF名を表します:

frr_ospf_vrf_enabled:
  public:
    redistribute:
    - bgp
    - connected
    passive_interfaces:
     - lo
    log_adjacency_changes: true
    areas:
      1:
        networks:
          - "{{ hostvars[inventory_hostname]['ansible_ens3']['ipv4']['address'] }}/30"
        auth: true
  mgmt:
    redistribute:
      - kernel
    areas:
      0:
        networks:
          - 172.16.0.0/12
      2:
        networks:
          - 192.168.0.0/16
        type: nssa

STATIC

STATIC ルートの設定

静的ルートを設定するには、必要に応じて以下を定義します:

frr_static: # 辞書形式。キー=宛先、値=ネクストホップ
  10.0.0.0/8: 192.168.1.1
  1.1.1.1: 192.168.1.1
  1.1.1.2: blackhole
frr_static_v6: # 辞書形式。キー=宛先、値=ネクストホップ
  2001:0db8:85a3:8a2e::/64 2001::1

インターフェース設定

インターフェース

frr_interfaces: # 辞書形式。キー=インターフェース名、値=インターフェースデータ
  lo:
    ip: 10.0.0.0/32 # ipは単一値またはリスト
    ipv6: 2001:0db8:85a3:8a2e::1/64 # ipv6は単一値またはリスト
    description: loopback
  eth0:
    ip: # ipは単一値またはリスト
      - 10.0.0.0/32
      - 172.16.0.0/32
    ipv6: # ipv6は単一値またはリスト
      - 2001:0db8:85a3:8a2e::1/64
      - 2001:0db8:85a3:8a2e::2/64
    vrf: management # インターフェースを'management' VRFに配置
    auth:
      id: 1
      key: supersecret
    other:
      - "no ipv6 nd suppress-ra"
      - "link-detect"

NOTE: デバイスは各VRF対応インターフェースに正しいVRF割り当てを持っている必要があります:

ip link set dev ${IFACE} master ${VRF}

アップグレード/ダウングレード

NOTE: FRRはこのロールを使用して6.0.2からダウングレードできません。

以下の変数を設定することで、FRRをアップグレードまたはダウングレードできます:

frr_version: 6.0.2 から frr_version: 6.0

Quagga設定

NOTE: QuaggaはOSのローカルリポジトリからインストールする必要があります。

次の変数を使用することで、FRRの代わりにQuaggaを設定できます:

routing_type: quagga

Quagga固有の追加設定

frr_bgp:
  asns:
    65000:
      neighbors:
        swp1:
          **interface: true**

ライセンス

MIT

著者情報

Larry Smith Jr.

コーヒーを買ってください

NOTE: リポジトリはhttps://github.com/mrlesmithjr/cookiecutter-ansible-roleをテンプレートとして作成/更新されています。

プロジェクトについて

Ansible role to install/configure [FRR](https://frrouting.org/)

インストール
ansible-galaxy install mrlesmithjr.frr
ライセンス
mit
ダウンロード
102.6k
所有者
Doing my thang with #automation #DevOps and cloudy things! Providing hopefully valuable content for others to consume easily and also learn from.