Description
Azure NIC IP forwarding lets an interface receive packets addressed elsewhere and send packets with a source address other than its own. Forwarding traffic also requires routes and software on the VM.
Potential impact
Traffic routed through an ordinary VM can take an unintended path if the VM forwards it.
Remediation
Set ip_forwarding_enabled = false on ordinary VMs. On a network appliance such as a firewall, enable it only on NICs that need to forward traffic. Verify the effective routes and access rules for that traffic.
Examples
Both configurations retain the same subnet and dynamic private IP allocation. Only the NIC’s forwarding setting changes.
Before
hcl
resource "azurerm_network_interface" "example" {
name = "example-nic"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
ip_configuration {
name = "internal"
subnet_id = azurerm_subnet.example.id
private_ip_address_allocation = "Dynamic"
}
ip_forwarding_enabled = true
}
After
hcl
resource "azurerm_network_interface" "example" {
name = "example-nic"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
ip_configuration {
name = "internal"
subnet_id = azurerm_subnet.example.id
private_ip_address_allocation = "Dynamic"
}
ip_forwarding_enabled = false
}