从Ubuntu主机访问在来宾KVM上运行的Docker容器应用

时间:2018-09-17 21:25:30

标签: docker ubuntu-16.04 virtualization kvm windows-server-2016

我的设置是:

  1. 在无头设备(主机)上运行的Ubuntu 16.04服务器
  2. 在主机顶部运行的Windows Server 2016 KVM(来宾)。
  3. 主机和访客之间的网络类型是NAT。整个事情都在公司后面。代理。
  4. 主机正在从公司网关获取静态IP。

在KVM上,我正在运行docker容器应用程序,该应用程序从内部和外部在端口15417上侦听(docker ps:0.0.0.0:15417-> 15417 / tcp) 容器IP地址为192.168.122.35,而来自NAT的KVM IP地址为:192.168.122.82

在docker容器上运行的应用公开了一个API,该API应该从kvm_ip:15417 / api上的linux主机进行访问

事实:

  1. 在Windows固件上打开端口15417进行入站TCP连接。
  2. 从主机到kvm IP(192.168.122.82)的ping操作正常
  3. 可以在192.168.122.35:15417/api上访问应用程序api
  4. docker日志,显示日志,以便应用程序启动并运行。

问题:

  1. 无法从localhost:15417 / api或127.0.0.1:15417/api上的KVM访问API,我得到的curl localhost:15417/api响应是:
  

目标主机无法访问

  1. 无法从主机上的192.168.122.82:15417/api(KVM_IP)访问API,curl 192.168.122.82:15417/api上的响应与kvm powershell上的响应相同。
  2. 没有从主机到192.168.122.82 15417的telnet或从来宾到telnet 127.0.0.1 15417的telnet,而到RDP(3389)或vnc(5900)等其他端口的telnet工作正常,这意味着这些端口都已打开。

这是我的主机“ ifconfig”:

br0       Link encap:Ethernet  HWaddr 00:90:0b:67:e3:4c
      inet addr:172.28.69.86  Bcast:172.28.69.87  Mask:255.255.255.248
      inet6 addr: fe80::290:bff:fe67:e34c/64 Scope:Link
      UP BROADCAST MULTICAST  MTU:1500  Metric:1
      RX packets:597 errors:0 dropped:0 overruns:0 frame:0
      TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000
      RX bytes:89816 (89.8 KB)  TX bytes:648 (648.0 B)

br-ef89294aca4b Link encap:Ethernet  HWaddr 02:42:3d:dc:07:b1
      inet addr:172.20.0.1  Bcast:172.20.255.255  Mask:255.255.0.0
      inet6 addr: fe80::42:3dff:fedc:7b1/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:80271 errors:0 dropped:0 overruns:0 frame:0
      TX packets:51030 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0
      RX bytes:98712118 (98.7 MB)  TX bytes:4318906 (4.3 MB)

docker0   Link encap:Ethernet  HWaddr 02:42:ea:f9:4a:a6
      inet addr:172.17.0.1  Bcast:172.17.255.255  Mask:255.255.0.0
      UP BROADCAST MULTICAST  MTU:1500  Metric:1
      RX packets:0 errors:0 dropped:0 overruns:0 frame:0
      TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0
      RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

enp2s0    Link encap:Ethernet  HWaddr 00:90:0b:67:e3:4b
      inet addr:172.28.69.84  Bcast:172.28.69.255  

遮罩:255.255.255.248           inet6 addr:fe80 :: 290:bff:fe67:e34b / 64范围:链接           UP广播多播MTU:1500公制:1           RX数据包:43437560错误:0掉落:0超限:0帧:0           TX数据包:28285024错误:0掉落:0超限:0运营商:0           碰撞:0 txqueuelen:1000           接收字节:50031414909(50.0 GB)发送字节:5610346118(5.6 GB)           内存:df800000-df8fffff

enp3s0    Link encap:Ethernet  HWaddr 00:90:0b:67:e3:4c
      UP BROADCAST MULTICAST  MTU:1500  Metric:1
      RX packets:0 errors:0 dropped:0 overruns:0 frame:0
      TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000
      RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
      Memory:dfe00000-dfe7ffff

