Enhance ExaBGP configuration and scripts by adding environment variable support for neighbor IP, local AS, and router ID. Update Dockerfile to include permissions for the new generate_config.py script. Improve start.sh to generate configuration dynamically and display relevant information during startup.
Build and Push Docker Image / build (push) Successful in 3m34s

This commit is contained in:
2025-07-11 16:28:33 +07:00
parent 050cf03339
commit a437b75540
6 changed files with 146 additions and 61 deletions
+12 -4
View File
@@ -78,18 +78,23 @@ def load_all_prefixes() -> Set[str]:
def announce_prefixes(prefixes: Set[str]):
"""Анонсирование префиксов через ExaBGP API"""
# Получение настроек из переменных окружения
neighbor_ip = os.environ.get('BGP_NEIGHBOR_IP', '192.168.1.1')
local_as = int(os.environ.get('BGP_LOCAL_AS', '65000'))
router_id = os.environ.get('BGP_ROUTER_ID', '192.168.1.100')
for prefix in sorted(prefixes):
# Формат команды для ExaBGP
command = {
"command": "announce route",
"neighbor": {
"ip": "192.168.1.1",
"ip": neighbor_ip,
"description": "RouterOS peer"
},
"attribute": {
"origin": "igp",
"as-path": [65000],
"next-hop": "192.168.1.100"
"as-path": [local_as],
"next-hop": router_id
},
"nlri": prefix
}
@@ -100,11 +105,14 @@ def announce_prefixes(prefixes: Set[str]):
def withdraw_prefixes(prefixes: Set[str]):
"""Отзыв префиксов через ExaBGP API"""
# Получение настроек из переменных окружения
neighbor_ip = os.environ.get('BGP_NEIGHBOR_IP', '192.168.1.1')
for prefix in sorted(prefixes):
command = {
"command": "withdraw route",
"neighbor": {
"ip": "192.168.1.1",
"ip": neighbor_ip,
"description": "RouterOS peer"
},
"nlri": prefix