# Ethernet интерфейсы в VyOS

> Настройка Ethernet интерфейсов в VyOS: IP адресация, MTU, VLAN, hardware offloading, speed/duplex и мониторинг состояния портов для Yandex Cloud и VK Cloud

Source: https://opennix.org/docs/vyos/interfaces/vyos-ethernet/



Ethernet интерфейсы являются основным типом физических сетевых интерфейсов в VyOS.

## Базовая конфигурация

### IP-адресация

Статический IPv4 адрес:
```
set interfaces ethernet eth0 address 192.168.1.1/24
```

Статический IPv6 адрес:
```
set interfaces ethernet eth0 address 2001:db8::1/64
```

Множественные адреса:
```
set interfaces ethernet eth0 address 192.168.1.1/24
set interfaces ethernet eth0 address 192.168.2.1/24
set interfaces ethernet eth0 address 2001:db8::1/64
```

### DHCP клиент

DHCPv4:
```
set interfaces ethernet eth0 address dhcp
```

DHCPv6:
```
set interfaces ethernet eth0 address dhcpv6
```

### Описание интерфейса

```
set interfaces ethernet eth0 description 'Primary LAN Interface'
```

### MAC-адрес

Изменение MAC-адреса:
```
set interfaces ethernet eth0 mac '00:50:56:00:00:01'
```

## Физические параметры

### Скорость и дуплекс

Автоматическое определение (по умолчанию):
```
set interfaces ethernet eth0 speed auto
set interfaces ethernet eth0 duplex auto
```

Фиксированные значения:
```
set interfaces ethernet eth0 speed 1000
set interfaces ethernet eth0 duplex full
```

Доступные скорости:
- `10` - 10 Mbps
- `100` - 100 Mbps
- `1000` - 1 Gbps
- `2500` - 2.5 Gbps
- `5000` - 5 Gbps
- `10000` - 10 Gbps
- `25000` - 25 Gbps
- `40000` - 40 Gbps
- `50000` - 50 Gbps
- `100000` - 100 Gbps
- `auto` - автоопределение

Режимы дуплекса:
- `half` - полудуплекс
- `full` - полный дуплекс
- `auto` - автоопределение

### MTU (Maximum Transmission Unit)

```
set interfaces ethernet eth0 mtu 1500
```

Типичные значения MTU:
- `1500` - стандартный Ethernet
- `9000` - Jumbo frames (требует поддержки оборудования)
- `1492` - для PPPoE (учитывает 8-байтовый оверхед)

## Flow Control

Управление потоком данных для предотвращения перегрузки:

```
set interfaces ethernet eth0 flow-control enable
```

## Offloading (аппаратное ускорение)

### Generic Receive Offload (GRO)

```
set interfaces ethernet eth0 offload gro
```

### Generic Segmentation Offload (GSO)

```
set interfaces ethernet eth0 offload gso
```

### Large Receive Offload (LRO)

```
set interfaces ethernet eth0 offload lro
```

### Scatter-Gather (SG)

```
set interfaces ethernet eth0 offload sg
```

### TCP Segmentation Offload (TSO)

```
set interfaces ethernet eth0 offload tso
```

### UDP Fragmentation Offload (UFO)

```
set interfaces ethernet eth0 offload ufo
```

**Примечание**: Offload функции могут улучшить производительность, но в некоторых случаях могут вызывать проблемы с определенными типами трафика или при использовании туннелей.

## Ring Buffer

Настройка размера кольцевых буферов для оптимизации производительности:

```
set interfaces ethernet eth0 ring-buffer rx 512
set interfaces ethernet eth0 ring-buffer tx 512
```

Увеличение размера буферов может помочь при обработке высоких нагрузок.

## VLAN (802.1Q)

### Создание VLAN интерфейса

```
set interfaces ethernet eth0 vif 100 address 192.168.100.1/24
set interfaces ethernet eth0 vif 100 description 'VLAN 100 - Guests'
```

### Множественные VLAN

