putty和互联网连接到CentOS 7主机中的lxc容器

时间:2018-01-22 07:47:37

标签: ssh centos7 lxc internet-connection network-connection

我想在笔记本电脑上创建多台机器,以便我可以尝试分布式编码和软件。

  

我能够在VMWare上为我的Ubuntu设置做到这一点,但我是   无法在VirtualBox 5.1.30上为CentOS7.3做到这一点。

我用静态IP创建了LXC容器。以下是更多细节。

  1. 组件1:运行连接到Internet的Windows 10的笔记本电脑 使用Wifi。
  2. 组件2:带有CentOS7.3网络的VirtualBox 5.1.30 主机设置为"桥接适配器"将混杂模式设置为"允许 所有"
  3. 组件3:CentOS7.3主机,IP 192.168.1.101,网关192.168.1.1。 这台机器可以连接到互联网,也可以连接到LXC 容器。这里没有问题。
  4. 组件4:使用virbr0的LXC容器,IP 192.168.122.211,GATEWAY 192.168.211.1。这台机器可以连接到互联网但我无法从笔记本电脑上ping它。
  5. 组件5:使用LAN,IP的mybr0桥接器的LXC容器 192.168.1.110,GATEWAY 192.168.1.1。这台机器无法连接到互联网,但我可以从Windows操作系统进入它。
  6.   

    我想要一个可以连接LXC容器的配置   从笔记本电脑使用putty或浏览器,容器将拉   来自yum,git等的更新

    以下是机器配置的详细信息。

    1. 组件1:Windows 10 OS Laptop。
    2. Output of ping
      C:\Users\bharat>ping -n 1 192.168.1.1   #GATEWAY
      Pinging 192.168.1.1 with 32 bytes of data:
      Reply from 192.168.1.1: bytes=32 time=2ms TTL=64
      
      C:\Users\bharat>ping -n 1 192.168.1.101   #CentOS7 HOST
      Pinging 192.168.1.101 with 32 bytes of data:
      Reply from 192.168.1.101: bytes=32 time<1ms TTL=64
      
      C:\Users\bharat>ping -n 1 192.168.1.110   #LXC on LAN
      Pinging 192.168.1.110 with 32 bytes of data:
      Reply from 192.168.1.110: bytes=32 time<1ms TTL=64
      
      C:\Users\bharat>ping -n 1 192.168.122.211 #LXC on virbr0
      Pinging 192.168.122.211 with 32 bytes of data:
      Request timed out.
      
           

      2。第3部分:CentOS 7.3主机

      [root@druv ~]# ip a s
      1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
          link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
          inet 127.0.0.1/8 scope host lo
             valid_lft forever preferred_lft forever
          inet6 ::1/128 scope host
             valid_lft forever preferred_lft forever
      2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master mybr0 state UP qlen 1000
          link/ether 08:00:27:72:a3:8b brd ff:ff:ff:ff:ff:ff
      3: mybr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP qlen 1000
          link/ether 08:00:27:72:a3:8b brd ff:ff:ff:ff:ff:ff
          inet 192.168.1.101/24 brd 192.168.1.255 scope global mybr0
             valid_lft forever preferred_lft forever
          inet6 fe80::a00:27ff:fe72:a38b/64 scope link
             valid_lft forever preferred_lft forever
      4: virbr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP qlen 1000
          link/ether 52:54:00:1e:1a:43 brd ff:ff:ff:ff:ff:ff
          inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
             valid_lft forever preferred_lft forever
      5: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN qlen 1000
          link/ether 52:54:00:1e:1a:43 brd ff:ff:ff:ff:ff:ff
      7: v-centos-001-e0@if6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master virbr0 state UP qlen 1000
          link/ether fe:50:cc:35:fc:a6 brd ff:ff:ff:ff:ff:ff link-netnsid 0
          inet6 fe80::fc50:ccff:fe35:fca6/64 scope link
             valid_lft forever preferred_lft forever
      9: v-centos-002-e0@if8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master mybr0 state UP qlen 1000
          link/ether fe:b8:55:66:bd:bf brd ff:ff:ff:ff:ff:ff link-netnsid 1
          inet6 fe80::fcb8:55ff:fe66:bdbf/64 scope link
             valid_lft forever preferred_lft forever
      [root@druv ~]#
      [root@druv ~]# netstat -rn    #Shows the default Gateway
      Kernel IP routing table
      Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
      0.0.0.0         192.168.1.1     0.0.0.0         UG        0 0          0 mybr0
      192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 mybr0
      192.168.122.0   0.0.0.0         255.255.255.0   U         0 0          0 virbr0
      [root@druv ~]#
      [root@druv ~]# brctl show    #Shows both the bridges are working fine.
      bridge name     bridge id               STP enabled     interfaces
      mybr0           8000.08002772a38b       no              enp0s3
                                                              v-centos-002-e0
      virbr0          8000.5254001e1a43       yes             v-centos-001-e0
                                                              virbr0-nic
      [root@druv ~]#
      
      1. 组件4:带有virbr0网络的centos-001 LXC容器
      2. [root@centos-001 ~]# ip a s
        1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
            link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
            inet 127.0.0.1/8 scope host lo
               valid_lft forever preferred_lft forever
            inet6 ::1/128 scope host
               valid_lft forever preferred_lft forever
        6: eth0@if7: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP qlen 1000
            link/ether fe:0c:7e:e3:6d:12 brd ff:ff:ff:ff:ff:ff link-netnsid 0
            inet 192.168.122.211/24 brd 192.168.122.255 scope global eth0
               valid_lft forever preferred_lft forever
            inet6 fe80::fc0c:7eff:fee3:6d12/64 scope link
               valid_lft forever preferred_lft forever
        [root@centos-001 ~]#
        [root@centos-001 ~]# netstat -rn
        Kernel IP routing table
        Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
        0.0.0.0         192.168.122.1   0.0.0.0         UG        0 0          0 eth0
        169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 eth0
        192.168.122.0   0.0.0.0         255.255.255.0   U         0 0          0 eth0
        [root@centos-001 ~]#
        [root@centos-001 ~]# ping google.com
        PING google.com (216.58.196.78) 56(84) bytes of data.
        64 bytes from bom05s11-in-f14.1e100.net (216.58.196.78): icmp_seq=1 ttl=55 time=4.03 ms
        64 bytes from bom05s11-in-f14.1e100.net (216.58.196.78): icmp_seq=2 ttl=55 time=3.59 ms
        
        --- google.com ping statistics ---
        2 packets transmitted, 2 received, 0% packet loss, time 1003ms
        rtt min/avg/max/mdev = 3.590/3.810/4.031/0.228 ms
        [root@centos-001 ~]#
        
        1. 组件5:LAN上的centos-002 LXC容器
        2. [root@centos-002 ~]# ip a s
          1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
              link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
              inet 127.0.0.1/8 scope host lo
                 valid_lft forever preferred_lft forever
              inet6 ::1/128 scope host
                 valid_lft forever preferred_lft forever
          8: eth0@if9: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP qlen 1000
              link/ether fe:49:cd:61:9e:1d brd ff:ff:ff:ff:ff:ff link-netnsid 0
              inet 192.168.1.110/24 brd 192.168.1.255 scope global eth0
                 valid_lft forever preferred_lft forever
              inet6 fe80::fc49:cdff:fe61:9e1d/64 scope link
                 valid_lft forever preferred_lft forever
          [root@centos-002 ~]#
          [root@centos-002 ~]# netstat -rn   # The default Gateway is of the LAN but can't ping to it.
          Kernel IP routing table
          Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
          0.0.0.0         192.168.1.1     0.0.0.0         UG        0 0          0 eth0
          169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 eth0
          192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 eth0
          [root@centos-002 ~]#
          [root@centos-002 ~]# ping 8.8.8.8
          PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
          From 192.168.1.110 icmp_seq=1 Destination Host Unreachable
          From 192.168.1.110 icmp_seq=2 Destination Host Unreachable
          From 192.168.1.110 icmp_seq=3 Destination Host Unreachable
          From 192.168.1.110 icmp_seq=4 Destination Host Unreachable
          
          --- 8.8.8.8 ping statistics ---
          4 packets transmitted, 0 received, +4 errors, 100% packet loss, time 3001ms
          pipe 4
          [root@centos-002 ~]#
          [root@centos-002 ~]# ping 192.168.1.101
          PING 192.168.1.101 (192.168.1.101) 56(84) bytes of data.
          64 bytes from 192.168.1.101: icmp_seq=1 ttl=64 time=0.391 ms
          64 bytes from 192.168.1.101: icmp_seq=2 ttl=64 time=0.109 ms
          
          --- 192.168.1.101 ping statistics ---
          2 packets transmitted, 2 received, 0% packet loss, time 1001ms
          rtt min/avg/max/mdev = 0.109/0.250/0.391/0.141 ms
          [root@centos-002 ~]#
          [root@centos-002 ~]# ping 192.168.1.1
          PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
          From 192.168.1.110 icmp_seq=1 Destination Host Unreachable
          From 192.168.1.110 icmp_seq=2 Destination Host Unreachable
          From 192.168.1.110 icmp_seq=3 Destination Host Unreachable
          From 192.168.1.110 icmp_seq=4 Destination Host Unreachable
          
          --- 192.168.1.1 ping statistics ---
          5 packets transmitted, 0 received, +4 errors, 100% packet loss, time 4011ms
          pipe 4
          [root@centos-002 ~]#
          

          我曾尝试在主机上禁用防火墙,但这也无济于事。我正在CentOS 7.3中专门尝试这个,因为我想研究一些rpm软件包/软件。

0 个答案:

没有答案
相关问题