On a Linux laptop, I want to give access to locally hosted VM (kvm) from LAN.

I'd like to do DNAT to VM.


client  <-- LAN --> host <-- bridge --> guest


  • wlp3s0:
  • br0:
  • net.ipv4.ip_forward = 1
  • Bridge:
# bridge -d link
16: vnet5: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 master br0 state forwarding priority 32 cost 100 
    hairpin off guard off root_block off fastleave off learning on flood on mcast_flood on bcast_flood on mcast_router 1 mcast_to_unicast off neigh_suppress off vlan_tunnel off isolated off locked off
  • Routing:
default via dev wlp3s0 proto dhcp src metric 600 dev wlp3s0 proto kernel scope link src metric 600 dev br0
  • Netfilter rule extract:
table inet filter {
  chain forward {
    type filter hook forward priority 0; policy drop;
    ct state established,related counter accept
    ct state invalid counter drop
    tcp dport 8080 counter log prefix "forward: " accept

table ip nat {
  chain prerouting {
    type nat hook prerouting priority dstnat
    tcp dport 8080 counter log prefix "dnat: " dnat to
  chain postrouting {
    type nat hook postrouting priority srcnat
    iifname br0 oifname wlp3s0 counter masquerade


  • enp1s0:
  • Routes:
default via dev enp1s0 proto dhcp src metric 100 dev enp1s0 proto kernel scope link src metric 100
  • No firewall
  • Service listening on


  • address:

Tests OK

  • Ping from host to guest (ping -c 1
  • Curl from host to guest service (curl -q
  • Access to internet from guest (curl -q https://serverfault.com)


Calling service from another client on LAN (curl -q does not reach the guest.

Tcpdump on wlp3s0 interface of the host:

11:10:54.063354 IP > Flags [S], seq 2985774913, win 64240, options [mss 1460,sackOK,TS val 525180874 ecr 0,nop,wscale 7], length 0
11:10:54.063388 IP > Flags [S], seq 2985774913, win 64240, options [mss 1460,sackOK,TS val 525180874 ecr 0,nop,wscale 7], length 0

(I see "forward" and "dnat" lines in syslog when forwarding and filtering are triggered.)

I see no packet on br0 interface of the host.

Please note the second line of tcpdump. Destination is rewritten, but on the wlp3s0 interface!

I also tested with wired Ethernet instead of Wifi: exactly same behavior.

Why the packet is not routed to bridge through br0?

Any hint appreciated!

  • I am not familiar with 'netfilter' , I guest in the rule 'tcp dport 8080 xxx dnat yyy' we may limit the 1st '8080' on 'enp1s0 or' ? And we also have some alternatives like 'nohup socat TCP-LISTEN:8080,bind=,reuseaddr,fork tcp: &' :) Mar 20 at 2:11
  • socat would be hard to maintain and scale, but I will try. It may help to troubleshoot! I don't understand the limit you suggest.
    – Benoit
    Mar 20 at 8:19
  • I did not test socat but ssh -L <wifi_ip>:8080: [email protected], which is functional workaround.
    – Benoit
    Mar 20 at 18:12
  • If you want to access the VM from the LAN is there any reason why you don't simply bridge it? No routing required. No firewall masquerade/DNAT/SNAT required. It just works Mar 20 at 20:09
  • 1
    You cannot simply bridge a wireless interface. See here or here. It's possible if client and AP enables "4-address" mode (not tested). Another option is to translate layer-2 addresses (ebtables or nft bridge table). I found it simpler to configure layer-3 NAT.
    – Benoit
    Mar 20 at 20:32

1 Answer 1


There is a typo in the prerouting rule. dnat to instead of dnat to

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .