


I had to connect 2 windows servers and put them in the same domain and adding server 2 on server 1. But they are connected by default? i just assumed they are both connected to the host for internet but aren't connected to each other in a network. I'm not sure how that exactly works because my knowledge in networking is a bit lacking. my teacher said it had to be connected through NAT so it sounds right. i will try adding them just with the default NAT settings when I'm home(I'm in the bus now going home).alamahant wrote:Kvm by default uses NAT networking.
You need qemu, libvirt and virt-manager.
So if you just create 2 vms they will --by default be on the same NAT network.
What exactly is your assignment?
Create two vms in two different NAT networks and being able to ping each other?
Can you plz be a bit more specific?



Told you not to use bridges in what scope?My teacher told me not to use bridges

It's actually a funny thing because the teachers teach you how to do it in VMware and the school uses that but the book we use actually uses hyperV.I bet he meant inside your windows machines. It's kinda implied by the context, since you're using qemu to do a vmware exercise... It tells me it's about windows guests and not about vmware.
You can not bridge bridges.i guess it would work if I give vm 1 internet through NAT and connecting vm 1 with 2 using a bridge
Code: Select all
iptables -t nat -I POSTROUTING 1 -o virbr0 -j MASQUERADE
iptables -t nat -I POSTROUTING 1 -o virbr1 -j MASQUERADE
iptables -t nat -I POSTROUTING 1 -s 192.168.122.0/24 -d 10.1.2.0/24 -j ACCEPT
iptables -t nat -I POSTROUTING 1 -d 192.168.122.0/24 -s 10.1.2.0/24 -j ACCEPT
iptables -I FORWARD 1 -d 192.168.122.0/24 -s 10.1.2.0/24 -j ACCEPT
iptables -I FORWARD 1 -s 192.168.122.0/24 -d 10.1.2.0/24 -j ACCEPT
Code: Select all
sysctl -a | grep forward
Code: Select all
net.ipv4.ip_forward = 1
Code: Select all
echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.d/90-ip-forward.conf
sysctl -p /etc/sysctl.d/90-ip-forward.conf


virbr0 is created automatically by libvirt for its default NAT network.I have created virbr0 but when i add the cards to the vm and start it the bridges don't seem to have an ip

oh I see, do I have to use the default settings or is there anything j should change because it looks like I can forward it to "any physical device" or "physical device"(I assume a specific one)alamahant wrote:virbr0 is created automatically by libvirt for its default NAT network.I have created virbr0 but when i add the cards to the vm and start it the bridges don't seem to have an ip
You dont need to create it.
You only need to create a second NAT network from virt-manager UI->edit->connection details-->networks.
vnet0 vnet1 and vnet2 are slaves to the bridges created by libvirt.Its the ifaces that inside the VM will appear as eth0 eth1 etc
Meaning?oh I see, do I have to use the default settings or is there anything j should change because it looks like I can forward it to "any physical device" or "physical device"(I assume a specific one)
Code: Select all
Forward to --> "Any physical device"
Mode --> NAT
Ipv4 configuration --> create your network here.You can accept the default given to you by virt-manager or you can change it also.
Ipv6 configuration --> leave it as it is.Disabled
Code: Select all
ip a

Which bridge?I added the new created network and the bridge on both VMs and it looks like progress
I suppose the virbr1 was just created no?When you created your new NAT network no?8: virbr0: <BROADCAST,MULTICAST> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 52:54:00:39:aa:f0 brd ff:ff:ff:ff:ff:ff
16: virbr1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 52:54:00:97:2b:7f brd ff:ff:ff:ff:ff:ff
inet 192.168.112.1/24 brd 192.168.112.255 scope global virbr1


i tried it but when i ping with vm 1 to 2 it times out but when i ping from 2 to 1 it tells me "reply from 10.10.10.3: destination host unreachable" so it looks like vm 1 is having problems pinging vm 2. By creating the bridge i used "nmtui" and changed the ipv4 configuration to automatic and added "10.10.10.0/24" as ip and "10.10.10.1" as default gateway, which now im typing this i realised there's no router in that path so after this i'll try removing the gateway but i don't think it will make much difference,NeddySeagoon wrote:Taigo,
Leave the defaults alone. They work and you may want to use the default network to fix things.
Make a new bridge on the host, call it br0 so you know its not being managed by virt-manager.
Add a second network card to each VM and connect it to br0.
That's the two VMs connected together.
Think of a private IP range that you don't use yet. 10.10.10.0/24 will do.
Inside each VM, on the interface connected to br0, assign static IPs from the 10.10.10.0/24 subnet.
They must be unique. say 10.10.10.a/24 and 10.10.10.b/24 you pick a and b. You must not use 0 or 255 by anything in between is good.
Ping 10.10.10.a from 10.10.10.b and vice versa is expected to work.
br0 is a bridge with two ports, so its just like an Ethernet cable joint.
Now you have a private network between the VMs and the 192.168.122.0/24 that goes between the VMs and the host with NAT.
If the ping 10.10.10.a works, remove the 192.168.122.0/24 IP address from VM2.
Now it can only connect to VM1 via the bridge. Ping should still work.