栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

服务器配置记录(三)虚拟机服务器配置(GNS3)

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

服务器配置记录(三)虚拟机服务器配置(GNS3)

这里选择使用GNS3作为虚拟机管理平台。原因在于其拓扑管理、虚拟机创建、团队协作都相对方便。

官方网址:GNS3 | The software that empowers network professionals

1. 服务器端安装

GNS3 Linux Install | GNS3 Documentation

sudo add-apt-repository ppa:gns3/ppa
sudo apt update
# 如果报错
W: GPG 错误:http://ppa.launchpad.net/gns3/ppa/ubuntu focal InRelease: 由于没有公钥,无法验证下列签名: NO_PUBKEY 9A2FD067A2E3EF7B
E: 仓库 “http://ppa.launchpad.net/gns3/ppa/ubuntu focal InRelease” 没有数字签名。
N: 无法安全地用该源进行更新,所以默认禁用该源。
N: 参见 apt-secure(8) 手册以了解仓库创建和用户配置方面的细节。
# 添加一下即可
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 9A2FD067A2E3EF7B # 这串秘钥可能不同,从报错复制过来即可
sudo apt install gns3-server gns3-gui
sudo apt install gns3-iou
2. 修改配置文件

建议在root下启动gns3server,否则某些系统下可能无法正常工作。

参考官网,gns3server会在如下位置搜索配置文件:

GNS3 server configuration file | GNS3 Documentation

$HOME/.config/GNS3/gns3_server.conf
$HOME/.config/GNS3.conf
/etc/xdg/GNS3/gns3_server.conf
/etc/xdg/GNS3.conf
gns3_server.conf in the current directory

因此,创建配置文件

sudo vim /etc/xdg/GNS3.conf

内容如下

[Server]
path = /usr/bin/gns3server
ubridge_path = /usr/bin/ubridge
host = 0.0.0.0
port = 3080
images_path = /home/用户名/GNS3/images # 镜像保存位置,安装时一般自动创建了用户目录的这个位置
projects_path = /home/用户名/GNS3/projects # 项目保存位置
appliances_path = /home/用户名/GNS3/appliances
additional_images_paths =
symbols_path = /home/用户名/GNS3/symbols # 符号文件
configs_path = /home/用户名/GNS3/configs # 配置文件
report_errors = True
auto_start = True
allow_console_from_anywhere = False
auth = True
user = admin # 客户端连接时的用户名
password = xxxxxxxxxxxxxxxxxxxxxxx # 客户端连接时的密码
protocol = http
console_start_port_range = 5000
console_end_port_range = 10000
udp_start_port_range = 10000
udp_end_port_range = 20000
3. 网络配置(非必须)

由于使用人数较多,为了便于管理,需要给gns3的虚拟网卡配置更大的文件范围。

3.1 修改libvirt配置文件
sudo vim /etc/libvirt/qemu/networks/default.xml

  default
  5bd729eb-970b-4399-b388-9c3607746952
  
  
  
  
    
      
    
  

这里我使用了10.233.0.0/16 网段供虚拟机使用,物理机连接虚拟机使用的IP是10.233.0.1,即虚拟机的默认网关。dhcp地址池的范围是10.233.200.1-10.233.255.254, 其余地址供用户配置静态IP使用。

3.2 删除重建虚拟网卡
sudo virsh net-destroy default
sudo virsh net-start default
4. 创建系统服务以实现开机自启动 4.1 编辑服务文件
sudo vim /etc/systemd/system/gns3server.service
[Unit]
After=network.service # 网络服务启动之后再启动

[Service]
# ExecStartPre=/usr/bin/virsh net-start default #部分系统每次重启会把虚拟网卡删掉因此需要加上这句,如果不删就不加
ExecStart=/usr/bin/gns3server -A --log /tmp/gns3server.log
RestartSec=5
Restart=always

[Install]
WantedBy=default.target
4.2 重新加载并使用服务
sudo systemctl daemon-reload
sudo systemctl enable gns3server.service
sudo systemctl start gns3server.service
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/1003184.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号