```
set interfaces ethernet eth0 vif 10 address 192.168.10.1/24
set interfaces ethernet eth0 vif 10 description 'VLAN 10 - Management'

set interfaces ethernet eth0 vif 20 address 192.168.20.1/24
set interfaces ethernet eth0 vif 20 description 'VLAN 20 - Servers'

set interfaces ethernet eth0 vif 30 address 192.168.30.1/24
set interfaces ethernet eth0 vif 30 description 'VLAN 30 - Workstations'
```

### QinQ (802.1ad)

Двойное тегирование VLAN:

```
set interfaces ethernet eth0 vif-s 100 vif-c 200 address 10.0.0.1/24
```

## IPv4 расширенные настройки

### ARP

Таймаут ARP кэша:
```
set interfaces ethernet eth0 ip arp-cache-timeout 3600
```

Proxy ARP:
```
set interfaces ethernet eth0 ip enable-proxy-arp
```

ARP announce:
```
set interfaces ethernet eth0 ip enable-arp-announce
```

ARP ignore:
```
set interfaces ethernet eth0 ip enable-arp-ignore
```

### Source validation

Проверка адреса источника для предотвращения спуфинга:

```
set interfaces ethernet eth0 ip source-validation strict
```

Режимы:
- `strict` - строгий режим (RFC 3704)
- `loose` - мягкий режим
- `disable` - отключено

### Disable forwarding

Отключение пересылки IP на интерфейсе:
```
set interfaces ethernet eth0 ip disable-forwarding
```

## IPv6 расширенные настройки

### Автоконфигурация (SLAAC)

```
set interfaces ethernet eth0 ipv6 address autoconf
```

### Duplicate Address Detection (DAD)

Количество попыток обнаружения дублирующихся адресов:
```
set interfaces ethernet eth0 ipv6 dup-addr-detect-transmits 1
```

### Отключение IPv6

```
set interfaces ethernet eth0 ipv6 disable
```

### Disable forwarding

```
set interfaces ethernet eth0 ipv6 disable-forwarding
```

## DHCP опции

### DHCPv4 клиент

Client ID:
```
set interfaces ethernet eth0 dhcp-options client-id 'my-client-id'
```

Hostname:
```
set interfaces ethernet eth0 dhcp-options host-name 'vyos-router'
```

Vendor class ID:
```
set interfaces ethernet eth0 dhcp-options vendor-class-id 'vyos'
```

Расстояние маршрута по умолчанию:
```
set interfaces ethernet eth0 dhcp-options default-route-distance 210
```

Отклонение маршрута по умолчанию от DHCP:
```
set interfaces ethernet eth0 dhcp-options no-default-route
```

### DHCPv6 клиент

Prefix delegation:
```
set interfaces ethernet eth0 dhcpv6-options pd 0 interface eth1 address 1
set interfaces ethernet eth0 dhcpv6-options pd 0 length 56
```

Rapid commit:
```
set interfaces ethernet eth0 dhcpv6-options rapid-commit
```

Temporary addresses:
```
set interfaces ethernet eth0 dhcpv6-options temporary
```

## Привязка к VRF

```
set interfaces ethernet eth0 vrf RED
```

## Зеркалирование трафика

Входящий трафик:
```
set interfaces ethernet eth0 mirror ingress eth1
```

Исходящий трафик:
```
set interfaces ethernet eth0 mirror egress eth1
```

## Политики трафика (QoS)

```
set interfaces ethernet eth0 traffic-policy in MY-SHAPER
set interfaces ethernet eth0 traffic-policy out MY-LIMITER
```

## Операционные команды

### Просмотр состояния

Все Ethernet интерфейсы:
```
show interfaces ethernet
```

Конкретный интерфейс:
```
show interfaces ethernet eth0
```

Краткая информация:
```
show interfaces ethernet eth0 brief
```

### Физические параметры

```
show interfaces ethernet eth0 physical
```

Вывод включает:
- Скорость и дуплекс
- Auto-negotiation статус
- Состояние канала (link up/down)
- Статистику ошибок

### Счетчики интерфейса

```
show interfaces ethernet eth0 statistics
```

### Сброс счетчиков

