You are not logged in.

#51 2013-11-30 05:29:41

OBLiQUE
Member
Registered: 2008-12-04
Posts: 107
Website

Re: [script] create_ap: Create a NATed or Bridged WiFi Access Point

my pleasure smile

Offline

#52 2013-12-19 16:45:49

mtrokic
Member
From: Montreal
Registered: 2009-10-24
Posts: 56
Website

Re: [script] create_ap: Create a NATed or Bridged WiFi Access Point

Dear All,

I have a problem which I don't know how to solve since I don't have the technical knowledge necessary with networking. Currently, I am using create_ap to allow some of my devices to connect to the internet through my laptop internet connection. I also frequently use an SSH proxy tunnel with the -ND option to connect to a computer outside of the country I am residing in. What I would like to do is to make my internet sharing with create_ap go through that same proxy and I haven't a clue how to proceed. I have been reading about iptables and such and I am just lost. Hopefully someone will be able to solve this for me. Thanks in advance.

Offline

#53 2013-12-20 06:42:24

OBLiQUE
Member
Registered: 2008-12-04
Posts: 107
Website

Re: [script] create_ap: Create a NATed or Bridged WiFi Access Point

You can use redsocks to redirect all outbound connections to the proxy.
official site: https://darkk.net.ru/redsocks/
tutorial: http://linuxaria.com/article/redirect-a … y-in-linux
AUR package: https://aur.archlinux.org/packages.php?ID=41765

Another way is to use vpn instead of ssh's socks proxy.

Offline

#54 2013-12-20 19:41:06

mtrokic
Member
From: Montreal
Registered: 2009-10-24
Posts: 56
Website

Re: [script] create_ap: Create a NATed or Bridged WiFi Access Point

Thank you OBLiQUE. I was not successful with redsocks. For some reason I couldnt establish a global proxy for my system. I was finally able to achieve my goal by using sshuttle and issuing

create_ap wlan0 eth0 ...
sshuttle -Nr username@server 0/0 -l 0.0.0.0

Shhuttle is really an impressive tool and create_ap is fantastic as well!

Last edited by mtrokic (2013-12-20 19:41:45)

Offline

#55 2013-12-21 07:58:27

OBLiQUE
Member
Registered: 2008-12-04
Posts: 107
Website

Re: [script] create_ap: Create a NATed or Bridged WiFi Access Point

Didn't know about sshuttle, thanks for sharing

Offline

#56 2013-12-22 01:50:58

AG Caesar
Member
From: Germany
Registered: 2013-01-19
Posts: 17

Re: [script] create_ap: Create a NATed or Bridged WiFi Access Point

Great script, but since the last update it broke on my computer. It worked perfectly, but now i get:

caesar@caesar ~ % sudo create_ap wlan0 eth0 MyAccessPoint
Config dir: /tmp/create_ap.wlan0.conf.IvpS9XrU
Creating a virtual WiFi interface... wlan0ap created.
RTNETLINK answers: Invalid argument

Doing cleanup...
iptables: No chain/target/match by that name.
iptables: Bad rule (does a matching rule exist in that chain?).
iptables: Bad rule (does a matching rule exist in that chain?).
iptables: Bad rule (does a matching rule exist in that chain?).
iptables: Bad rule (does a matching rule exist in that chain?).
iptables: Bad rule (does a matching rule exist in that chain?).

I use a D-Link System DWA-140 RangeBooster N Adapter(rev.B1) [Ralink RT2870] USB wlan stick which i did not change... Any help? smile


[Edit]
I did look at the git Bugtracker and there was the solution. Sorry, I could have looked there earlier...
sudo create_ap --no-virt wlan0 eth0 MyAccessPoint
te --no-virt Option helpes and solves all problems!

Last edited by AG Caesar (2013-12-22 15:29:17)

Offline

#57 2013-12-22 20:23:17

arokh
Member
Registered: 2013-05-30
Posts: 35

Re: [script] create_ap: Create a NATed or Bridged WiFi Access Point

Very useful script, thanks a bunch!!

I'm using it to set up a NAT'ed AP on my already connected wlan. Works fine if I'm connected on 2.4GHz but if my wlan is connected with 5GHz it doesn't work:

