I want to bridge y.y.4.36 to my Virtual machine.

I can configure y.y.4.36 on Host. So routing to Host works and I can ping y.y.4.36 from the internet:

$ ifconfig
eno2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet x.x.41.32  netmask  broadcast x.x.41.255
        inet6 fe80::5a20:b1ff:fe07:b375  prefixlen 64  scopeid 0x20<link>
        ether 58:20:b1:07:b3:75  txqueuelen 1000  (Ethernet)
        RX packets 2851252  bytes 241129524 (241.1 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 6722211  bytes 9634863759 (9.6 GB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device memory 0x92c00000-92cfffff  
eno2:0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet y.y.4.36  netmask  broadcast y.y.4.63
        ether 58:20:b1:07:b3:75  txqueuelen 1000  (Ethernet)
        device memory 0x92c00000-92cfffff  
$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface         x.x.41.1         UG    0      0        0 eno2
x.x.41.0   U     0      0        0 eno2

Note there is no default gateway for y.y.4.36.

I can easily set the VM to used Bridged Network, and set its address to y.y.4.36. But how do I make it reachable from the internet?

I expect I have to remove eno2:0 and then some how tell the virtual machine that it should use y.y.4.36 as its address and x.x.41.1 as its default gateway.

But how do I do that?

This does not work:

$ route add -net default gw x.x.41.1
SIOCADDRT: Network is unreachable

because the VM does not have an address on x.x.41.*.


I have made a workaround. On Virtual Machine add another interface with host networking. Then:

ifconfig enp0s8
ifconfig eth0 y.y.4.36 netmask
route add -net default gw
# Force the src address to be y.y.4.36 and not
ip route replace default via dev enp0s8 src y.y.4.36

On Host:

route add -host y.y.4.36 gw

So I route traffic through VirtualBox's host network (

It seems to work, but I believe there is a more conventional way to do accomplish giving y.y.4.36 to the VM.

  • If you can ping y.y.4.36 from the Internet there must be a route to it. Or you're using NAT/Port Forwarding. So on your local network remove the configuration for y.y.4.36 from your host and add it to your bridged VM. What's the problem here?
    – roaima
    Sep 18 at 22:51
  • @roaima What should be the default gw for the VM?
    – Ole Tange
    Sep 19 at 4:45
  • You've said you want to bridge. So the configuration for the VM must be the same as for the host (but obviously a different IP address)
    – roaima
    Sep 19 at 7:11
  • If you want to route, that's a totally different thing
    – roaima
    Sep 19 at 7:12
  • I'm confused: you say "I want to bridge y.y.4.36 to my Virtual machine. I can configure y.y.4.36 on Host" : so the ip is on the host, not on the guest? Do you want that ip instead to be the ip of the guest? (as shown with your guest's eth0) ? It is unclear what you are trying to achieve (what are your LANs, what ip(s) should the guest have, what ip(s) should the host have). What subnets for all the LANs (you have some and some Sep 19 at 7:18

1 Answer 1


If I understand correctly:

Your host is x.x.41.32  netmask (ie, net is x.x.41.0 to x.x.42.255),
 and the gateway (to internet) is x.x.41.1. 
you want to setup a lan for your vms on x.x.4.36 netmask
 (hence on a subnet with 32 ips, x.x.4.32 to x.x.4.63 and that vm is x.x.4.36).

If you want that subnet to access the internet: one of many possibilities (TIMTOWTDI...): one of the vms (for exemple: x.x.4.36? or the host? or another one?) should have 2 interfaces : one in x.x.41.y, one in x.x.4.z, and have routing enabled, and have the default gateway x.x.41.1. The other vms should have as default gateway the x.x.4.z ip of that particular vm (or host).

  • Well, the router on y.y.4.z is not needed when I put y.y.4.36 on Host (as shown with eno2:0). I can access Host just fine using that. I believe the ISP has put y.y.4.36 in their router's ARP table, so it always goes to my server.
    – Ole Tange
    Sep 19 at 16:02

You must log in to answer this question.

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