简体   繁体   中英

Bridged linux networking and virtualization

I have Linux host with libvirt/kvm virtualization, VMs needs the "real" static IP addresses, so I decided to setup bridged network. I make br0 on the host and in the VMs properties I set source device: Host device vnet0(Bridge 'br0').

For example, my br0 have ip 192.168.1.1 and one of the VM have 192.168.1.5

Everything works pretty well, but then I connect to the virtual machine, the client address detects as 192.168.1.1. Also, all the HTTP requests comes from 192.168.1.1.

Q : Is it my mistake, some sort of misconfiguration? How can VM get the real IPs of the clients?

Let me try to answer based on what i infer from your question:

Since you want to assign routable IP addresses to the VMs,

Option 1: Add the host physical ethernet interface to the vswitch (aka vswitch uplink). Further, for all the VM ethernet interface, assign IP address in the same subnet in which the physical ethernet interface's IP belongs. Alternatively, if DHCP server is running in the same broadcast domain (subnet), the VMs would get the IP from the DHCP server if the interfaces are configured to get IP via DHCP

Option 2: Create the vswitch and assign XYZ1 IP to the vswitch (br0). Also enable IP forwarding in the host. Now you can assign IPs from the same subnet to the VM ethernet interfaces. Alternatively, you can run DHCP (eg DNSmasq) on br0 and assign IPs to the VM interfaces

Is it my mistake, some sort of misconfiguration? How can VM get the real IPs of the clients?

If you are connecting from the host on which your vms are running, then they are getting the real IP address. Your host shares a network (192.168.1.0/24 or similar, apparently) with the virtual machines. When you connect to your virtual machines from your host , the source address if 192.168.1.1.

If you are connecting from elsewhere on your network, you would need to provide us with more details of your configuration.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM