• 4


    Prerequisites:

    • CentOS7 virtual machine on Hyper-V

    Now we have a working CentOS7 virtual machine on Hyper-V. Let's configure the network for it, then we can access CentOS from host system (Windows 10) with xshell or MobaXterm, and enable CentOS access to Internet.

    Setup Internal network:

    1. Sharing Physical network switch with Vitual switch. 
      Windows Home Button -> Control Panel -> Network and sharing center -> Change adapter settings
      Right click on your Physical network switch which can access to Internet, then select on tab Sharing, share the connection with Hyper-V Default virtual switch
       

    2. Configure Hyper-V default switch
      Right click on vEthernet (Default Switch) -> Internet protocal v4(TCP/IPv4) -> Set IP and Subnet mask as below
    3. Configure k8s-master network adapter
      Go back to Hyper-V - > right click on k8s-master -> settings -> Network adapter -> Virtual switch select to Defalut switch
    4. Configure CentOS network adapter
      Start and connect to k8s-master -> enter command: vi /etc/sysconfig/network-scripts/ifcfg-eth0 -> update fields as below

      To summarize the update, below fields will be updated or introduced:

              BOOTPROTO=static
              ONBOOT=yes
              IPADDR=192.168.137.161
              NETMASK=255.255.255.0
              NM_CONTROLLED=no
              GATEWAY=192.168.137.1
              DNS1=192.168.137.1

    5. Restart k8s-master (Here restart network service may not take effect for the change with: systemctl restart network)
    6. After restart k8s-master, check ip details. You will find the static IP is take effected on adapter eth0
      ip addr
    7. Try to access internet from k8s-master, and good it's working as expected

       

    8. Go back to host Windows 10, try ping to k8s-master, working as well.
    9. Now try remote to k8s-master from Host with xshell or MobaXterm. And able to remote no issues.
    10. Now we have a virtual machine which can access from host, and it can access to Internet !
      Remember to apply the same for another machine k8s-node1 from step 3 to step 9
    11. Trouble shooting IMPORTANT !
      Once the network setup correctly at first place, and network working as expected ! However based on my experience, after some network change or HOST machine restart or shutdown, it will cause VM not able to connect internet ! Even you try to restart HOST machine or restart VM, but it's won't fix it. And you verify IP tables on Win 10 Host by running command: route print, you even can see the vEthernet IP 192.168.137.1 onlink without any issue, on the other hand your VM network setting also correctly. What we should do to get this fixed ? Well, easy:
      From your Win 10 Host, go to Control Panel -> Change adapter settings (as step 1), disable the sharing, then enable the sharing again !
  • 相关阅读:
    list集合对象日期排序
    Mongodb模糊,or,and查询和日期查询
    单例模式
    代理模式
    抽象工厂模式
    java 除数运算获取两位小数
    html5 canvas 使用总结
    @MockBean 注解后 bean成员对象为 null?
    Java8 BiFunction 简单用用
    如何正确安装Ubuntu
  • 原文地址:https://www.cnblogs.com/waynewei/p/14851944.html
Copyright © 2020-2023  润新知