MACbookでGNS3を利用し自分のMACbookをCiscoRouteに接続する方法
- 目的
- 前提
- 環境
- 対象
- 手順
- 手順1 tuntapをインストール
- 手順2 tun tapがインストールされていることを確認
- 手順3 利用するtapのパーミッションを変更
- 手順4 tapを起動
- 手順5 tapが動いていることの確認
- 手順6 GNS3にcloudを設置
- 手順7 Cloudの設定変更
- 手順8 tapを登録
- 手順9 CloudとRouterのケーブルを接続
- 手順10 ケーブルを削除
- 手順11 ターミナルを終了
- 手順12 ターミナルを起動
- 手順13 CloudとRouterを接続
- 手順14 接続できる
- 手順15 ifconfigで自動で作成されているのを確認
- 手順16 tapにIpアドレスを登録する
- 手順17 自分のtapにPingが飛ぶことを確認
- 手順18 ciscoにIpアドレスを設定
- 手順19 Pingを飛ばす
- おまけ
目的
MACbookでGNS3を利用し自分のMACbookをCiscoRouteに接続する方法を記載します
前提
環境
Operating System: MAC OS 10.14.5 Mojav3 GNS3 Software Version: GNS3 2.2.5
対象
おそらく下記が出ている方
Error while sending command 'bridge add_nio_tap 2d6afde7-5ff2-4ae2-a261-521d5c810d54-11 "tap0"': unable to create NIO TAP for bridge '2d6afde7-5ff2-4ae2-a261-521d5c810d54-11': uBridge version 0.9.16 running with libpcap version 1.8.1 -- Apple version 79.250.1 Hypervisor TCP control server started (IP 127.0.0.1 port 53630). UDP tunnel connecting from local port 10000 to IPv4 addresss 127.0.0.1 on port 10001 create_nio_tap: unable to open TAP device tap0 (Resource busy)
手順
手順1 tuntapをインストール
tun tapをインストールする
brew cask install tuntap
手順2 tun tapがインストールされていることを確認
tun tapがインストールされていることを確認する
➜ ll /dev/ | grep tap crw-rw---- 1 root wheel 31, 0 4 13 21:56 tap0 crw-rw---- 1 root wheel 31, 1 4 7 10:33 tap1 crw-rw---- 1 root wheel 31, 10 4 7 10:33 tap10 crw-rw---- 1 root wheel 31, 11 4 7 10:33 tap11 crw-rw---- 1 root wheel 31, 12 4 7 10:33 tap12 crw-rw---- 1 root wheel 31, 13 4 7 10:33 tap13 crw-rw---- 1 root wheel 31, 14 4 7 10:33 tap14 crw-rw---- 1 root wheel 31, 15 4 7 10:33 tap15 crw-rw---- 1 root wheel 31, 2 4 7 10:33 tap2 crw-rw---- 1 root wheel 31, 3 4 7 10:33 tap3 crw-rw---- 1 root wheel 31, 4 4 7 10:33 tap4 crw-rw---- 1 root wheel 31, 5 4 7 10:33 tap5 crw-rw---- 1 root wheel 31, 6 4 7 10:33 tap6 crw-rw---- 1 root wheel 31, 7 4 7 10:33 tap7 crw-rw---- 1 root wheel 31, 8 4 7 10:33 tap8 crw-rw---- 1 root wheel 31, 9 4 13 21:48 tap9
手順3 利用するtapのパーミッションを変更
cd /dev/ sudo chmod 777 tap0 ➜ ll /dev/ | grep tap crwxrwxrwx 1 root wheel 31, 0 4 13 21:56 tap0 crw-rw---- 1 root wheel 31, 1 4 7 10:33 tap1
手順4 tapを起動
tap0を起動する [n]<>が何かを知りたい人はこちら
exec 3<>/dev/tap0
手順5 tapが動いていることの確認
tap0が付いていることを確認する ifconfig
(略) tap0: flags=8842<BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500 ether 82:35:b3:4e:79:7a media: autoselect status: active open (pid 19303)
手順6 GNS3にcloudを設置
GNS3からCloudをだす
ここは自分のPC名
手順7 Cloudの設定変更
cloudを指2本でタップしてConfigureをクリック
手順8 tapを登録
TAP Interfacesをクリックして TAP0を登録する
こうなる
手順9 CloudとRouterのケーブルを接続
GNS3からCloudとRouterのケーブルを接続する
こんな感じに
これでできたーと喜ぶと 多分こうなる(´・ω・`)
雑談1
色々聞いてみる(´;ω;`)<ボスケテ www.gns3.com
負けずに公式にも聞いてみる(´;ω;`)<ボスケテボスケテ
反応が無いため 自分の構築が悪いのか むしろみんなスムーズに動いていて質問することでは無いのかと思い始める
ここからほんとよくわからなかったので 手順10移行は自分が動いた方法を記載します。 なので環境によっては動かない人がいたらすみません
手順10 ケーブルを削除
ケーブルを選択し線をタップして1回削除します
手順11 ターミナルを終了
exec 3<>tap0を動かした ターミナルを落とします。
exit
手順12 ターミナルを起動
ターミナルを起動させます ifconigで tap0が無いことを確認します。
手順13 CloudとRouterを接続
GNS3からCloudとRouterのケーブルを接続する
こんな感じに
手順14 接続できる
するとなぜか接続できる!
雑談2
おそらくなのですがtap0を起動させているままだと重複して読み込め無いのかな 'bridge add_nio_tap 2d6afde7-5ff2-4ae2-a261-521d5c810d54-11 "tap0"
手順15 ifconfigで自動で作成されているのを確認
ifconfigで確認するとtap0が自動で作られている この自動で作られているというのが大事
ifconfig (略) tap0: flags=8842<BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500 ether 46:18:f6:0b:f2:63 media: autoselect status: active open (pid 44810)
手順16 tapにIpアドレスを登録する
IPアドレスが設定されていないので ifconfig コマンドでIpをp設定する
sudo ifconfig tap0 10.0.0.1/24 up ifconfig (略) tap0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500 ether 46:18:f6:0b:f2:63 inet 10.0.0.1 netmask 0xffffff00 broadcast 10.0.0.255 media: autoselect status: active open (pid 44810)
手順17 自分のtapにPingが飛ぶことを確認
pingが飛ぶことを確認する
ping 10.0.0.1 PING 10.0.0.1 (10.0.0.1): 56 data bytes 64 bytes from 10.0.0.1: icmp_seq=0 ttl=64 time=0.041 ms 64 bytes from 10.0.0.1: icmp_seq=1 ttl=64 time=0.049 ms 64 bytes from 10.0.0.1: icmp_seq=2 ttl=64 time=0.087 ms
手順18 ciscoにIpアドレスを設定
Ciscoを設定する
R1#config t Enter configuration commands, one per line. End with CNTL/Z. R1(config)#interface ethernet 0/0 R1(config-if)# ip address 10.0.0.2 255.255.255.0 R1(config-if)#no sh R1(config-if)#no shutdown
手順19 Pingを飛ばす
➜ ping 10.0.0.2 PING 10.0.0.2 (10.0.0.2): 56 data bytes 64 bytes from 10.0.0.2: icmp_seq=0 ttl=255 time=22.978 ms 64 bytes from 10.0.0.2: icmp_seq=1 ttl=255 time=10.092 ms
おまけ
sshする
ここのサイトを参考に設定する www.infraexpert.com
下記の特権モードのパスワードを忘れずに
enable secret cisco ← お好きなパスワード
crypto key generate rsaは 4096が使えないので 2048ぐらいで勘弁
macからssh
こうなるので
➜ ssh admin@10.0.0.2 Unable to negotiate with 10.0.0.2 port 22: no matching key exchange method found. Their offer: diffie-hellman-group1-sha1
Host 10.0.0.2 KexAlgorithms +diffie-hellman-group1-sha1 Ciphers aes128-cbc
これでできる
macからAnsible
パスワードの書き方 hostsに書いているのは許して
➜ cat hosts [cisco] 10.0.0.2 [cisco:vars] ansible_connection=network_cli ansible_network_os=ios ansible_ssh_user=admin ansible_ssh_pass=cisco ansible_become=yes ansible_become_method=enable ansible_become_pass=cisco
➜ ansible -i hosts cisco -m ping [WARNING]: Platform darwin on host 10.0.0.2 is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python interpreter could change this. See https://docs.ansible.com/ansible/2.9/referen ce_appendices/interpreter_discovery.html for more information. 10.0.0.2 | SUCCESS => { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python" }, "changed": false, "ping": "pong" }
参考サイト
*1:多分777じゃなくていいがよくわかってないのでとりあえず777