Tenho uma configuração muito simples que precisa encaminhar tráfego de uma interface WireGuard (wg0) para hosts conectados a uma interface LAN (enp0s25).
[ other LAN host ] <---> enp0s25 [ server ] wg0 <---> [ remote peer]
10.131.12.2 10.131.12.19 10.131.6.6 10.131.6.1
# sysctl -n net.ipv4.ip_forward
1
# nft list ruleset
table inet firewall {
chain postrouting {
type nat hook postrouting priority srcnat; policy accept;
iifname "wg0" masquerade
oifname "wg0" masquerade
}
}
Isso funciona bem. No entanto, eu quero usar VMs, então eu crio uma interface de ponte em /etc/network/interfaces
, com o mesmo endereço mac que enp0s25
:
allow-hotplug enp0s25
iface enp0s25 inet manual
auto br0
iface br0 inet dhcp
bridge_ports enp0s25
hwaddress ether d0:50:99:89:8d:e0
[ other LAN host ] <---> enp0s25/br0 [ server ] wg0 <---> [ remote peer]
10.131.12.2 10.131.12.19 10.131.6.6 10.131.6.1
Agora, só consigo acessar a máquina em si wg0
, e não qualquer outra máquina na LAN.
tcpdump mostra (descrições adicionadas aos endereços IP para maior clareza):
# tcpdump -i wg0 icmp
11:48:35.968486 IP 10.131.6.1 (remote wg peer) > 10.131.12.2 (other LAN host): ICMP echo request, id 18176, seq 1072, length 64
11:48:37.049028 IP 10.131.6.1 (remote wg peer) > 10.131.12.2 (other LAN host): ICMP echo request, id 18176, seq 1073, length 64
11:48:37.966377 IP 10.131.6.1 (remote wg peer) > 10.131.12.2 (other LAN host): ICMP echo request, id 18176, seq 1074, length 64
# tcpdump -i enp0s25 icmp
11:48:35.968513 IP 10.131.12.19 (this host) > 10.131.12.2 (other LAN host): ICMP echo request, id 18176, seq 1072, length 64
11:48:35.968752 IP 10.131.12.2 (other LAN host) > 10.131.12.19 (this host): ICMP echo reply, id 18176, seq 1072, length 64
11:48:37.049057 IP 10.131.12.19 (this host) > 10.131.12.2 (other LAN host): ICMP echo request, id 18176, seq 1073, length 64
11:48:37.049300 IP 10.131.12.2 (other LAN host) > 10.131.12.19 (this host): ICMP echo reply, id 18176, seq 1073, length 64
11:48:37.966399 IP 10.131.12.19 (this host) > 10.131.12.2 (other LAN host): ICMP echo request, id 18176, seq 1074, length 64
As solicitações estão indo do host WG remoto para o outro host LAN e retornando ao servidor, mas não conseguem retornar ao host WG remoto por algum motivo.
O que há de diferente em uma interface de ponte que interrompe essa configuração de encaminhamento?
Adicionei algumas regras de registro para tentar descobrir o caminho através do nftables. A linha vermelha é a solicitação de eco ICMP, a linha azul é a resposta de eco. Parece "desaparecer" no estágio de pré-roteamento inet, não aparece no gancho de entrada ou no gancho de encaminhamento.