labunix's blog

labunixのラボUnix

debian 10でgns3を使ってみる。

■debian 10でgns3を使ってみる。

$ lsb_release -d
Description:	Debian GNU/Linux 10 (buster)

$ python3 --version
Python 3.7.3

■後述のubuntuのapt-get/dpkgではpython3.6用のため、
 pip3を使う。

$ pip3 search gns3
gns3-gui (2.2.0)            - GNS3 graphical interface for the GNS3 server.
gns3-server (2.2.0)         - GNS3 server
gns3-proxy (0.5)            - GNS3 Proxy based on proxy.py by Abhinav Singh (https://github.com/abhinavsingh/proxy.py)
gns3-netifaces (0.10.4.1)   - Portable network interface information. GNS3 fork for solving a Python 3 issue
gns3-net-converter (1.3.0)  - Official fork by GNS3 team of the gns3 converter.Convert old ini-style GNS3 topologies (<=0.8.7) to the
                              newer version 1+ JSON format
gns3-converter (1.2.4)      - Convert old ini-style GNS3 topologies (<=0.8.7) to the newer version 1+ JSON format
gns3fy (0.5.2)              - Python wrapper around GNS3 Server API
pygns3-elsholz (3.11)       - Python implementation of the GNS3 API. Fork by elsholz from mvdwoord/PyGNS3

$ pip3 install --upgrade gns3-server gns3-gui
$ /usr/local/bin/pip3 search gns3 | lsec INSTALLED
gns3-gui (2.2.0)            - GNS3 graphical interface for the GNS3 server.
  INSTALLED: 2.2.0 (latest)
gns3-server (2.2.0)         - GNS3 server
  INSTALLED: 2.2.0 (latest)

$ gns3
Please install the PyQt5.QtWebSockets module

$ pip3 search PyQt5 | grep ^PyQt5
PyQt5-sip (12.7.0)                - The sip module support for PyQt5
PyQt5-stubs (5.13.0.1)            - PEP561 stub files for the PyQt5 framework
PyQt5 (5.13.1)                    - Python bindings for the Qt cross platform UI and application toolkit
PyQt5Designer (5.13.1)            - PyQt5 Designer
PyQt5Singleton (0.1)              - A simple singleton implementation to work with PyQt5

$ pip3 install --upgrade PyQt5

$ pip3 search PyQt5 | lsec INSTALLED
PyQt5-sip (12.7.0)                - The sip module support for PyQt5
  INSTALLED: 12.7.0 (latest)
PyQt5 (5.13.1)                    - Python bindings for the Qt cross platform UI and application toolkit
  INSTALLED: 5.13.1 (latest)

■ユーザ権限では「127.0.0.1:3080」が立ち上がらない。「sudo」ならイケるので何かが足りない。

$ gns3 2>&1 | awk '/127.0.0.1/{gsub("\134. ","\n",$0);print $0}'
2019-10-17 22:29:25 CRITICAL topology.py:250 Cannot connect to http://127.0.0.1:3080
Please check if GNS3 is allowed in your antivirus and firewall
And that server version is 2.2.0.

■グループを追加していなければ追加する。
 これは127.0.0.1:3080がつながらない問題とは異なる。

$ awk -F\: '/ubridge|libvirt|kvm|wireshark|docker/{print "gpasswd -a labunix "$1}' /etc/group | sudo sh
[sudo] labunix のパスワード:
ユーザ labunix をグループ kvm に追加
ユーザ labunix をグループ libvirt に追加
ユーザ labunix をグループ libvirt-qemu に追加
ユーザ labunix をグループ ubridge に追加
ユーザ labunix をグループ docker に追加

■以下は問題なさそう。

$ pip3 show gns3-server | grep Location
Location: /usr/local/lib/python3.7/dist-packages

$ awk '/user|group|3080|127.0.0.1|localhost/{print FILENAME";"$0}' $(find /usr/local/lib/python* -type f -name "topology.py")
/usr/local/lib/python3.7/dist-packages/gns3server/controller/topology.py;            "host": server.get("host", "localhost"),
/usr/local/lib/python3.7/dist-packages/gns3server/controller/topology.py;            "port": server.get("port", 3080),

■どこかでhostを違う値に書き換えているはず。
 「host = None」の値を書き換え。

$ awk '/^host/{print FILENAME";"$0}' $(find ~/.config/GNS3/ -type f)
/home/labunix/.config/GNS3/2.2/gns3_server.conf;host = None
/home/labunix/.config/GNS3/gns3_server.conf;host = 127.0.0.1

$ sed -i -e 's/host = None/host = localhost/' .config/GNS3/2.2/gns3_server.conf

■正常に起動した。

$ gns3 &

■もしかしてデフォルトのユーザ用コンフィグが間違っている?
 と思ったら、そうみたい。

 GNS3 2.2 installation and configuration: Includes GNS Web UI demo
 https://www.gns3.com/community/discussion/gns3-2-2-installation-and-config

■ところでrootユーザなら起動したので、再確認したところ、「127.0.0.1」だった。
 rootユーザも2.2配下なので、ログインユーザ用のgns3_server.confだけがおかしい。
 gns3のdist-packagesと、rootユーザのどちらに合わせるかは、
 IPv4固定にしたいとかがなく、どちらも動くのであればdist-packagesの方がベターだと思うけど、
 これは各自の判断で。

$ sudo sdiff -s /home/labunix/.config/GNS3/2.2/gns3_server.conf  /root/.config/GNS3/2.2/gns3_server.conf | grep host
host = localhost					      |	host = 127.0.0.1
ghost_ios_support = True				      <

■参考:以下のstretchからの移行としてapt-getでは失敗したので削除した手順

$ sudo sed -i -e 's/xenial/bionic/' /etc/apt/sources.list.d/gns3.list 

$ cat /etc/apt/sources.list.d/gns3.list 
deb http://ppa.launchpad.net/gns3/ppa/ubuntu bionic main
deb-src http://ppa.launchpad.net/gns3/ppa/ubuntu bionic main

■GPGキーがなければ追加する。

$ apt-key finger F88F6D313016330404F710FC9A2FD067A2E3EF7B
pub   rsa1024 2013-07-06 [SC]
      F88F 6D31 3016 3304 04F7  10FC 9A2F D067 A2E3 EF7B
uid           [  不明  ] Launchpad PPA for GNS3

$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F88F6D313016330404F710FC9A2FD067A2E3EF7B

■GNS3をインストール

$ sudo apt install -y gns3-gui

$ dpkg -l | awk '/docker|ubridge|wireshark/&&$1 ~ /^ii/{print $2,$3,$4}'
docker-ce 5:19.03.3~3-0~debian-buster amd64
docker-ce-cli 5:19.03.3~3-0~debian-buster amd64
libwireshark-data 2.6.8-1.1 all
libwireshark11:amd64 2.6.8-1.1 amd64
ubridge 0.9.16-1~xenial1 amd64
wireshark 2.6.8-1.1 amd64
wireshark-common 2.6.8-1.1 amd64
wireshark-doc 2.6.8-1.1 all
wireshark-qt 2.6.8-1.1 amd64

■python3.7用には作られていないようだ。

$ gns3
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00007ff17393e740 (most recent call first):
中止

■gns3はpython3.6用だった。

$ dpkg -L gns3-gui | awk -F\/ '/python/{for(a=1;a<=NF;a++){if($a ~ /^python/){print $a | "sort -uV"}}}'
python
python3
python3.6
python3.6m
python-config
python-wheels

■削除
 ubridgeも一緒に消えてしまうので再インストール。

$ dpkg -l | awk '/gns3/&&/^ii/{print "apt-get purge -y "$2}' | sudo sh
$ sudo apt-get autoremove -y
$ sudo apt-get install -y ubridge
$ grep ubridge /etc/group
ubridge:x:142:labunix

$ dpkg -l | awk '/^rc/{print $2,$3}'
libpython3.5-minimal:amd64 3.5.3-1+deb9u1
python3.5-minimal 3.5.3-1+deb9u1
spice-client-glib-usb-acl-helper 0.35-2

$ dpkg -l | awk '/^rc/{print "apt-get purge -y "$2}' | sudo sh
$ dpkg -l | awk '/^rc/{print $2,$3}'