2

I have a linux box and has ethernet, wlan STA/client and wlan Access Point. It's a internet connection via ethernet and I can log in to the box via ssh. But I wish to use the box like a wireless router and be able to connect to internet by using for example a smart phone. I can connect my phone to wifi but it has no internet access.

Here are my interfaces:

eth0 is Ethernet
eth1 and eth2 is WLAN

# ifconfig
br0       Link encap:Ethernet  HWaddr 00:15:BC:22:17:20
          inet addr:10.10.1.116  Bcast:10.10.1.255  Mask:255.255.255.0
          inet6 addr: fe80::215:bcff:fe22:1720/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6377 errors:0 dropped:608 overruns:0 frame:0
          TX packets:615 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:865911 (845.6 KiB)  TX bytes:59751 (58.3 KiB)

eth0      Link encap:Ethernet  HWaddr 00:15:BC:22:17:20
          inet6 addr: fe80::215:bcff:fe22:1720/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6417 errors:0 dropped:6 overruns:0 frame:0
          TX packets:623 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:985364 (962.2 KiB)  TX bytes:60399 (58.9 KiB)

eth1      Link encap:Ethernet  HWaddr 00:15:BC:22:17:21
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

eth2      Link encap:Ethernet  HWaddr 02:15:BC:22:17:21
          inet addr:192.168.2.10  Bcast:192.168.2.255  Mask:255.255.255.0
          inet6 addr: fe80::15:bcff:fe22:1721/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:502 errors:0 dropped:3 overruns:0 frame:0
          TX packets:236 errors:0 dropped:8 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:44998 (43.9 KiB)  TX bytes:24874 (24.2 KiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:164 errors:0 dropped:0 overruns:0 frame:0
          TX packets:164 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:13525 (13.2 KiB)  TX bytes:13525 (13.2 Ki

B)

And here is /etc/network/interfaces file:

auto lo
iface lo inet loopback

iface eth0 inet manual

iface eth1 inet dhcp

iface eth2 inet dhcp

iface br0 inet dhcp
hostname gw-143A
   bridged_ports  eth0

Wireless:

# iwconfig
tap0      no wireless extensions.

lo        no wireless extensions.

br0       no wireless extensions.

eth2      IEEE 802.11-bgn  Mode:Master  Frequency:2.457 GHz

eth1      IEEE 802.11-bgn  ESSID:""
          Mode:Managed  Frequency:2.437 GHz  Access Point: Not-Associated
          Bit Rate:0 kb/s
          RTS thr:off   Fragment thr:off
          Encryption key:9F64-0D78-CCAB-A8 [3]
          Power Management:off
          Link Quality:0  Signal level:0  Noise level:0
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

sit0      no wireless extensions.

eth0      no wireless extensions.
1

In order for your linux box to act as a WLAN access point, you will need to:

  • make sure your wireless NICs use a driver which supports AP. Output of lsmod | grep 80211 usually helps. If your driver doesn't support AP mode, you'll have to get a new WLAN adapter which does.
  • make sure your kernels supports IP forwarding and enable it. This is usually done by running echo 1 > /proc/sys/net/ipv4/ip_forward as root.
  • configure routing tables to forward network packets from br0 to eth2:

sudo iptables -t nat -A POSTROUTING -o br0 -j MASQUERADE

sudo iptables -A FORWARD -i br0 -o eth2 -m state --state RELATED,ESTABLISHED -j ACCEPT

sudo iptables -A FORWARD -i eth2 -o br0 -j ACCEPT

  • Thank you for your answer. I have tried just as you have described. But still not succeeded. I forgot to mention that I run the buildroot. – pomegranatex Aug 23 '16 at 9:42
  • 1
    It works now. I have changed DNS to 8.8.8.8 on my phone. Thanks again – pomegranatex Aug 23 '16 at 11:25
  • @pomegranatex Good. Thanks for reporting back! – Dmitry Grigoryev Aug 23 '16 at 11:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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