$ sudo ./create_ap wlp2s0 wlp2s0 NUC password
Config dir: /tmp/create_ap.wlp2s0.conf.qB1GriZm
hostapd will fail to use channel 1 because wlp2s0 is already set to channel 44, fallback to channel 44.
Creating a virtual WiFi interface... wlp2s0ap created.
Sharing Internet using method: nat
hostapd command-line interface: hostapd_cli -p /tmp/create_ap.wlp2s0.conf.qB1GriZm/hostapd_ctrl
Configuration file: /tmp/create_ap.wlp2s0.conf.qB1GriZm/hostapd.conf
wlp2s0ap: IEEE 802.11 Configured channel (44) not found from the channel list of current mode (1) IEEE 802.11g
wlp2s0ap: IEEE 802.11 Hardware does not support configured channel
Could not select hw_mode and channel. (-4)
wlp2s0ap: Unable to setup interface.

ERROR: Failed to run hostapd, maybe a program is interfering.

I'm connected on channel 44 to my regular wlan already so why does it say unsupported channel? Like I said, works fine if I'm on 2.4GHz hmm

Offline

#58 2013-12-22 21:44:40

OBLiQUE
Member
Registered: 2008-12-04
Posts: 107
Website

Re: [script] create_ap: Create a NATed or Bridged WiFi Access Point

arokh wrote:

I'm connected on channel 44 to my regular wlan already so why does it say unsupported channel? Like I said, works fine if I'm on 2.4GHz hmm

Thanks, I will add 802.11n support in few days.

Offline

#59 2013-12-23 12:13:33

OBLiQUE
Member
Registered: 2008-12-04
Posts: 107
Website

Re: [script] create_ap: Create a NATed or Bridged WiFi Access Point

@arokh Unfortunately, hostapd does not fully support 802.11n (5GHz) channels, I looked a bit in their code but I couldn't find a way to enable them. But, I will check again on my free time and if I find a way to do it, I will update my script.

Offline

#60 2013-12-23 20:26:18

arokh
Member
Registered: 2013-05-30
Posts: 35

Re: [script] create_ap: Create a NATed or Bridged WiFi Access Point

Hm I'm pretty sure it does? OpenWRT uses hostapd for 802.11n on 5GHz I believe?

What about 802.11n on 2.4GHz? Anyways thx for looking into it.

Offline

#61 2013-12-23 20:57:11

Gusar
Member
Registered: 2009-08-25
Posts: 3,605

Re: [script] create_ap: Create a NATed or Bridged WiFi Access Point

Are you guys aware that you don't need hostapd to run an AP? wpa_supplicant can do it. I haven't tried it with 5GHz, but I don't see why it wouldn't work. The config looks like this:

network={
    ssid="ssid_here"
    mode=2
    frequency=5220
    key_mgmt=WPA-PSK
    proto=RSN
    pairwise=CCMP
    group=CCMP
    psk="passphrase"
}

mode=2 is the setting to create an AP. In this particular instance we're creating a WPA2-only network with CCMP/AES encryption. And 5220 is the frequency of channel 44.

Last edited by Gusar (2013-12-23 21:03:04)

Offline

#62 2013-12-24 09:11:52

OBLiQUE
Member
Registered: 2008-12-04
Posts: 107
Website

Re: [script] create_ap: Create a NATed or Bridged WiFi Access Point

@arokh I will check OpenWRT when I have free time and yes 802.11n on 2.4GHz is supported.

@Gusar Didn't know about it.

Offline

#63 2013-12-27 17:09:37

dare023
Member
Registered: 2010-04-21
Posts: 64

Re: [script] create_ap: Create a NATed or Bridged WiFi Access Point

Hi, I am trying to use this script to make hotspot for my phone and tablet.
Problem is that I need to bridge 3g connection to wlan0
I tried this:

sudo ./create_ap --no-virt ppp0 wlan0 MyAccessPoint

and got this :

Config dir: /tmp/create_ap.ppp0.conf.lnm5ZCr8
Network Manager config found, set ppp0 as unmanaged device... DONE
Sharing Internet using method: nat

dnsmasq: failed to create listening socket for 127.0.0.1: Address already in use

Doing cleanup...

Can you help me to get this working?
I tried killall dnsmasq, but it is not running?
Thank you in advance.

Offline

#64 2013-12-28 17:03:22

OBLiQUE
Member
Registered: 2008-12-04
Posts: 107
Website

Re: [script] create_ap: Create a NATed or Bridged WiFi Access Point

Your parameters are wrong, the first interface must be the AP interface and the second interface must be the Internet interface. So you must execute:

sudo ./create_ap --no-virt wlan0 ppp0 MyAccessPoint

Now, about the dnsmasq, maybe another dns daemon is running. You can check with:

sudo netstat -pntl | grep ':53'

Another thing you can do, is to use bridge mode instead of NAT mode:

sudo ./create_ap --no-virt -m bridge wlan0 ppp0 MyAccessPoint

Last edited by OBLiQUE (2013-12-28 17:04:12)

Offline