```
clear interfaces ethernet eth0 counters
```

### Мониторинг трафика

```
monitor interfaces ethernet eth0 traffic
```

### Capture трафика

```
monitor traffic interface eth0
monitor traffic interface eth0 filter 'port 80'
```

## Примеры конфигурации

### Простой LAN интерфейс

```
set interfaces ethernet eth0 address 192.168.1.1/24
set interfaces ethernet eth0 description 'LAN'
set interfaces ethernet eth0 speed 1000
set interfaces ethernet eth0 duplex full
```

### WAN интерфейс с DHCP

```
set interfaces ethernet eth1 address dhcp
set interfaces ethernet eth1 description 'WAN'
set interfaces ethernet eth1 dhcp-options default-route-distance 210
```

### Trunk порт с множественными VLAN

```
set interfaces ethernet eth2 description 'Trunk to switch'
set interfaces ethernet eth2 mtu 1500

set interfaces ethernet eth2 vif 10 address 192.168.10.1/24
set interfaces ethernet eth2 vif 10 description 'VLAN 10 - Management'

set interfaces ethernet eth2 vif 20 address 192.168.20.1/24
set interfaces ethernet eth2 vif 20 description 'VLAN 20 - Data'

set interfaces ethernet eth2 vif 30 address 192.168.30.1/24
set interfaces ethernet eth2 vif 30 description 'VLAN 30 - Voice'
```

### Интерфейс с jumbo frames

```
set interfaces ethernet eth3 address 10.0.0.1/24
set interfaces ethernet eth3 description 'Storage network'
set interfaces ethernet eth3 mtu 9000
set interfaces ethernet eth3 speed 10000
set interfaces ethernet eth3 duplex full
```

### Dual-stack (IPv4 + IPv6)

```
set interfaces ethernet eth0 address 192.168.1.1/24
set interfaces ethernet eth0 address 2001:db8:1::1/64
set interfaces ethernet eth0 description 'Dual-stack LAN'
set interfaces ethernet eth0 ipv6 dup-addr-detect-transmits 1
```

## Устранение неполадок

### Интерфейс в состоянии down

Проверьте физическое подключение:
```
show interfaces ethernet eth0 physical
```

Проверьте, не отключен ли интерфейс:
```
show interfaces ethernet eth0 | grep disable
```

Включите интерфейс если отключен:
```
delete interfaces ethernet eth0 disable
commit
```

### Проблемы с производительностью

Проверьте ошибки и коллизии:
```
show interfaces ethernet eth0 statistics
```

Попробуйте отключить offload:
```
delete interfaces ethernet eth0 offload
commit
```

Увеличьте ring buffer:
```
set interfaces ethernet eth0 ring-buffer rx 1024
set interfaces ethernet eth0 ring-buffer tx 1024
commit
```

### Auto-negotiation проблемы

Зафиксируйте скорость и дуплекс:
```
set interfaces ethernet eth0 speed 1000
set interfaces ethernet eth0 duplex full
commit
```

### VLAN проблемы

Убедитесь, что родительский интерфейс активен:
```
show interfaces ethernet eth0
```

Проверьте VLAN ID:
```
show interfaces ethernet eth0 vif
```

## Лучшие практики

1. **Используйте описания** для всех интерфейсов и VLAN
2. **Фиксируйте скорость/дуплекс** для критичных соединений
3. **Планируйте MTU** - учитывайте VLAN тег (4 байта)
4. **Тестируйте offload** - может вызывать проблемы с некоторым оборудованием
5. **Мониторьте ошибки** - регулярно проверяйте счетчики
6. **Документируйте VLAN** - используйте понятные описания
7. **Резервируйте конфигурацию** перед изменениями

## Следующие шаги

- [Bridge](/docs/vyos/interfaces/vyos-bridge/) - для создания L2 моста между интерфейсами
- [Bond](/docs/vyos/interfaces/vyos-bond/) - для агрегации Ethernet каналов
- [VLAN](/docs/vyos/interfaces/vyos-vlan/) - детальная настройка VLAN

