2

I have had this problem already and figured out its reason. Basically the problem is that the virtual devices on GNS3 cannot ping the physical host and also the physical host cannot ping the virtual devices on GNS3. The reason is that the the GNS3 virtual devices and also the host are using the same MAC address.


Now, I intend to make the GNS3 virtual devices be able to ping the physical host and vice versa. Does anybody know how to do it? Is it possible to do it with bridges? If so, how can I implement bridges to achieve my goal? A step-by-step answer is much appreciated.

4
  • There are many videos and descriptions just a quick Google search away. No point in us just repeating all that here.
    – Ron Trunk
    May 14, 2018 at 13:09
  • @RonTrunk Can you refer me to one of them? I don't know which one solves my problem.
    – Megidd
    May 14, 2018 at 13:13
  • @JFL How can Open vSwitch solve the problem of MAC address being the same across virtual GNS3 devices and my physical host? I mean, how does it solve the problem? Sorry, I don't quite get it
    – Megidd
    May 14, 2018 at 13:49

2 Answers 2

1

I think bridge works for that. 1. Create a loopback interface in your window system. 2. In GNS3, select a cloud to connect the loopback interface, thus the virtual device(like a router) can ping with your own system.

4
  • Can you introduce a video or tutorial on this?
    – Megidd
    May 15, 2018 at 5:19
  • I tried the loopback, but it doesn't seem to work. Not sure, maybe I'm missing something. Is there any step-by-step tutorial on it?
    – Megidd
    May 17, 2018 at 4:49
  • I can find a guide but it is a Chinese article with screenshots. I cannot access google, in my place it is not allowed to access it. You can search by yourself. Here is the doc : m.baidu.com/sf_edu_wenku/view/…
    – sky
    May 17, 2018 at 23:30
  • @user4838962 Hope it can help.
    – sky
    May 18, 2018 at 7:51
0

I'm on Ubuntu 17.10. The first thing I do, is to install openvswitch:

$ sudo apt install openvswitch-switch

Then, I followed the first 11 minutes of this tutorial.


Before doing tutorial steps, my IP addresses are:

$ ip address 
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp2s0f2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 70:4d:7b:3a:6e:2c brd ff:ff:ff:ff:ff:ff
    inet 10.10.1.122/16 brd 10.10.255.255 scope global dynamic enp2s0f2
       valid_lft 81401sec preferred_lft 81401sec
    inet6 fe80::f39e:90d0:970:b350/64 scope link 
       valid_lft forever preferred_lft forever
3: wlp3s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
    link/ether 94:e9:79:2a:34:23 brd ff:ff:ff:ff:ff:ff

Steps:

Add mybridge:

$ sudo ovs-vsctl add-br mybridge

Check if mybridge is added:

$ sudo ovs-vsctl show 
b6806445-d242-4102-9a58-7516aee68916
    Bridge mybridge
        Port mybridge
            Interface mybridge
                type: internal
    ovs_version: "2.8.1"

Check again:

$ ip address 
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp2s0f2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 70:4d:7b:3a:6e:2c brd ff:ff:ff:ff:ff:ff
    inet 10.10.1.122/16 brd 10.10.255.255 scope global dynamic enp2s0f2
       valid_lft 81023sec preferred_lft 81023sec
    inet6 fe80::f39e:90d0:970:b350/64 scope link 
       valid_lft forever preferred_lft forever
3: wlp3s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
    link/ether 94:e9:79:2a:34:23 brd ff:ff:ff:ff:ff:ff
4: ovs-system: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether ae:71:01:fd:5e:0f brd ff:ff:ff:ff:ff:ff
5: mybridge: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether f6:d4:f3:64:16:42 brd ff:ff:ff:ff:ff:ff

Bring up the mybridge:

$ sudo ip link set mybridge up

Or you can do it old-school with deprecated ifconfig:

$ sudo ifconfig mybridge up

Check:

$ sudo ip address 
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp2s0f2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 70:4d:7b:3a:6e:2c brd ff:ff:ff:ff:ff:ff
    inet 10.10.1.122/16 brd 10.10.255.255 scope global dynamic enp2s0f2
       valid_lft 80659sec preferred_lft 80659sec
    inet6 fe80::f39e:90d0:970:b350/64 scope link 
       valid_lft forever preferred_lft forever
3: wlp3s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
    link/ether 94:e9:79:2a:34:23 brd ff:ff:ff:ff:ff:ff
4: ovs-system: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether ae:71:01:fd:5e:0f brd ff:ff:ff:ff:ff:ff
5: mybridge: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1000
    link/ether f6:d4:f3:64:16:42 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::f4d4:f3ff:fe64:1642/64 scope link 
       valid_lft forever preferred_lft forever

Add a port from mybridge to enp2s0f2:

$ sudo ovs-vsctl add-port mybridge enp2s0f2

Check:

$ sudo ovs-vsctl show
b6806445-d242-4102-9a58-7516aee68916
    Bridge mybridge
        Port "enp2s0f2"
            Interface "enp2s0f2"
        Port mybridge
            Interface mybridge
                type: internal
    ovs_version: "2.8.1"

Try to ping the outside world, not possible:

$ ping 1.1.1.1
PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.
From 10.10.1.122 icmp_seq=1 Destination Host Unreachable
From 10.10.1.122 icmp_seq=2 Destination Host Unreachable
From 10.10.1.122 icmp_seq=3 Destination Host Unreachable
From 10.10.1.122 icmp_seq=4 Destination Host Unreachable
^C
--- 1.1.1.1 ping statistics ---
5 packets transmitted, 0 received, +4 errors, 100% packet loss, time 4045ms
pipe 3

Remove previous IP addresses of enp2s0f2:

$ sudo ip address del 10.10.1.122/16 dev enp2s0f2

Or you can do it old-school with deprecated ifconfig:

$ sudo ifconfig enp2s0f2 0

Check:

$ sudo ip address 
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp2s0f2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master ovs-system state UP group default qlen 1000
    link/ether 70:4d:7b:3a:6e:2c brd ff:ff:ff:ff:ff:ff
    inet6 fe80::f39e:90d0:970:b350/64 scope link 
       valid_lft forever preferred_lft forever
3: wlp3s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
    link/ether 94:e9:79:2a:34:23 brd ff:ff:ff:ff:ff:ff
4: ovs-system: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether ae:71:01:fd:5e:0f brd ff:ff:ff:ff:ff:ff
5: mybridge: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1000
    link/ether 70:4d:7b:3a:6e:2c brd ff:ff:ff:ff:ff:ff
    inet6 fe80::f4d4:f3ff:fe64:1642/64 scope link 
       valid_lft forever preferred_lft forever

Get IP address for mybridge:

$ sudo dhclient mybridge

Check:

$ sudo ip address 
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp2s0f2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master ovs-system state UP group default qlen 1000
    link/ether 70:4d:7b:3a:6e:2c brd ff:ff:ff:ff:ff:ff
    inet6 fe80::f39e:90d0:970:b350/64 scope link 
       valid_lft forever preferred_lft forever
3: wlp3s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
    link/ether 94:e9:79:2a:34:23 brd ff:ff:ff:ff:ff:ff
4: ovs-system: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether ae:71:01:fd:5e:0f brd ff:ff:ff:ff:ff:ff
5: mybridge: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1000
    link/ether 70:4d:7b:3a:6e:2c brd ff:ff:ff:ff:ff:ff
    inet 10.10.1.122/16 brd 10.10.255.255 scope global mybridge
       valid_lft forever preferred_lft forever
    inet6 fe80::f4d4:f3ff:fe64:1642/64 scope link 
       valid_lft forever preferred_lft forever

Check the routing, it should be through mybridge interface:

$ sudo route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.10.12.12     0.0.0.0         UG    0      0        0 mybridge
10.10.0.0       0.0.0.0         255.255.0.0     U     0      0        0 mybridge

It is possible to ping the outside world now:

$ ping 1.1.1.1
PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.
64 bytes from 1.1.1.1: icmp_seq=1 ttl=50 time=89.9 ms
64 bytes from 1.1.1.1: icmp_seq=2 ttl=50 time=95.2 ms
64 bytes from 1.1.1.1: icmp_seq=3 ttl=50 time=82.3 ms
64 bytes from 1.1.1.1: icmp_seq=4 ttl=50 time=93.3 ms
^C
--- 1.1.1.1 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3002ms
rtt min/avg/max/mdev = 82.323/90.211/95.221/4.946 ms

It is possible to ping by name too:

$ ping google.com
PING google.com (172.217.16.206) 56(84) bytes of data.
64 bytes from fra16s08-in-f14.1e100.net (172.217.16.206): icmp_seq=1 ttl=47 time=117 ms
64 bytes from fra16s08-in-f14.1e100.net (172.217.16.206): icmp_seq=2 ttl=47 time=110 ms
64 bytes from fra16s08-in-f14.1e100.net (172.217.16.206): icmp_seq=3 ttl=47 time=115 ms
64 bytes from fra16s08-in-f14.1e100.net (172.217.16.206): icmp_seq=4 ttl=47 time=114 ms
64 bytes from fra16s08-in-f14.1e100.net (172.217.16.206): icmp_seq=5 ttl=47 time=113 ms
^C
--- google.com ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4006ms
rtt min/avg/max/mdev = 110.344/114.344/117.319/2.308 ms

Add a tap to be used later in GNS3:

$ sudo ip tuntap add mode tap vport1

Check:

$ sudo ip address 
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp2s0f2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master ovs-system state UP group default qlen 1000
    link/ether 70:4d:7b:3a:6e:2c brd ff:ff:ff:ff:ff:ff
    inet6 fe80::f39e:90d0:970:b350/64 scope link 
       valid_lft forever preferred_lft forever
3: wlp3s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
    link/ether 94:e9:79:2a:34:23 brd ff:ff:ff:ff:ff:ff
4: ovs-system: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether ae:71:01:fd:5e:0f brd ff:ff:ff:ff:ff:ff
5: mybridge: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1000
    link/ether 70:4d:7b:3a:6e:2c brd ff:ff:ff:ff:ff:ff
    inet 10.10.1.122/16 brd 10.10.255.255 scope global mybridge
       valid_lft forever preferred_lft forever
    inet6 fe80::f4d4:f3ff:fe64:1642/64 scope link 
       valid_lft forever preferred_lft forever
6: vport1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 12:85:60:b7:d1:3e brd ff:ff:ff:ff:ff:ff

Bring up vport1:

$ sudo ip link set vport1 up

Or do it old-school with deprecated ifconfig:

$ sudo ifconfig vport1 up

Check:

$ sudo ip address 
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp2s0f2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master ovs-system state UP group default qlen 1000
    link/ether 70:4d:7b:3a:6e:2c brd ff:ff:ff:ff:ff:ff
    inet6 fe80::f39e:90d0:970:b350/64 scope link 
       valid_lft forever preferred_lft forever
3: wlp3s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
    link/ether 94:e9:79:2a:34:23 brd ff:ff:ff:ff:ff:ff
4: ovs-system: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether ae:71:01:fd:5e:0f brd ff:ff:ff:ff:ff:ff
5: mybridge: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1000
    link/ether 70:4d:7b:3a:6e:2c brd ff:ff:ff:ff:ff:ff
    inet 10.10.1.122/16 brd 10.10.255.255 scope global mybridge
       valid_lft forever preferred_lft forever
    inet6 fe80::f4d4:f3ff:fe64:1642/64 scope link 
       valid_lft forever preferred_lft forever
6: vport1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
    link/ether 12:85:60:b7:d1:3e brd ff:ff:ff:ff:ff:ff

Add vport1 to mybridge:

$ sudo ovs-vsctl add-port mybridge vport1

Check:

$ sudo ovs-vsctl show
b6806445-d242-4102-9a58-7516aee68916
    Bridge mybridge
        Port "enp2s0f2"
            Interface "enp2s0f2"
        Port mybridge
            Interface mybridge
                type: internal
        Port "vport1"
            Interface "vport1"
    ovs_version: "2.8.1"