#65 2013-12-28 17:30:17

OBLiQUE
Member
Registered: 2008-12-04
Posts: 107
Website

Re: [script] create_ap: Create a NATed or Bridged WiFi Access Point

BTW, on android phones there is a build in service for that. Google search: android hotspot

Offline

#66 2013-12-29 08:34:22

dare023
Member
Registered: 2010-04-21
Posts: 64

Re: [script] create_ap: Create a NATed or Bridged WiFi Access Point

OBLiQUE wrote:

BTW, on android phones there is a build in service for that. Google search: android hotspot

I know that wink. I just have good plan on 3g net and prefer to use wireless on phone when I can, but thank you.

Well, I did find dnsmasq running, from Networkmanager (kde). I stopped it and got this:

[me@laptop create_ap-master]$ sudo ./create_ap --no-virt wlan0 ppp0 MyAccessPoint
Config dir: /tmp/create_ap.wlan0.conf.UkXpBXKt
Network Manager config found, set wlan0 as unmanaged device... DONE
Sharing Internet using method: nat
hostapd command-line interface: hostapd_cli -p /tmp/create_ap.wlan0.conf.UkXpBXKt/hostapd_ctrl
Configuration file: /tmp/create_ap.wlan0.conf.UkXpBXKt/hostapd.conf
nl80211: Failed to set interface wlan0 into AP mode
nl80211 driver initialization failed.

ERROR: Failed to run hostapd, maybe a program is interfering.


Doing cleanup...

I guess this is related to this post?

OBLiQUE wrote:

Thanks, I will add 802.11n support in few days.

Hostapd is installed.
When trying as bridge got this

[me@laptop create_ap-master]$ sudo ./create_ap --no-virt -m bridge wlan0 ppp0 MyAccessPoint
Config dir: /tmp/create_ap.wlan0.conf.3JSBLRLS
Network Manager config found, set wlan0 as unmanaged device... DONE
Sharing Internet using method: bridge
can't add ppp0 to bridge br0: Invalid argument

Doing cleanup...

Thank you for helping.

Last edited by dare023 (2013-12-29 08:36:19)

Offline

#67 2013-12-29 10:03:35

OBLiQUE
Member
Registered: 2008-12-04
Posts: 107
Website

Re: [script] create_ap: Create a NATed or Bridged WiFi Access Point

dare023 wrote:

Well, I did find dnsmasq running, from Networkmanager (kde). I stopped it and got this:

[me@laptop create_ap-master]$ sudo ./create_ap --no-virt wlan0 ppp0 MyAccessPoint
Config dir: /tmp/create_ap.wlan0.conf.UkXpBXKt
Network Manager config found, set wlan0 as unmanaged device... DONE
Sharing Internet using method: nat
hostapd command-line interface: hostapd_cli -p /tmp/create_ap.wlan0.conf.UkXpBXKt/hostapd_ctrl
Configuration file: /tmp/create_ap.wlan0.conf.UkXpBXKt/hostapd.conf
nl80211: Failed to set interface wlan0 into AP mode
nl80211 driver initialization failed.

ERROR: Failed to run hostapd, maybe a program is interfering.


Doing cleanup...

I guess this is related to this post?

OBLiQUE wrote:

Thanks, I will add 802.11n support in few days.

No. Maybe your wifi adapter does not support AP mode or maybe a program is interfering.
You can edit the script and change this:

hostapd $CONFDIR/hostapd.conf || die "Failed to run hostapd, maybe a program is interfering."

to this:

hostapd -dd $CONFDIR/hostapd.conf || die "Failed to run hostapd, maybe a program is interfering."

and paste the debug messages.

Offline

#68 2013-12-29 10:14:36

dare023
Member
Registered: 2010-04-21
Posts: 64

Re: [script] create_ap: Create a NATed or Bridged WiFi Access Point

Hope this helps:

[me@laptop create_ap-master]$ sudo ./create_ap --no-virt wlan0 ppp0 MyAccessPoint
Config dir: /tmp/create_ap.wlan0.conf.BmYR6BJ5
Network Manager config found, set wlan0 as unmanaged device... DONE
Sharing Internet using method: nat
hostapd command-line interface: hostapd_cli -p /tmp/create_ap.wlan0.conf.BmYR6BJ5/hostapd_ctrl
random: Trying to read entropy from /dev/random
Configuration file: /tmp/create_ap.wlan0.conf.BmYR6BJ5/hostapd.conf
ctrl_interface_group=0
nl80211: interface wlan0 in phy phy0
rfkill: initial event: idx=0 type=1 op=0 soft=0 hard=0
rfkill: initial event: idx=1 type=1 op=0 soft=0 hard=0
rfkill: initial event: idx=2 type=2 op=0 soft=1 hard=0
nl80211: Using driver-based off-channel TX
nl80211: Add own interface ifindex 3
nl80211: Set mode ifindex 3 iftype 3 (AP)
nl80211: Failed to set interface 3 to mode 3: -95 (Operation not supported)
nl80211: Interface already in requested mode - ignore error
nl80211: Setup AP - device_ap_sme=0 use_monitor=0
nl80211: Subscribe to mgmt frames with AP handle 0x89113d8
nl80211: Register frame type=0xb0 nl_handle=0x89113d8
nl80211: Register frame match - hexdump(len=0): [NULL]
nl80211: Register frame command failed (type=176): ret=-22 (Invalid argument)
nl80211: Register frame match - hexdump(len=0): [NULL]
nl80211: Failed to set interface wlan0 into AP mode
netlink: Operstate: linkmode=0, operstate=6
nl80211: Set mode ifindex 3 iftype 2 (STATION)
nl80211 driver initialization failed.

ERROR: Failed to run hostapd, maybe a program is interfering.


Doing cleanup...

and as bridge

[me@laptop create_ap-master]$ sudo ./create_ap --no-virt -m bridge wlan0 ppp0 MyAccessPoint
Config dir: /tmp/create_ap.wlan0.conf.hTys1UK6                                                                             
Network Manager config found, set wlan0 as unmanaged device... DONE                                                        
Sharing Internet using method: bridge                                                                                      
can't add ppp0 to bridge br0: Invalid argument                                                                             
                                                                                                                           
Doing cleanup...         

Thanks.

Offline

#69 2013-12-29 11:09:18

OBLiQUE
Member
Registered: 2008-12-04
Posts: 107
Website

Re: [script] create_ap: Create a NATed or Bridged WiFi Access Point

nl80211: Set mode ifindex 3 iftype 3 (AP)
nl80211: Failed to set interface 3 to mode 3: -95 (Operation not supported)

Your interface does not support AP mode.

Offline

#70 2013-12-29 11:10:40

dare023
Member
Registered: 2010-04-21
Posts: 64

Re: [script] create_ap: Create a NATed or Bridged WiFi Access Point

Oh, well, what to do...
Thank you, man!

Offline

#71 2014-01-13 13:37:28

Jamp
Member
Registered: 2009-04-25
Posts: 10

Re: [script] create_ap: Create a NATed or Bridged WiFi Access Point

Hi, I had similar problems as dare, but knew that AP works on my card (it worked before).

I have Intel Centrino Advanced-N 6205 and iwlwifi driver.

What made the create_ap script work for me was setting WPA supplicant driver to wext in wicd preferences, so I guess there is some kind of conflict. Hope this helps somebody

Offline

#72 2014-01-13 14:05:41

OBLiQUE
Member
Registered: 2008-12-04
Posts: 107
Website

Re: [script] create_ap: Create a NATed or Bridged WiFi Access Point

@jamp: I have exactly the same WiFi adapter and I don't have this problem. So, for sure your problem is somewhere else. What error did you get?

Offline

#73 2014-01-30 10:18:51

spondbob
Member
Registered: 2014-01-30
Posts: 8
Website

Re: [script] create_ap: Create a NATed or Bridged WiFi Access Point

spondbob@bikinibottom ~/create_ap :( (master)
$ sudo ./create_ap --driver rtl871xdrv -n wlan0 myssid mypassword
Config dir: /tmp/create_ap.wlan0.conf.Nl6ZZz1n
nl80211 not found.
Creating a virtual WiFi interface... nl80211 not found.

ERROR: Maybe your WiFi adapter does not fully support virtual interfaces.
       Try again with --no-virt.


Doing cleanup...
iptables: Bad rule (does a matching rule exist in that chain?).
iptables: Bad rule (does a matching rule exist in that chain?).
iptables: Bad rule (does a matching rule exist in that chain?).

why it keeps using nl80211? I can confirm that the driver exist and working by running sudo hostapd -dd /etc/hostapd/hostapd.conf

Offline

#74 2014-01-31 13:54:27

ltb
Member
Registered: 2013-12-19
Posts: 4

Re: [script] create_ap: Create a NATed or Bridged WiFi Access Point

thanks a lot!

Offline

#75 2014-01-31 21:02:49

OBLiQUE
Member
Registered: 2008-12-04
Posts: 107
Website

Re: [script] create_ap: Create a NATed or Bridged WiFi Access Point

spondbob contacted me via github and the solution of its problem was to add --no-virt

Offline

Board footer

Powered by FluxBB