lo        Link encap:Local Loopback
      inet addr:127.0.0.1  Mask:255.0.0.0
      inet6 addr: ::1/128 Scope:Host
      UP LOOPBACK RUNNING  MTU:65536  Metric:1
      RX packets:2528921 errors:0 dropped:0 overruns:0 frame:0
      TX packets:2528921 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1
      RX bytes:3180228446 (3.1 GB)  TX bytes:3180228446 (3.1 GB)

veth38444b2 Link encap:Ethernet  HWaddr b2:43:0f:a2:0e:34
      inet6 addr: fe80::b043:fff:fea2:e34/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:24 errors:0 dropped:0 overruns:0 frame:0
      TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0
      RX bytes:1728 (1.7 KB)  TX bytes:816 (816.0 B)

veth55c3534 Link encap:Ethernet  HWaddr 52:e3:a5:c0:54:84
      inet6 addr: fe80::50e3:a5ff:fec0:5484/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:4329603 errors:0 dropped:0 overruns:0 frame:0
      TX packets:4447953 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0
      RX bytes:1018418030 (1.0 GB)  TX bytes:1107337021 (1.1 GB)

vetha9c713b Link encap:Ethernet  HWaddr 02:96:67:47:1c:72
      inet6 addr: fe80::96:67ff:fe47:1c72/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:175785 errors:0 dropped:0 overruns:0 frame:0
      TX packets:124544 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0
      RX bytes:45484242 (45.4 MB)  TX bytes:22613601 (22.6 MB)

vethcfde2a8 Link encap:Ethernet  HWaddr ca:ab:04:da:b6:98
      inet6 addr: fe80::c8ab:4ff:feda:b698/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:990878 errors:0 dropped:0 overruns:0 frame:0
      TX packets:1367424 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0
      RX bytes:212266708 (212.2 MB)  TX bytes:287696403 (287.6 MB)

vethd045150 Link encap:Ethernet  HWaddr 42:b0:0f:df:b3:ec
      inet6 addr: fe80::40b0:fff:fedf:b3ec/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:431061 errors:0 dropped:0 overruns:0 frame:0
      TX packets:423829 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0
      RX bytes:102897883 (102.8 MB)  TX bytes:91172674 (91.1 MB)

vethe3e3d6f Link encap:Ethernet  HWaddr 76:21:a7:44:81:7d
      inet6 addr: fe80::7421:a7ff:fe44:817d/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:1598 errors:0 dropped:0 overruns:0 frame:0
      TX packets:1924 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0
      RX bytes:597484 (597.4 KB)  TX bytes:350579 (350.5 KB)

vethf34ccaa Link encap:Ethernet  HWaddr 76:a9:29:e3:b5:2c
      inet6 addr: fe80::74a9:29ff:fee3:b52c/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:2674 errors:0 dropped:0 overruns:0 frame:0
      TX packets:3783 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0
      RX bytes:4805257 (4.8 MB)  TX bytes:689076 (689.0 KB)

virbr0    Link encap:Ethernet  HWaddr 52:54:00:17:94:ca
      inet addr:192.168.122.1  Bcast:192.168.122.255  Mask:255.255.255.0
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:23845306 errors:0 dropped:0 overruns:0 frame:0
      TX packets:31454109 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000
      RX bytes:1454280991 (1.4 GB)  TX bytes:48875445867 (48.8 GB)

vnet0     Link encap:Ethernet  HWaddr fe:54:00:fc:b7:f1
      inet6 addr: fe80::fc54:ff:fefc:b7f1/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:4512098 errors:0 dropped:0 overruns:0 frame:0
      TX packets:4084521 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000
      RX bytes:580069804 (580.0 MB)  TX bytes:2979706156 (2.9 GB)

以及我的KVM(访客)网络默认配置:

<network>
  <name>default</name>
  <uuid>9f80b5ad-b4fa-4c7e-a559-d27c23328347</uuid>
  <forward mode='nat'/>
  <bridge name='virbr0' stp='on' delay='0'/>
  <mac address='52:54:00:17:94:ca'/>
  <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>

最后,KVM网络接口配置为:

<interface type='network'>
  <mac address='52:54:00:fc:b7:f1'/>
  <source network='default' bridge='virbr0'/>
  <target dev='vnet0'/>
  <model type='rtl8139'/>
  <alias name='net0'/>
  <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>

在尝试找出导致我从主机访问KVM上的应用程序中断的原因时,我很挣扎。

0 个答案:

没有答案