Цель: Проброс портов через Linux (nftables).
1. Включение IP Forwarding (на всех роутерах):
echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf
sysctl -p
2. Настройка VQ-TRT (Скопировать и вставить все, только заменить IP согласно заданию)
# Очистка старых правил
nft flush ruleset
# Создание таблицы nat
nft add table ip nat
nft add chain ip nat prerouting { type nat hook prerouting priority dstnat\; }
nft add chain ip nat postrouting { type nat hook postrouting priority srcnat\; }
# Проброс портов
nft add rule ip nat prerouting tcp dport 80 dnat to <IP_VQ-SVR>:8080
nft add rule ip nat prerouting tcp dport 2026 dnat to <IP_VQ-SVR>:2026
# Masquerade
nft add rule ip nat postrouting masquerade
# Фильтр (разрешить forward)
nft add table ip filter
nft add chain ip filter forward { type filter hook forward priority 0\; policy accept\; }
# Сохранение
nft list ruleset > /etc/nftables/nftables.nft
systemctl enable --now nftables
3. Настройка VR-TRT (Скопировать и вставить все, только заменить IP согласно заданию)
nft flush ruleset
nft add table ip nat
nft add chain ip nat prerouting { type nat hook prerouting priority dstnat\; }
nft add chain ip nat postrouting { type nat hook postrouting priority srcnat\; }
# Проброс портов
nft add rule ip nat prerouting tcp dport 8080 dnat to <IP_VR-SVR>:8080
nft add rule ip nat prerouting tcp dport 2026 dnat to <IP_VR-SVR>:2026
nft add rule ip nat postrouting masquerade
nft add table ip filter
nft add chain ip filter forward { type filter hook forward priority 0\; policy accept\; }
nft list ruleset > /etc/nftables/nftables.nft
systemctl enable --now nftables