GNS3 / gns3-server

GNS3 server
GNU General Public License v3.0
811 stars 263 forks source link

[BUG] IP's addressed via "Cloud" are unreachable from the local host providing the interface for the bridge #2216

Open eantowne opened 1 year ago

eantowne commented 1 year ago

On Ubuntu and Manjaro I am seeing the following behavior:

  1. Create a project
  2. Add cloud
  3. Add VPCS
  4. Connect VPCS to cloud (Select physical interface of local host with LAN connectivity)
  5. Start VPCS
  6. Acquire DHCP address on vpcs via "ip dhcp"
  7. VPCS can ping out to devices on LAN other than local host's IP (IP of the interface the cloud is bridged to)
  8. External hosts on lan can ping VPCS
  9. Local host that GNS3 is running on (Cloud bridged to it's NIC) cannot ping VPCS

This used to work from my recollection. Has something changed, or how can this be resolved?

eantowne commented 1 year ago

Hmmm, maybe I maybe thinking of using the virbr0 interface to access internal to the project. I know I was never able to use the cloud for this a long time ago on Windows.

spikefishjohn commented 1 year ago

Seems to work just fine if you use a bridge interface.

GNS3 - 10.1.18.22/23 - br0 made a cloud add a VPCS to br0 ip dhcp ping 10.1.18.22 works

root@compute01:~# brctl show br0
bridge name     bridge id               STP enabled     interfaces
br0             8000.2a4984899a1a       no              eno4.18
                                                        gns3tap0-13
                                                        gns3tap1-13
                                                        gns3tap2-13
                                                        gns3tap3-13
                                                        gns3tap4-13
root@compute01:~# ip address  | grep ' br0:'
20: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000

PC1> ping 10.1.18.22

84 bytes from 10.1.18.22 icmp_seq=1 ttl=64 time=0.679 ms
84 bytes from 10.1.18.22 icmp_seq=2 ttl=64 time=0.624 ms

PC1> show ip

NAME        : PC1[1]
IP/MASK     : 10.1.18.52/23
GATEWAY     : 10.1.18.1
DNS         : 8.8.8.8  8.8.4.4
DHCP SERVER : 10.1.18.1
DHCP LEASE  : 345287, 345600/172800/302400
MAC         : 00:50:79:66:68:00
LPORT       : 20606
RHOST:PORT  : 127.0.0.1:20607
MTU         : 1500

PC1>
hajonnes commented 1 year ago

for a noob like me, could you help me with how I could set up that kind of bridge? I'm on an arch based distibution so I have the command 'ip' and 'nmcli' as prefered tools but I'm open for suggestions.

spikefishjohn commented 1 year ago

Well the ip command is just for setting values one time. It doesn't set it to work at boot up.

https://wiki.archlinux.org/title/network_bridge

See the "With NetworkManager" section.

Do this on the console. If you get it wrong its going to kill your network access. You also may need to delete the old connection for the real interface. Once you do that just move the IP address to the bridge interface along with default route.

If you get stuck show your interface configuration and route table.

hajonnes commented 1 year ago

I set up a bridge as follows:

set up the bridge:

In sudo ip tuntap add dev tap0 mode tap user <userNumber> group <userGroup> <userNumber> can be obtained by the command id -u. <userGroup> can be obtained by the command groups and see if your username has a group, if it does then use that as <userGroup>. A tap interface should be set to your user like this, otherwise it can only be used by sudo processes (I think). Use e.g. ip a s to show what you what your ethernet interface name is and use it where I have placed written <ethernetInterface>. Mine for example was enp0s31f6 but a common name is eth0 as well, if it is a similar name it is probably what you are looking for.

id -u
groups
ip a s
sudo ip link add name br0 type bridge
sudo ip link set br0 up
sudo ip tuntap add dev tap0 mode tap user <userNumber> group <userGroup>
sudo ip link set tap0 up
sudo ip link set tap0 master br0
sudo ip link set <ethernetInterface> master br0

reset routes:

sudo ip link set  <ethernetInterface> down
sudo ip link set  <ethernetInterface> up

add dhcp client to bridge:

you should not put one on <ethernetInterface> or tap, they are slave interfaces. I'm on manjaro an arch based distribution. For me dhclient was already installed so I used it. There are other dhcp clients. search in your packagemanager after dhcp to see which dhcp client you have installed and google the command how to put one on your interface. If you have dhclient it is as follows:

sudo dhclient br0 -v 

check so the routes are working well:

use the command ip r s.

$> ip r s
default via 192.168.88.1 dev br0 
192.168.88.0/24 dev br0 proto kernel scope link src 192.168.88.239

here one can see that my traffic uses br0 to my local lan (192.168.88.0/24). I make a cloud in gn3 and connect it to "tap0" then my lan's dhcp server gives out addresses to my gns3 topology. If you do not have a good route configuration check out: https://diego.assencio.com/?index=d71346b8737ee449bb09496784c9b344 https://is.muni.cz/th/tu1ke/iproute.pdf to fix it.

Question

That is my setup, but is there an easier setup? I only want to be able to connect with winbox that runs in wine to my gns3-topology. I was thinking that winbox needs to be on the same lan as my gns3-topology so then I must connect my my gns3-topology to my lan and winbox communicate to my lan automatically since my linux machine is on my lan.

josephmhiggins commented 1 year ago

GNS3 has a mikrotik winbox docker. I recommend installing that in the gns3 topology trying that out. If it works, delete your cloud and revert your changes on your host.

vlisivka commented 1 year ago

Workaround for the problem:

Pair of veth is created, then checksum making is disabled on veth.

$ cat ~/bin/start-gns3 
#!/bin/bash

sudo ip link add veth01 type veth peer name veth02
sudo ethtool -K veth01 tx off
sudo ip addr add 192.168.6.1/24 brd + dev veth01
sudo ip link set dev veth01 up
sudo ip link set dev veth02 up

gns3

sudo ip link set dev veth01 down
sudo ip link set dev veth02 down
sudo ip link del dev veth01

Add veth02 to GNS3 "cloud" (press "show special devices" to see it), then connect a MikroTik to it. MikroTik will be able to communicate with host via Winbox or Dude.

mikhail-do commented 8 months ago

I fixed it with a bit another way and glad to share it. I use netplan for my network setup.

I had the file in my kubuntu: /etc/netplan/01-network-manager-all.yaml And I changed the config like this:

network:
  version: 2
  renderer: networkd
  ethernets:
    enp3s0:
      wakeonlan: true
      dhcp4: no
      dhcp6: no
  bridges:
    br0:
      interfaces:
        - enp3s0
      dhcp4: yes
      dhcp6: no

I know, when I have networkd, system icon in a tray shows me like I don't have internet connection. image So I just hided and disabled the icon and that is okay for me.

Then I created cloud in GNS3 and connected to br0 interface: image

After it - everything is works