4 - Configure Internal network connectivity for Virtual machine
Prerequisites:
- CentOS7 virtual machine on Hyper-V
Now we have a working CentOS7 virtual machine on Hyper-V. Let‘s configure the Internal network for it, then we can access CentOS from host system (Windows 10) with xshell or MobaXterm.
Check network details from local host Windows 10, which Virtual switch will be followed with. Launch CMD then enter ipconfig.
My local host will be like:
IPv4 address: 192.168.0.113
Subnet mask: 255.255.255.0
Setup Internal network:
- Create Internal Virtual switch from Hyper-V. Click on Virtual Switch Manager
- On new prompt Virtual switch manager window, highlight New virtual network switch, and select with Internal, then click on Create Virtual Switch
-
From next creation screen, enter vitual switch name as Internal-VM-Switch (What name you like will be fine), select to option Internal network, then click on OK
-
Config IP for Internal-VM-Switch
Once creasted a virtual network switch on Hyper-V, you can see it from network options and sharing from Control Panel
Windows Home Button -> Control Panel -> Network and sharing center -> Change adapter settings - Update virtual switch IP to align with Host machine ( Windows 10 )
Right click on Internal virtual switch -> Properties -> highlight Internet protocol version 4(TCP/IP) -> Properties -> Setup IP and Subnet mask to align with local host Windows 10 -> click OK
Note: My local host IPv4 range is 192.168.0.113, so the range will be 192.168.0.xxx, here virtual switch IP put up one different with host IP will be fine. Then put up with same subnet mask 255.255.255.0 - Now we have Done create Virtual network switch and configure from Hyper-V
- Configure network for CentOS, before that, make sure you have shutdown CentOS
- Go back to Hyper-V, right click on k8s-master -> settings -> highlight Network Adapter -> Virtual switch make selection to the one we just created Internal-VM-Switch -> click on Apply
- Now Start and Connect to vitual machine k8s-master again, login with root user
- Config network adapter, enter below command and edit accordingly
vi /etc/sysconfig/network-scripts/ifcfg-eth0To sumarrize update/add below fields:
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.0.161
NETMASK=255.255.255.0
GATEWAY=192.168.0.1
DNS1=192.168.0.1
BROADCAST=192.168.0.255 - Save above update and quit, enter below command restart network service, then check network details
systemctl restart network
ip addr - Now try to ping this CentOS from local host ( Windows 10 ), it‘s working perfectly!
- Next connect to CentOS with xshell or MobaXterm, i go with MobaXtern Community Edition since it‘s FREE
- So far all good. Next we will configure external network for CentOS to enable Internet access for it.
Remember to apply the same settings for another virtual machine k8s-node1 from step 7 to 13