VirtualBox Linux virtual machine related

Source: Internet
Author: User
Tags ssh access

Linux virtual machine set to static IP After installing a Linux virtual machine in VirtualBox, the Linux virtual machine defaults to DHCP to automatically surf the network when using NAT, and it uses the NetworkManager service instead of the net. At this point, the current communication network card's MAC address, IP address, and the default route, Gateway, and record this information.
    1. First through Systemctl stop NetworkManager; systemctl disable NetworkManager; to stop and disable NetworkManager services, Then uninstall the NetworkManager package.
    2. Edit/etc/sysconfig/network-script/ifcfg-devname This file, the file contents (MAC address, network card name, IP address, network management needs to be recorded before use) are as follows:
    3. Edit/etc/resolve.conf to add the associated DNS server address, for example: NameServer 114.114.114.114
    4. Execute systemctl start network;systemctl Enable network to open and start the Network service by default.
host SSH access to Linux virtual machine
    1. Virtual machine Internet access is set to NAT mode, then use command IP addr in linux virtual machine to view current network card
    2. Edit the configuration file for the NIC in the/etc/sysconfig/network-scripts directory and set the Onboot to Yes
    3. Port forwarding is set in VirtualBox, such as. The host can then access the 127.0.0.1 directly via the SSH client, directly accessing the Linux virtual machine.
    4. When setting up port forwarding, be sure to pay attention to the protocol. For example, SSH is tcp:22 tftp is udp:69, if the TFTP is set to tcp:69, the host is anyway unable to access the virtual machine tftp.

If the external host has the need to access the virtual machine, it is necessary to change the host IP in the port mapping from 127.0.0.1 to Cheng the host's IP (this time the host IP should be fixed, or the external host will not be able to access the host), such as. You also need to configure the firewall rules on the Win7 , as follows:

Inbound rule Settings First select Inbound rules, then create a new rule, select the port, and then next step, select TCP to select a specific port and then enter the port, if there are multiple ports that need to be separated by commas for example: 88,8080 The third step is to allow the fourth step to select the scope of the application rule Fifth step Into the rule name

With the above configuration, the external host accesses the host's 22 port directly, and is actually the 22 port on the virtual machine being accessed.

host and virtual machine Create shared Folders
  1. The relevant software is then automatically mounted to the optical drive in VirtualBox.
  2. Perform mount/dev/cdrom/mnt to mount the optical drive to the system/mnt directory
  3. Be sure to install DKMS before installing the Linux Guest additions. If DKMS isn't available or not installed, the guest kernel modules would need to be recreated manually whenever the guest      Kernel is updated using the command rcvboxadd setup as root.

  4. Execute the file with the suffix run (Root permission), install the Enhancement tool
  5. After the installation is complete, restart the system.
  6. Then add the shared folder in the virtual machine settings (the folder name is best in English), for example: MyShare
  7. Execute mount-t vboxsf myshare/mnt in the virtual machine to mount the shared folder to the/mnt directory
  8. Thenadd the above statement to the/etc/rc.d/rc.lo Cal to enable it to execute, and then give rc.local executable permissions.
Common scripts under Windows: (Note that the IF statement in the Bat command under Windows does not wrap with subsequent statements, otherwise a syntax error is prompted) : Begin
@echo, enter the action you want to perform:
@echo "0: Start putty"
@echo "1: Start Centos7"
@echo "2: Close Centos7"

@set/P input=
@if%input% = = 0 C:\Users\sxhlinux\Desktop\putty.exe-load mystation
@if "%input%" = = "1" vboxmanage STARTVM CentOS--type Headless
@if "%input%" = = "2" vboxmanage CONTROLVM CentOS savestate

VirtualBox Linux virtual machine related

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.