bigbluebutton / bbb-install

BASH script to install BigBlueButton in 30 minutes.
GNU Lesser General Public License v3.0
611 stars 540 forks source link

Wrong determination of local IP address #522

Open mokazemi opened 2 years ago

mokazemi commented 2 years ago

Hello. Due to restrictions in my country, I have to use openVPN on my server. I use this answer to do so, and everything was alright before BBB 2.5.

But now I investigated that bbb-install.sh determine my local IP wrong when I'm connected to VPN.

Here are lines from bbb-install.sh for BBB 2.4:

# Determine local IP
  need_pkg net-tools
  if LANG=c ifconfig | grep -q 'venet0:0'; then
    IP=$(ifconfig | grep -v '127.0.0.1' | grep -E "[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*" | tail -1 | cut -d: -f2 | awk '{ print $1}')
  else
    IP=$(ifconfig "$(route | grep ^default | head -1 | sed "s/.* //")" | awk '/inet /{ print $2}' | cut -d: -f2)
  fi

And here are lines from bbb-install.sh for BBB 2.5:

  # Determine local IP
  if [ -e "/sys/class/net/venet0:0" ]; then
    # IP detection for OpenVZ environment
    _dev="venet0:0"
  else
    _dev=$(awk '$2 == 00000000 { print $1 }' /proc/net/route | head -1)
  fi
  _ips=$(LANG=C ip -4 -br address show dev "$_dev" | awk '{ $1=$2=""; print $0 }')
  _ips=${_ips/127.0.0.1\/8/}
  read -r IP _ <<< "$_ips"
  IP=${IP/\/*} # strip subnet provided by ip address
  if [ -z "$IP" ]; then
    read -r IP _ <<< "$(hostname -I)"
  fi

I ran these lines into the server separately, while VPN was connected. The first one shows the IP correct. But the second one shows it wrong (10.8.0.2 which is something related to OpenVPN I think).

EDIT: I think the device is determined wrong. awk '$2 == 00000000 { print $1 }' /proc/net/route | head -1 shows tun0 when vpn is on, and shows eth0 when it's off. I think eth0 is correct here.

michi-80337 commented 2 years ago

The server is behind a NAT when OpenVPN is active. Both code snippets look after the default route on the server and retrieve the external interface from that route. If OpenVPN is active the default route goes over tun0. In the other case the default route goes over eth0. In a second step both code snippets use the interface name to get the IP address that is assigned to the interface. They retrieve the list of addresses assigned to the interface and take the first address from that list. The installation will fail, because the IP address 10.8.0.2 is not routeable. Hence You have to use the hostname of the OpenVPN public interface that Your communication partner is seeing while Your VPN is active. The public IP address has to be stable.

mokazemi commented 2 years ago

The server is behind a NAT when OpenVPN is active. Both code snippets look after the default route on the server and retrieve the external interface from that route. If OpenVPN is active the default route goes over tun0. In the other case the default route goes over eth0. In a second step both code snippets use the interface name to get the IP address that is assigned to the interface. They retrieve the list of addresses assigned to the interface and take the first address from that list. The installation will fail, because the IP address 10.8.0.2 is not routeable. Hence You have to use the hostname of the OpenVPN public interface that Your communication partner is seeing while Your VPN is active. The public IP address has to be stable.

No I disable the VPN when installation process finishes. The first script outputs eth0, even if the OpenVPN is on.

But I recently noticed something else. It sounds also Freeswitch somewhere in between, selects internal IP wrong, in the variables. So it should also be changed.

I ended up installing using passing proxy.