1

Yesterday i create windows 2012r2 VM in my ubuntu 16.04 server using KVM. Now i can ping between guest and host and in vice versa. But other system in my LAN not able to ping with the vm (i assign a static ip to my vm).

i used the below anser for forward the port, Alter the iptable rules. Also disable the windows firewall settings

Enable the fort forwarding in ubuntu host. But no progress Other machines will not ping to the VM.

*

root@server2:~# virsh net-dumpxml default
<network>
  <name>default</name>
  <uuid>95e24458-3946-42cf-b013-71637b906842</uuid>
  <forward mode='nat'>
    <nat>
      <port start='1024' end='65535'/>
    </nat>
  </forward>
  <bridge name='virbr0' stp='on' delay='0'/>
  <mac address='52:54:00:fd:24:95'/>
  <ip address='192.168.122.1' netmask='255.255.255.0'>
    <dhcp>
      <range start='192.168.122.2' end='192.168.122.254'/>
    </dhcp>
  </ip>
</network>

*

root@server2:~# iptables -L Chain INPUT (policy ACCEPT) target
prot opt source destination ACCEPT udp -- anywhere anywhere udp dpt:domain ACCEPT tcp -- anywhere
anywhere tcp dpt:domain ACCEPT udp -- anywhere
anywhere udp dpt:bootps ACCEPT tcp -- anywhere
anywhere tcp dpt:bootps

Chain FORWARD (policy ACCEPT) target prot opt source
destination ACCEPT all -- anywhere 192.168.122.0/24 ctstate RELATED,ESTABLISHED ACCEPT all -- 192.168.122.0/24
anywhere ACCEPT all -- anywhere anywhere REJECT
all -- anywhere anywhere reject-with icmp-port-unreachable REJECT all -- anywhere
anywhere reject-with icmp-port-unreachable ACCEPT all -- anywhere 192.168.122.0/24 state NEW,RELATED,ESTABLISHED ACCEPT all -- anywhere
anywhere state RELATED,ESTABLISHED ACCEPT all -- anywhere anywhere ACCEPT tcp -- anywhere
192.168.122.196 tcp dpt:ssh state NEW DROP all -- anywhere anywhere

Chain OUTPUT (policy ACCEPT) target prot opt source
destination ACCEPT udp -- anywhere anywhere
udp dpt:bootpc

root@server2:~#

Any mistake please advice. I am new to this enviorment .Any one please help.

user3789039
  • 89
  • 1
  • 7

2 Answers2

1

I have same question some time i found this post helpful.

Forwarding ports to guests in libvirt / KVM

Hope it will help you.

Net Runner
  • 5,626
  • 11
  • 29
  • As a new bie i have some doubts . Port 80 is used as the guest port and port 22 is used as the host's port ..? – user3789039 Jan 04 '17 at 12:41
  • All things are set well. but not able to ping from other systems in my lan to the windows 2012 r2 Vm in kvm. I disabled the firewall on the windows , No progress, While ping from other systems it will not shows any "host un reacheable" or time out error. I am stuck on it. No idea for what to do. – user3789039 Jan 06 '17 at 09:18
  • hi just make an edit please look into the question. – user3789039 Jan 06 '17 at 12:33
1

It sounds as though you want the VM to be directly on the network rather than behind NAT?

In that case, create a new network that bridges your KVM host's network interface and attach the VM there.

MikeyB
  • 38,725
  • 10
  • 102
  • 186