首先参考博客http://blog.csdn.net/luokingfly/article/details/52299034的内容进行设置,为了方便显示,我将这篇博客的内容复制这这里,共大家参考:
VirtualBox:
0.启动virtualbox后,先添加个host-only adapter网络 ,VirtualBox VM-->preferences-->network , 找到默认是NAT network ,边上有个Host-only network, 添加一个。 这一步不做默认的是NAT网络,eth0的IP地址是10.x.x.x, 无法从PC上ssh.
-
import 下载好的mininet image , *.ovf.
-
Select “settings,” and add an additional host-only network adapter that you can use log in to the VM image.加上这个网络后,就有两个host-only 网络,eth0 eth1, 如果不加,后面做sudo dhclient eth1 时会报错找不到eth1
-
For more information on setting up networking in VirtualBox, you may wish to check out these VirtualBox specific instructions
VMware: Import the OVF file, then start the VM.
VMware may ask you to install VMware tools on the VM - if it asks, decline. Everything graphical in the tutorial is done via X forwarding through SSH (in fact, the VM doesn’t have a desktop manager installed), so the VMware tools are unnecessary unless you wish to install an X11/Gnome/etc. environment in your VM.
进行设置之后,这是可以启动虚拟机。使用下面的用户名和密码:
mininet-vm login: mininet
Password: mininet
也就是说用户名和密码都是mininet。
对于一个初学者来说,最好的方式就是按照Mininet官方Walkthrough进行学习。
你会发现你自己可以进行的操作就是一个命令,那就是sudo mn -h,当你在执行第二条命令,也就是启动Wireshark是会报错。
error: XDG_RUNTIME_DIR not set in the environment. Gtk-WARNING **: cannot open display
这个错误正式这篇文章要解决的问题
首先,大家不用怀疑mininet的镜像有问题,因为它真的是可用的。
其次,到这一步,这个错误其实原因就在于mininet这个镜像没有安装图形界面,所以到此为止你有两条路可走:1、下载一个Ubuntu 桌面版,在上面安装mininet以及相关的软件;2、尝试使用x工具
我这里处理的方式就是第二种。在windows主机上下载xshell和xmanager,安装这两个就可以搞定了。使用xshell进行登陆,在xshell中创建新会话(IP地址输入第1步中输入虚拟机中mininet VM的IP地址),注意你需要设置一个地方,在我们连接配置的地方,找到左边树形中的SSH,单击“隧道”后,在右边的页面上有个X11转移,勾选复选框转发X11连接到(X)以及下面的Xmanager,这样你在自动wireshark的时候就不会出现错误了。
这时候,选择使用XShell登陆到到mininet主机,使用xshell登录虚拟机后,通过键盘输入xterm,xshell即可自动启动xmanager并将xterm咋主机上开启一个窗口进行显示。
这是你再输入wireshark &就会自动的开启另外一个wireshark窗口。
到此为止,就可以正常的进行练习了。