You are not logged in.

#1 2013-04-20 14:30:12

drag0nius
Member
Registered: 2013-04-20
Posts: 6

Hostapd conflicting with netctl profiles

Hello,

I'm not sure whether it's a bug or i can't find proper way to configure it.
Basically:
1. when hostapd is started i can't use netctl profile to assign IP to the interface, because interface is started already
2. when netctl profile is started assigning IP i cannot start hostapd because it can't switch to AP mode

Profile:

Interface=wlp2s1
Connection=wireless
IP=static
Address=('192.168.1.1/24')

Any suggestions how do i solve this?

Previously on Ubuntu i just set up static ip in /etc/network/interfaces file and it worked fine.

Last edited by drag0nius (2013-04-20 14:39:20)

Offline

#2 2013-04-20 16:05:23

progandy
Member
Registered: 2012-05-17
Posts: 5,184

Re: Hostapd conflicting with netctl profiles

Maybe you can try to start hostpad after you assigned the profile? If that works you could use ExecUpPost in your profile to run it and ExexDownPre to stop.
PS: If you want to assign a static IP to a hostapd connection, you need an "ethernet" profile, not wireless (which always uses wpa_supplicant)

Last edited by progandy (2013-04-20 16:06:30)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#3 2013-04-20 19:55:30

drag0nius
Member
Registered: 2013-04-20
Posts: 6

Re: Hostapd conflicting with netctl profiles

I cannot start profile when interface is up already.
Ethernet profile does not work on wireless interface, fails with "no connection on interface".

All i can think of now is something like python script run with cron assigning ip whenever interface is up and ip is not.

Last edited by drag0nius (2013-04-20 19:58:31)

Offline

#4 2013-04-20 23:10:43

jouke
Member
Registered: 2009-10-14
Posts: 72

Re: Hostapd conflicting with netctl profiles

It might very well be possible to do this with netctl, but nevertheless I would welcome a patch to implement an access point connection type for netctl.

I am sorry that I am of little help, but if this gets anyone hacking I am happy wink.

Offline

#5 2013-04-21 00:20:39

progandy
Member
Registered: 2012-05-17
Posts: 5,184

Re: Hostapd conflicting with netctl profiles

You can either create a new connection type or use an ethernet profile like this:

Connection=ethernet
Interface=wlan0
SkipNoCarrier=yes
ExecUpPost="hostapd -B -P /run/hostapd_wlan0.pid /etc/hostapd/hostapd_wlan0.conf"
ExecDownPre="read pid <"/run/hostapd_wlan0.pid" && kill $pid || true"
... IP config here

| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#6 2013-04-22 17:12:48

Leonid.I
Member
From: Aethyr
Registered: 2009-03-22
Posts: 999

Re: Hostapd conflicting with netctl profiles

@progandy:
HostAP already has a service file. Why combine it together with netctl?

@drag0nius:
Please see https://bbs.archlinux.org/viewtopic.php?id=136332 . Basically, you have to do 2 things:
* Create and enable a netctl _ethernet_ profile for netctl with a static IP and "SkipNoCarrier=yes", ordered before network.target.
* Start the HostAP service (hostapd.service which is by default ordered after network.target).

Alternatively, you can use "Bridge=..." option in hostapd.conf and then just use a bridge netctl profile (again ordered before hostapd.service).

@jouke:
Could you please elaborate on what you'd like to see? I thought about this in the context of netcfg, but it seems redundant, i.e. everything I could imagine could be done with existing netcfg profiles and hostapd service file...


Arch Linux is more than just GNU/Linux -- it's an adventure
pkill -9 systemd

Offline

#7 2013-04-22 17:29:01

progandy
Member
Registered: 2012-05-17
Posts: 5,184

Re: Hostapd conflicting with netctl profiles

@progandy:
HostAP already has a service file. Why combine it together with netctl?

If you create a permanent accesspoint, it may be better to use systemd (automatic restart if it crashes)
If you use netctl, you'll be able to simply change the profile to switch from ap to client. Maybe a better way would be to use a hostapd@profilename.service and issuse systemctl start/stop in ExecUp/Down. I was just using hostapd the same netctl starts way wpa_supplicant and dhcp.


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#8 2013-04-22 22:36:24

Leonid.I
Member
From: Aethyr
Registered: 2009-03-22
Posts: 999

Re: Hostapd conflicting with netctl profiles

progandy wrote:

@progandy:
HostAP already has a service file. Why combine it together with netctl?

If you create a permanent accesspoint, it may be better to use systemd (automatic restart if it crashes)
If you use netctl, you'll be able to simply change the profile to switch from ap to client. Maybe a better way would be to use a hostapd@profilename.service and issuse systemctl start/stop in ExecUp/Down. I was just using hostapd the same netctl starts way wpa_supplicant and dhcp.

I think it's always better to have dedicated tools: HostAP inits the card (think of it as a special driver), netctl deals with IPs, and systemd handles dependencies. For example:

/etc/systemd/system/netctl@AP_profile.service
...
Conflicts=netctl@managed_profile.service
Requires=hostapd.service
Before=network.target hostapd.service
...

/etc/systemd/system/netctl@managed_profile.service
...
Conflicts=netctl@AP_profile.service hostapd.service
...

systemctl enable netctl@managed_profile.service
systemctl start netctl@managed_profile.service

So, by default the system will be a usual station. But by enabling AP_profile it will switch to an AP mode, and vice versa. Notice, there is no need to even have hostapd.service enabled...

Last edited by Leonid.I (2013-04-22 22:37:25)


Arch Linux is more than just GNU/Linux -- it's an adventure
pkill -9 systemd

Offline

Board footer

Powered by FluxBB