This is what VPS does.

Source: Internet
Author: User
Tags virtual private server
Article title: this is what VPS does. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
VPS is short for Virtual Private Server (also known as VDS). it means a Virtual Private Server, that is, running several independent operating systems simultaneously on a Server (here referred to as FreeBSD ), what is the purpose? I will not describe it in detail here. imagine a few users share a server, which is completely independent of each other. everyone has the root permission ....... In FreeBSD, VPS is usually implemented by Jail (it is said that there are specialized commercial software but it is not discussed here). the specific steps are briefly described below.
  
The steps for using Jail to implement VPS in FreeBSD are cumbersome. here I use a copied Shell script (slightly changed) to complete the entire process conveniently, assume that the host system address is 192.168.0.1 and the VPS address is 192.168.0.2 (alias), and the generated VPS is placed under/home/jail. Note that VPS is implemented here, and the entire FreeBSD directory tree, which is the same as that of the host system, must be generated. If you only want to implement a Jail that runs a service, do not use this script.
  
In addition, in VPS, services that listen to all addresses by default may need to be reset to a specific address.
  
#! /Bin/sh
######################################## ########
#
#
# Makejail
#-Originally written in 2001 by Yann Sommer
#-Slightly modified by MaxBSD
#
# Creation of a new jail environment
# For FreeBSD.
#
# Achtung: Tested under FreeBSD4.X only.
#
######################################## ########
  
Echo "First off, pls create an ip alias and hostname
Echo "for the new jail system in/etc/rc. conf ."
Echo "eg: ifconfig_fxp0_alias0 = \" inet 192.168.0.2 netmask 0xffffff \""
Sleep 3
  
If test-z $ @; then
Echo "Enter destination directory for new jail :"
Echo "eg:/home/jail"
Read JAIL
Else
JAIL =$ @
Fi
  
Test! -D $ JAIL | {echo "$ JAIL already exists !! "; Exit 1 ;}
  
Echo "Creating jail directory ..."
Mkdir $ JAIL
  
Echo "Making World ...."
Cd/usr/src
Make world DESTDIR = $ JAIL-DNOCLEAN
Cd etc
Make distribution DESTDIR = $ JAIL NO_MAKEDEV = yes
  
Echo "Making devices ..."
Cd $ JAIL/dev
Sh MAKEDEV jail
Cd $ JAIL
Ln-sf dev/null kernel
  
Echo "Preparing initial configuration ..."
Touch $ JAIL/etc/fstab
Grep nameserver/etc/resolv. conf> $ JAIL/etc/resolv. conf
Echo "jail. set_hostname_allowed = 0">/etc/sysctl. conf
Echo "jail. sysvipc_allowed = 1">/etc/sysctl. conf
Echo "inetd_flags ="-wW-a 192.168.0.1 ">/etc/rc. conf
Echo "network_interfaces = \" \ "">/etc/rc. conf
Echo "sendmail_enable = \" NONE \ ""> $ JAIL/etc/rc. conf
Echo "portmap_enable = \" NO \ ""> $ JAIL/etc/rc. conf
Echo "============================================== ======================"
Echo "* Mission accomplished! *"
Echo
Echo "To start the jail you 've just created, do this command :"
Echo "Substitute the IP address and hostname with your own ."
Echo
Echo "jail/home/jail hostname 192.168.0.2/bin/sh/etc/rc"
Echo "============================================== ======================"
  
FreeBSD's Jail function is not very powerful yet, especially in terms of management. Fortunately, some 3rd party programs have enhanced this feature and will not be discussed here. If you are interested, search by yourself.
  
  
  
Related Article

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.