sh 一个shell脚本,为本地托管的nat VM创建一个8节点nat网络,通过por提供ssh,mysql,postgres和其他Web服务

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 一个shell脚本,为本地托管的nat VM创建一个8节点nat网络,通过por提供ssh,mysql,postgres和其他Web服务相关的知识,希望对你有一定的参考价值。

VBoxManage natnetwork add --netname natnet2 --network "192.168.15.0/8" --enable --dhcp on

for i in {2..8}
do
  # redirect ssh from default of 22 to 220#
  VBoxManage natnetwork modify --netname natnet2 --port-forward-4 "ssh${i}:tcp:[]:220${i}:[192.168.15.${i}]:22"
  # redirect mysql from default of 3306 to 330#
  VBoxManage natnetwork modify --netname natnet2 --port-forward-4 "mysql${i}:tcp:[]:330${i}:[192.168.15.${i}]:3306"
  # redirect postgres from default of 5432 to 540#
  VBoxManage natnetwork modify --netname natnet2 --port-forward-4 "postgres${i}:tcp:[]:540${i}:[192.168.15.${i}]:5432"
  # redirect nginx from default of 8080 to 880#
  VBoxManage natnetwork modify --netname natnet2 --port-forward-4 "nginx${i}:tcp:[]:880${i}:[192.168.15.${i}]:8080"
done

VBoxManage natnetwork start --netname natnet2
VBoxManage list natnetworks

#=======================================================
#  This script makes the below network for hosted VMs
#=======================================================
# NetworkName:    natnet2
# IP:
# Network:        192.168.15.0/8
# IPv6 Enabled:   No
# IPv6 Prefix:
# DHCP Enabled:   Yes
# Enabled:        Yes
# Port-forwarding (ipv4)
#         mysql2:tcp:[]:3302:[192.168.15.2]:3306
#         mysql3:tcp:[]:3303:[192.168.15.3]:3306
#         mysql4:tcp:[]:3304:[192.168.15.4]:3306
#         mysql5:tcp:[]:3305:[192.168.15.5]:3306
#         mysql6:tcp:[]:3306:[192.168.15.6]:3306
#         mysql7:tcp:[]:3307:[192.168.15.7]:3306
#         mysql8:tcp:[]:3308:[192.168.15.8]:3306
#         nginx2:tcp:[]:8802:[192.168.15.2]:8080
#         nginx3:tcp:[]:8803:[192.168.15.3]:8080
#         nginx4:tcp:[]:8804:[192.168.15.4]:8080
#         nginx5:tcp:[]:8805:[192.168.15.5]:8080
#         nginx6:tcp:[]:8806:[192.168.15.6]:8080
#         nginx7:tcp:[]:8807:[192.168.15.7]:8080
#         nginx8:tcp:[]:8808:[192.168.15.8]:8080
#         postgres2:tcp:[]:5402:[192.168.15.2]:5432
#         postgres3:tcp:[]:5403:[192.168.15.3]:5432
#         postgres4:tcp:[]:5404:[192.168.15.4]:5432
#         postgres5:tcp:[]:5405:[192.168.15.5]:5432
#         postgres6:tcp:[]:5406:[192.168.15.6]:5432
#         postgres7:tcp:[]:5407:[192.168.15.7]:5432
#         postgres8:tcp:[]:5408:[192.168.15.8]:5432
#         ssh2:tcp:[]:2202:[192.168.15.2]:22
#         ssh3:tcp:[]:2203:[192.168.15.3]:22
#         ssh4:tcp:[]:2204:[192.168.15.4]:22
#         ssh5:tcp:[]:2205:[192.168.15.5]:22
#         ssh6:tcp:[]:2206:[192.168.15.6]:22
#         ssh7:tcp:[]:2207:[192.168.15.7]:22
#         ssh8:tcp:[]:2208:[192.168.15.8]:22

以上是关于sh 一个shell脚本,为本地托管的nat VM创建一个8节点nat网络,通过por提供ssh,mysql,postgres和其他Web服务的主要内容,如果未能解决你的问题,请参考以下文章

sh 这是一个shell脚本,用于自动生成https托管站点的自签名证书。

shell脚本定时备份日志===logBackup.sh

通过 nat VM SERVER 进行 Xdebug

怎么在一个shell脚本中执行远程主机的另一个shell脚本?? ssh已经可以无密码登录了。

Shell 脚本文件(.sh)不能从 Linux 上的 c# 核心运行

如何通过命令行启动 XAMPP-VM?