1

I'm trying to set up a Raspberry Pi running Raspbian Jessie with the following configuration:

  • DHCP Server (isc-dhcp-server)
  • WLAN Access Point (hostapd)
  • Application Server (HTTP server on port 80)

My problem is that devices connected to the WLAN AP cannot communicate with the webserver running on the Pi. Devices connected to the ethernet port have no trouble displaying the webpage.

When I connect my laptop to the AP and try to ping the Pi (10.10.1.1) it tells me that it is down. I do however get an IP address (e.g. 10.10.1.17). When using an ethernet cable to the Pi I receive an IP address and am able to ping the Pi on 10.10.1.1 so everything is worked when using a wired connection.

Here are my configuration files:

/etc/dhcp/dhcp.conf

ddns-update-style none;
authoritative;
log-facility local7;

subnet 10.10.1.0 netmask 255.255.255.0 {
   range 10.10.1.10 10.10.1.100;
   option routers 10.10.1.1;
   default-lease-time 3600;
   max-lease-time 3600;
   option subnet-mask 255.255.255.0;
   option broadcast-address 10.10.1.255;
   option domain-name-servers 8.8.8.8;
   option domain-name "support.muffag.ch";
}

/etc/default/isc-dhcp-server

INTERFACES="eth0 wlan0"

/etc/network/interfaces

source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

allow-hotplug eth0
auto eth0
iface eth0 inet static
       address 10.10.1.1
       netmask 255.255.255.0


allow-hotplug wlan0
auto wlan0
iface wlan0 inet static
        address 10.10.1.2
        netmask 255.255.255.0

/etc/hostapd/hostapd.conf

interface=wlan0
driver=rtl871xdrv
ssid=Test AP
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=Raspberry
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

/etc/default/hostapd

DAEMON_CONF="/etc/hostapd/hostapd.conf"

.

I've seen that other people are talking about a network bridge but I'm unsure on how to use something like that. How can I make sure that devices connected to the access point can reach the webserver?

2
  • Enable packet forwarding in /etc/sysctl.conf
    – Ijaz Ahmad
    Commented Jan 8, 2016 at 14:06
  • @IjazKhan Just did that and the problem still persists, thanks.
    – dislick
    Commented Jan 8, 2016 at 14:13

2 Answers 2

3

If your webserver is listening on port 80 of any IP address (not just 10.10.1.1), then you can just use the gateway address of the interface you are connected to.

However, before you can do that, you first need to fix the address ranges you are using. Your current configuration says to give 10.10.1.0-10.0.1.255 to eth0 and wlan0. This is bad. You either need to give different IP address ranges to the two interfaces or use a bridge network. If you want to easily allow the devices on wlan0 to communicate with devices on eth0 (as if they were on the same network), you'll need to use a bridge.

For using different address ranges, your /etc/network/interfaces file should look like the following:

source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

allow-hotplug eth0
auto eth0
iface eth0 inet static
       address 10.10.1.1
       netmask 255.255.255.0


allow-hotplug wlan0
auto wlan0
iface wlan0 inet static
        address 10.10.2.1
        netmask 255.255.255.0

Basically, 10.10.1.0-10.10.1.255 has been allocated to eth0, and 10.10.2.0-10.10.2.255 has been allocated to wlan0. You'll also need to change /etc/dhcp/dhcp.conf:

ddns-update-style none;
authoritative;
log-facility local7;

subnet 10.10.1.0 netmask 255.255.255.0 {
   range 10.10.1.10 10.10.1.100;
   option routers 10.10.1.1;
   default-lease-time 3600;
   max-lease-time 3600;
   option subnet-mask 255.255.255.0;
   option broadcast-address 10.10.1.255;
   option domain-name-servers 8.8.8.8;
   option domain-name "support.muffag.ch";
}

subnet 10.10.2.0 netmask 255.255.255.0 {
   range 10.10.2.10 10.10.2.100;
   option routers 10.10.2.1;
   default-lease-time 3600;
   max-lease-time 3600;
   option subnet-mask 255.255.255.0;
   option broadcast-address 10.10.2.255;
   option domain-name-servers 8.8.8.8;
   option domain-name "support.muffag.ch";
}

A section for the 10.10.2.0/24 network has been added.

At this point, you should be able to connect to the webserver. If you're connected to eth0, you need to use 10.10.1.1; if you're connected to wlan0, you need to use 10.10.2.1.

1

I suspect you've missed a step in your configuration, which allows packets to be forwarded between interfaces:

sysctl -w net.ipv4.ip_forward=1

When you have confirmed that this works for you, either edit /etc/sysctl.conf or add your own file to /etc/sysctl.d/ to make the change permanent.

2
  • Thanks, I've edited the file and rebooted but couldn't notice any difference. Any other ideas?
    – dislick
    Commented Jan 8, 2016 at 14:05
  • @dislick please try it as is, without a reboot Commented Jan 8, 2016 at 20:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .