oblique / create_ap

[NOT MAINTAINED] This script creates a NATed or Bridged WiFi Access Point.
BSD 2-Clause "Simplified" License
4.45k stars 1k forks source link

Bridge mode does not work #60

Open solsticedhiver opened 9 years ago

solsticedhiver commented 9 years ago

hi. I just tried your "little" script inside a kali VM with an USB wifi dongle.

I run

$ ./create_ap.sh -m bridge wlan0 eth0 MonOuiPhi autruchecourrantdanslasavane
Config dir: /tmp/create_ap.wlan0.conf.bGtr8XqE 
PID: 4483
Creating a virtual WiFi interface... ap0 created.
Sharing Internet using method: bridge
Create a bridge interface... br0 created.
hostapd command-line interface: hostapd_cli -p /tmp/create_ap.wlan0.conf.bGtr8XqE/hostapd_ctrl
Configuration file: /tmp/create_ap.wlan0.conf.bGtr8XqE/hostapd.conf
Failed to update rate sets in kernel module
Using interface ap0 with hwaddr yy:yy:yy:yy:yy:yy and ssid 'MonOuiPhi'
ap0: STA xx:xx:xx:xx:xx:xx IEEE 802.11: authenticated
ap0: STA xx:xx:xx:xx:xx:xx IEEE 802.11: associated (aid 1)
ap0: AP-STA-CONNECTED xx:xx:xx:xx:xx:xx
ap0: STA xx:xx:xx:xx:xx:xx RADIUS: starting accounting session 54B208F6-00000000
ap0: STA xx:xx:xx:xx:xx:xx WPA: pairwise key handshake completed (RSN)

The AP shows up on wifi scan, the wifi client is able to connect and to get an IP address via DHCP, but one can not reach the internet.

a simple "ping 8.8.8.8" gives "Destination Host unreachable" Something is broken or missing

oblique commented 9 years ago

I just downloaded the latest Kali (1.0.9a) and installed: hostapd, bridge-utils After that I tried your command and everything works fine. Try to connect to the AP from another device and test it. Also try to bridge your VM interface.

What wifi adapter do you have? Also post me the output of iw list.

oblique commented 9 years ago

BTW, what VM do you use? I use VirtualBox and the host machine is ArchLinux.

solsticedhiver commented 9 years ago

my host is ubuntu 14.10. The wifi key is TP-Link TL-WN722N. It is working fine in AP mode. The only problem is sometimes it locks up. And yes, my VM (virtualbox) uses bridge network.

As I said, what's strange is that the wifi client (phone) can connect to the AP, can get an IP from DHCP, but then nothing. The phone got assigned is normal IP (192.168.0.42) that it normally has when using wifi without hostpad. So it has been able to get that IP through the bridge on the local LAN and to connect with the router at 192.168.0.254.

But once there, I am able to ping the other PCs on the LAN but not 192.168.0.254! Correction:I am able to ping 192.168.0.12, 192.168.0.10 which are in the virtualbox bridge but not outside the latptop like 192.168.0.254 or 192.192.168.0.18 or 8.8.8.8

From within the VM I can go on the net. But not from the wifi client.

# iw list
Wiphy phy0
    Band 1:
        Capabilities: 0x116e
            HT20/HT40
            SM Power Save disabled
            RX HT20 SGI
            RX HT40 SGI
            RX STBC 1-stream
            Max AMSDU length: 3839 bytes
            DSSS/CCK HT40
        Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
        Minimum RX AMPDU time spacing: 8 usec (0x06)
        HT TX/RX MCS rate indexes supported: 0-7
        Frequencies:
            * 2412 MHz [1] (20.0 dBm)
            * 2417 MHz [2] (20.0 dBm)
            * 2422 MHz [3] (20.0 dBm)
            * 2427 MHz [4] (20.0 dBm)
            * 2432 MHz [5] (20.0 dBm)
            * 2437 MHz [6] (20.0 dBm)
            * 2442 MHz [7] (20.0 dBm)
            * 2447 MHz [8] (20.0 dBm)
            * 2452 MHz [9] (20.0 dBm)
            * 2457 MHz [10] (20.0 dBm)
            * 2462 MHz [11] (20.0 dBm)
            * 2467 MHz [12] (20.0 dBm)
            * 2472 MHz [13] (20.0 dBm)
            * 2484 MHz [14] (disabled)
        Bitrates (non-HT):
            * 1.0 Mbps
            * 2.0 Mbps (short preamble supported)
            * 5.5 Mbps (short preamble supported)
            * 11.0 Mbps (short preamble supported)
            * 6.0 Mbps
            * 9.0 Mbps
            * 12.0 Mbps
            * 18.0 Mbps
            * 24.0 Mbps
            * 36.0 Mbps
            * 48.0 Mbps
            * 54.0 Mbps
    max # scan SSIDs: 4
    max scan IEs length: 2257 bytes
    Coverage class: 0 (up to 0m)
    Supported Ciphers:
        * WEP40 (00-0f-ac:1)
        * WEP104 (00-0f-ac:5)
        * TKIP (00-0f-ac:2)
        * CCMP (00-0f-ac:4)
        * CMAC (00-0f-ac:6)
    Available Antennas: TX 0x1 RX 0x1
    Configured Antennas: TX 0x1 RX 0x1
    Supported interface modes:
         * IBSS
         * managed
         * AP
         * AP/VLAN
         * monitor
         * mesh point
         * P2P-client
         * P2P-GO
    software interface modes (can always be added):
         * AP/VLAN
         * monitor
    valid interface combinations:
         * #{ managed, P2P-client } <= 2, #{ AP, mesh point, P2P-GO } <= 2,
           total <= 2, #channels <= 1
    Supported commands:
         * new_interface
         * set_interface
         * new_key
         * new_beacon
         * new_station
         * new_mpath
         * set_mesh_params
         * set_bss
         * authenticate
         * associate
         * deauthenticate
         * disassociate
         * join_ibss
         * join_mesh
         * remain_on_channel
         * set_tx_bitrate_mask
         * action
         * frame_wait_cancel
         * set_wiphy_netns
         * set_channel
         * set_wds_peer
         * Unknown command (84)
         * Unknown command (87)
         * Unknown command (85)
         * Unknown command (89)
         * Unknown command (92)
         * connect
         * disconnect
    Supported TX frame types:
         * IBSS: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
         * managed: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
         * AP: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
         * AP/VLAN: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
         * mesh point: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
         * P2P-client: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
         * P2P-GO: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
         * Unknown mode (10): 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
    Supported RX frame types:
         * IBSS: 0x40 0xb0 0xc0 0xd0
         * managed: 0x40 0xd0
         * AP: 0x00 0x20 0x40 0xa0 0xb0 0xc0 0xd0
         * AP/VLAN: 0x00 0x20 0x40 0xa0 0xb0 0xc0 0xd0
         * mesh point: 0xb0 0xc0 0xd0
         * P2P-client: 0x40 0xd0
         * P2P-GO: 0x00 0x20 0x40 0xa0 0xb0 0xc0 0xd0
         * Unknown mode (10): 0x40 0xd0
    Device supports RSN-IBSS.
    HT Capability overrides:
         * MCS: ff ff ff ff ff ff ff ff ff ff
         * maximum A-MSDU length
         * supported channel width
         * short GI for 40 MHz
         * max A-MPDU length exponent
         * min MPDU start spacing
    Device supports TX status socket option.
    Device supports HT-IBSS.

hostapd

solsticedhiver commented 9 years ago

Ok. I have found that if I connect the laptop to the modem/router with ethernet this is working. I.e. the phone wifi client connected to the AP from hostapd can go th net.

But if the latptop is connected on the AP#1 (fxxx) of the router, I can not pass on to the router and the net from the phone wifi client of the other AP#2 (MonOuiPhi). the AP#1 is on channel 1. I was using channel 3 for MonOuiPhi. now using channel 6. and still not working So I don't think it's too close channel but another restriction in ubuntu or something in network/wireless stack or virtualbox

Note: this is working in nat mode even if there are 2 wifi APs

oblique commented 9 years ago

By the WiFi protocol you can not bridge a wifi interface to another one. If you change the VM network to NAT it should work. The strange thing is that VirtualBox has a mechanism to bridge through wifi interface, so I will investigate it and see if there is a way to solve this problem.

oblique commented 9 years ago

Probably this will be solved if I implement pseudo-bridge (#38). Which I don't have much time to investigate it at the moment.

solsticedhiver commented 9 years ago

I have no practical use of this. I was just testing things to discover.

ribamar-santarosa commented 6 years ago

Also not working for me:

sudo ./create_ap -m bridge wlo1 ppp0 tinga tijolo22
# Config dir: /tmp/create_ap.wlo1.conf.A7AcJq1Q
# PID: 20089
# Network Manager found, set ap0 as unmanaged device... DONE
# Creating a virtual WiFi interface... ap0 created.
# Sharing Internet using method: bridge
# Create a bridge interface... 

And then it stays forever. I checked the source code of the script and found that

    (nmcli -t -f DEVICE,STATE d 2>&1 | grep -E "^$1:unmanaged$" > /dev/null 2>&1) || return 1

is always returning 1 (and it's called from withing an infinite loop).

          *-network
                description: Wireless interface
                product: Wireless 7265
                vendor: Intel Corporation
                physical id: 0
                bus info: pci@0000:03:00.0
                logical name: wlo1
                version: 48
                serial: fa:00:68:b6:83:f8
                width: 64 bits
                clock: 33MHz
                capabilities: bus_master cap_list ethernet physical wireless
                configuration: broadcast=yes driver=iwlwifi driverversion=4.9.0-3-amd64 firmware=17.352738.0 latency=0 link=no multicast=yes wireless=IEEE 802.11
                resources: irq:50 memory:c1000000-c1001fff

I have these modules loaded:

lsmod  | grep wi
iwlwifi               147456  1 iwlmvm
cfg80211              589824  3 iwlmvm,iwlwifi,mac80211
hp_wireless            16384  0
ghost commented 5 years ago

Having a similar issue with a less ... interesting? ... set-up.

This is a MintBox Mini Pro. It has a dual-channel wifi chip; I have it plugged into the router, and it's running whatever Ubuntu variant that it came with.

The script looks like it's working just fine; it sets up the bridge I asked for from the wifi to the ethernet, reports no errors, and I can connect to the AP with my phone. However, I get a "no internet" message from Android. I suspect this is because the dnsmasq that's being executed isn't working; given that ps shows dnsmasq being run with --listen-address=127.0.1.1,

$ nslookup www.google.com 127.0.1.1
Server:         127.0.1.1
Address:        127.0.1.1#53

** server can't find www.google.com: REFUSED

From what I can find online, disabling IPv6 lookups for dnsmasq resolves the issue for some people; this can be achieved through the config file, but since create_ap isn't using a config file for dnsmasq, how would I achieve this -- or at least try and see if it fixes the issue?

Incidentally, I can nslookup domains via either IPv4 or IPv6 nameservers from the same host, just not from the local dnsmasq service.