net/VLan.sh

31 lines
902 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# Минимальный скрипт настройки VLAN на HQ-RTR
# sudo ./minimal_vlan.sh
[[ $EUID -ne 0 ]] && { echo "Запустите с sudo"; exit 1; }
IFACE="enp0s8" # Интерфейс для VLAN
modprobe 8021q
# Создание VLAN
ip link add link $IFACE name vlan100 type vlan id 100
ip link add link $IFACE name vlan200 type vlan id 200
ip link add link $IFACE name vlan999 type vlan id 999
# Назначение IP
ip addr add 192.168.3.1/26 dev vlan100
ip addr add 192.168.4.1/29 dev vlan200
ip addr add 192.168.1.1/28 dev vlan999
# Поднятие интерфейсов
ip link set $IFACE up
ip link set vlan100 up
ip link set vlan200 up
ip link set vlan999 up
# Включение маршрутизации
sysctl -w net.ipv4.ip_forward=1
# Проверка
echo "VLAN настроены:"
ip -4 addr show | grep -E "vlan|inet" | grep -v "127.0.0.1"