настройки netplan ubuntu 20.04
Приветсвую у меня есть сервер на нем имеется два сетевых интерфейса один имеет белую статику второй серую статику, так же имеется ряд устройств которые находятся в одном влане с серой статикой и мне нужно что бы эти устройсва стучались исключитлеьно через серый ip.
network: version: 2 ethernets: enp5s0f0: dhcp4: no addresses: [185.123.41.128/30] routes: - to: 0.0.0.0/0 via: 185.123.41.127 nameservers: addresses: [8.8.8.8]
enp5s0f1: dhcp4: no addresses: [192.168.80.250/24] routes: - to: 0.0.0.0/0 via: 192.168.80.80 nameservers: addresses: [8.8.8.8]
# Добавление таблиц маршрутизации и меток routing-policy: - from: 185.123.41.128 table: 100 priority: 100 - from: 192.168.80.250 table: 101 priority: 101
# Добавление правил iptables # Входящие пакеты с IP 185.123.41.128 будут маршрутизироваться через enp5s0f0 post-up: - ip rule add from 185.123.41.128 table 100 - ip route add default via 185.123.41.127 table 100 - iptables -t nat -A POSTROUTING -s 185.123.41.128 -o enp5s0f0 -j MASQUERADE
# Входящие пакеты с IP 192.168.80.250 будут маршрутизироваться через enp5s0f1 - ip rule add from 192.168.80.250 table 101 - ip route add default via 192.168.80.80 table 101 - iptables -t nat -A POSTROUTING -s 192.168.80.250 -o enp5s0f1 -j MASQUERADE
прописал такие настройки, но после netplan applay отдает такую ошибку: /etc/netplan/00-installer-config.yaml:33:5: Invalid YAML: did not find expected '-' indicator: post-up: ^
настройки вроде меняются, но нужного результата я не получаю
1 ответ
Netplan is a utility in Ubuntu that manages network configuration. It uses YAML-based configuration files to define network interfaces and settings. Here's an example of how you can configure network settings using Netplan in Ubuntu 20.04:
-
Open Netplan Configuration File: The main Netplan configuration file is located in the
/etc/netplan/
directory. By default, it's named something like00-installer-config.yaml
or01-network-manager-all.yaml
.Use a text editor (such as
nano
orvi
) with superuser privileges to open the configuration file:bashCopy code
sudo nano /etc/netplan/01-network-manager-all.yaml
-
Configure Network Interface: Here's an example of a basic Netplan configuration for a wired (Ethernet) network interface:
yamlCopy code
network: version: 2 renderer: networkd ethernets: enp0s3: # Change this to your actual interface name dhcp4: true
Replace
enp0s3
with the actual name of your Ethernet interface (you can find the name using theifconfig
orip addr
command). -
Apply Configuration: After editing the Netplan configuration file, save the changes and exit the text editor.
Then, apply the configuration by running:
bashCopy code
sudo netplan apply
-
Restart Networking: If you've made significant changes to network configurations, consider restarting the networking service to ensure the changes take effect:
bashCopy code
sudo systemctl restart systemd-networkd
-
Check Network Status: To check the status of your network interfaces and configurations, you can use commands like:
ip addr show
: Displays information about network interfaces.ip route show
: Displays the routing table.systemctl status systemd-networkd
: Checks the status of the networking service.