VMs different networks with same source IP address.

Issues related to configuring your network
Post Reply
g2morales
Posts: 2
Joined: 2017/10/10 03:27:17

VMs different networks with same source IP address.

Post by g2morales » 2017/10/10 15:36:41

I am trying to figure out what is going on with my setup: I have a physical host with CentOS7 that is hosting two VM using QEMU/KVM, both are supposed to be on different networks (one is 192.168.100.0/24 thru virbr1 and the other is 192.168.122.0/24 thru virbr0). Both are configured as NAT.

I have enabled in the physical host this instruction net.ipv4.ip_forward=1 on /etc/sysctl.conf. My objective is that i try to connect from one host (192.168.100.100) to another (192.168.122.101). As you can see on the screenshot, looks like when I'm doing FTP to the host on the 122 network, the source is coming as 192.168.122.1 but i cant figure out why. I know that NAT will replace the IP source with the gateway, but I'm not sure why its coming out as 192.168.122.1 instead of 192.168.100.1

Can you point me to where the configuration mistake may be coming from? The whole thing is about simulating a connection the host 192.168.122.101 from an outside network (192.168.100.X)

Image

zovs66
Posts: 50
Joined: 2017/09/29 14:55:01

Re: VMs different networks with same source IP address.

Post by zovs66 » 2017/10/18 14:18:37

I am computer programmer and this may or may not help.

My host is a windows box and in my Oracle VirtualBox I created a Host-only Network (Preferences|Network) and then for each of VM's I give them two adapters the first one a NAT adapter so they can get to the internet and the second a Host-only Adapter. So once I have done that and after I have installed or configured ssh and vsftpd from the host I was able to ssh and ftp to each vm and after I turned the firewall off from each vm to each vm.

Also, my vm's ip was 192.168.56.101, 192.168.56.102, 192.168.56.103, etc. and my host is 192.168.56.1

Hope that helps?
Red, Green, Refactor...

User avatar
jlehtone
Posts: 4530
Joined: 2007/12/11 08:17:33
Location: Finland

Re: VMs different networks with same source IP address.

Post by jlehtone » 2017/10/20 07:44:37

Netfilter implements the NAT. Libvirt creates some netfilter rules for each "network" (i.e. virbrX) it manages. The most relevant rules are probably visible with:

Code: Select all

iptables -t nat -S POSTROUTING

Post Reply