Now on GNS3 topology:

enter image description here

Use vport1 to configure Cloud-1:

enter image description here

Now it is possible to ping the physical host computer from within the GNS3 router:

R1#show ip interface brief 
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            10.10.1.183     YES DHCP   up                    up      
FastEthernet0/1            172.31.0.1      YES NVRAM  up                    up      
NVI0                       unassigned      NO  unset  up                    up      
R1#     
R1#
R1#ping 10.10.1.122

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.10.1.122, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/10/16 ms

Also it is possible to ping the physical host computer from within the virtual PC in GNS3:

PC-1> show ip

NAME        : PC-1[1]
IP/MASK     : 172.31.0.2/24
GATEWAY     : 172.31.0.1
DNS         : 1.1.1.1  
DHCP SERVER : 172.31.0.1
DHCP LEASE  : 86135, 86400/43200/75600
MAC         : 00:50:79:66:68:00
LPORT       : 10010
RHOST:PORT  : 127.0.0.1:10011
MTU:        : 1500

PC-1> ping 10.10.1.122 
84 bytes from 10.10.1.122 icmp_seq=1 ttl=63 time=20.278 ms
84 bytes from 10.10.1.122 icmp_seq=2 ttl=63 time=20.494 ms
84 bytes from 10.10.1.122 icmp_seq=3 ttl=63 time=19.957 ms
84 bytes from 10.10.1.122 icmp_seq=4 ttl=63 time=20.254 ms
84 bytes from 10.10.1.122 icmp_seq=5 ttl=63 time=14.312 ms

PC-1>

Also my physical host computer can ping the virtual router on GNS3:

$ ping 10.10.1.183
PING 10.10.1.183 (10.10.1.183) 56(84) bytes of data.
64 bytes from 10.10.1.183: icmp_seq=1 ttl=255 time=5.24 ms
64 bytes from 10.10.1.183: icmp_seq=2 ttl=255 time=4.47 ms
64 bytes from 10.10.1.183: icmp_seq=3 ttl=255 time=2.58 ms
64 bytes from 10.10.1.183: icmp_seq=4 ttl=255 time=2.13 ms
64 bytes from 10.10.1.183: icmp_seq=5 ttl=255 time=10.9 ms
64 bytes from 10.10.1.183: icmp_seq=6 ttl=255 time=10.1 ms
^C
--- 10.10.1.183 ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 5006ms
rtt min/avg/max/mdev = 2.130/5.921/10.967/3.446 ms

It is possible to check MAC addresses with the following command, as can be seen, enp2s0f2 and mybridge share the same MAC address but the one for vport1 is different:

$ sudo ovs-ofctl show mybridge
OFPT_FEATURES_REPLY (xid=0x2): dpid:0000704d7b3a6e2c
n_tables:254, n_buffers:0
capabilities: FLOW_STATS TABLE_STATS PORT_STATS QUEUE_STATS ARP_MATCH_IP
actions: output enqueue set_vlan_vid set_vlan_pcp strip_vlan mod_dl_src mod_dl_dst mod_nw_src mod_nw_dst mod_nw_tos mod_tp_src mod_tp_dst
 1(enp2s0f2): addr:70:4d:7b:3a:6e:2c
     config:     0
     state:      0
     current:    100MB-FD AUTO_NEG
     advertised: 10MB-HD 10MB-FD 100MB-HD 100MB-FD COPPER AUTO_NEG AUTO_PAUSE AUTO_PAUSE_ASYM
     supported:  10MB-HD 10MB-FD 100MB-HD 100MB-FD COPPER AUTO_NEG
     speed: 100 Mbps now, 100 Mbps max
 2(vport1): addr:12:85:60:b7:d1:3e
     config:     0
     state:      0
     current:    10MB-FD COPPER
     speed: 10 Mbps now, 0 Mbps max
 LOCAL(mybridge): addr:70:4d:7b:3a:6e:2c
     config:     0
     state:      0
     speed: 0 Mbps now, 0 Mbps max
OFPT_GET_CONFIG_REPLY (xid=0x4): frags=normal miss_send_len=0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.