# Discourse-setup uses ifconfig to check the IP address for Let's Encrypt, but it's not available on Debian stretch

**URL:** <https://meta.discourse.org/t/discourse-setup-uses-ifconfig-to-check-the-ip-address-for-lets-encrypt-but-its-not-available-on-debian-stretch/61080>\
**Category:** Bug\
**Created:** [2017年四月16日 21:14 UTC](https://meta.discourse.org/t/discourse-setup-uses-ifconfig-to-check-the-ip-address-for-lets-encrypt-but-its-not-available-on-debian-stretch/61080 "2017-04-16T21:14:53Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrisc](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chrisc/32/119982_2.png) [@chrisc](https://meta.discourse.org/u/chrisc)\
**Post date:** [2017年四月16日 21:14 UTC](https://meta.discourse.org/t/discourse-setup-uses-ifconfig-to-check-the-ip-address-for-lets-encrypt-but-its-not-available-on-debian-stretch/61080/1 "2017-04-16T21:14:53Z")

</div>

These lines in `discourse-setup` depend on `ifconfig`, but Debian Stretch doesn’t have `ifconfig`:

```bash
  local IFACE=none
  local IFCONFIG=`which ifconfig`
  /sbin/route |grep default > /tmp/route$PPID

  if grep default /tmp/route$PPID > /dev/null
  then
      local IFACE=`cut -c 73-100 /tmp/route$PPID |head -1`
  else
    echo WARNING: Cannot check your IP number.
  fi
  local IP=`$IFCONFIG $IFACE|grep "inet addr:" |cut -d":" -f 2|cut -d" " -f1|head -1`

```

The way I check for the IP address on Debian Stretch is to use `hostname -i`, for example:

```bash
#!/bin/bash

local IFCONFIG=$(which ifconfig)
local HOSTNAME=$(which hostname)

# Check is ifconfig is available
if [[${IFCONFIG}]]; then
  # https://stackoverflow.com/a/4046101
  local IP=$($IFCONFIG | fgrep 'inet addr:' | fgrep -v '127.0.0.1' | cut -d: -f2 | awk '{print $1}' | head -n1)
# If we don't have ifconfig then try to use hostname
elif [[${HOSTNAME}]]; then
  local IP=$(hostname -i)
else
  echo "Sorry, couldn't find ifconfig or hostname so couldn't use them to work out the local IP address"
fi

```

---

<div class="post-metadata">

**Author:** ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)\
**Post date:** [2017年四月16日 21:17 UTC](https://meta.discourse.org/t/discourse-setup-uses-ifconfig-to-check-the-ip-address-for-lets-encrypt-but-its-not-available-on-debian-stretch/61080/2 "2017-04-16T21:17:07Z")

</div>

Aha this is an issue for @pfaffman

I wonder how many distros do not have this command? I suggest we skip the check if the command is missing, assuming it is a rare thing in a distro.

---

<div class="post-metadata">

**Author:** ![chrisc](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chrisc/32/119982_2.png) [@chrisc](https://meta.discourse.org/u/chrisc)\
**Post date:** [2017年四月16日 21:19 UTC](https://meta.discourse.org/t/discourse-setup-uses-ifconfig-to-check-the-ip-address-for-lets-encrypt-but-its-not-available-on-debian-stretch/61080/3 "2017-04-16T21:19:38Z")

</div>

It is good to do this check, `hostname -i` is a lot simpler than getting the IP address from `ifconfig`.

---

<div class="post-metadata">

**Author:** ![chrisc](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chrisc/32/119982_2.png) [@chrisc](https://meta.discourse.org/u/chrisc)\
**Post date:** [2017年四月16日 21:33 UTC](https://meta.discourse.org/t/discourse-setup-uses-ifconfig-to-check-the-ip-address-for-lets-encrypt-but-its-not-available-on-debian-stretch/61080/4 "2017-04-16T21:33:26Z")

</div>

A couple of other things, `dig` is part of `dnsutils` which isn’t installed by default so needs to be installed before this check will work, furthermore if the local dns server resolves an address it isn’t always the case that a public one will – you could consider if it would be safer to use a public server, for example `dig @8.8.8.8`.

---

<div class="post-metadata">

**Author:** ![kraml](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kraml/32/68627_2.png) [@kraml](https://meta.discourse.org/u/kraml)\
**Post date:** [2017年四月17日 02:52 UTC](https://meta.discourse.org/t/discourse-setup-uses-ifconfig-to-check-the-ip-address-for-lets-encrypt-but-its-not-available-on-debian-stretch/61080/5 "2017-04-17T02:52:04Z")

</div>

Not only Debian, but some other distro don’t install ifconfig by default in a minimal setup, including CentOS 7. It is still available in the `net-tools` package for CentOS 7 as part of the base repository, and I believe Debain should have it too, just not sure whether they use the same package name.

Newer distros moved to `iproute` package. The new `ip` command from this package now does ifconfig/route and many other tasks. To get IP address, just use `ip addr` (multiline output) or `ip -o addr` (single line output for each interface).

---

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [2017年四月17日 03:19 UTC](https://meta.discourse.org/t/discourse-setup-uses-ifconfig-to-check-the-ip-address-for-lets-encrypt-but-its-not-available-on-debian-stretch/61080/6 "2017-04-17T03:19:19Z")

</div>

> [@chrisc](#):
>
> Debian Stretch doesn’t have ifconfig:

Well, the version that Digital Ocean installs has ifconfig. `hostname -i` on the Digital Ocean droplet I just checked returns 127.0.1.1, so that doesn’t seem helpful.

> [@codinghorror](#):
>
> I wonder how many distros do not have this command?

I don’t remember any in the past 20 years. Apparently, it’s been [deprecated](https://linuxconfig.org/how-to-install-missing-ifconfig-command-on-debian-linux). It seems that `ip -a` is the New Way.

It worked on Centos, which now appears to work with the Docker that ./discourse-setup will install (alas, that script doesn’t actually start Docker, but I can probably fix it so that it will).

It could be that Digital Ocean adds `ifconfig`.

One or both of Debian and Centos are missing `git`.

I think I can do a bit of work and make `./discourse-setup` work for Ubuntu, Debian, and Centos, including installing Docker and `git`.

---

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [2017年四月17日 03:34 UTC](https://meta.discourse.org/t/discourse-setup-uses-ifconfig-to-check-the-ip-address-for-lets-encrypt-but-its-not-available-on-debian-stretch/61080/7 "2017-04-17T03:34:51Z")

</div>

Oops. Discourse-setup can’t install install git. Chicken. Eggs.

---

<div class="post-metadata">

**Author:** ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)\
**Post date:** [2017年四月17日 05:15 UTC](https://meta.discourse.org/t/discourse-setup-uses-ifconfig-to-check-the-ip-address-for-lets-encrypt-but-its-not-available-on-debian-stretch/61080/8 "2017-04-17T05:15:26Z")

</div>

Probably we need a different command that is more compatible with more distros.
