使用hostapd和dnsmasq实现软AP

fortime posted @ 2010年12月20日 23:13 in linux with tags Android ap hostapd dnsmasq , 20072 阅读

由于要共享无线给android,虽然cm6.1可以用ad-hoc,但感觉android连ad-hoc要比连ap耗电。本来想看看有什么usb无线网卡可以在linux下用软ap,顺便用来替换掉上网本的无线网卡,我的上网本在linux下的无线驱动太差劲(可恨的rtl8187),连ad-hoc都不支持。结果在http://linuxwireless.org上发现我台式机的无线网卡的ath5k驱动很完善,可以用软ap,ath5k太可爱了。回来搞了一个晚上加一个中午,终于用hostapd,dnsmasq实现了软ap。可怜的netmanager要报废咯~

首先,系统是U10.10,安装软件:

sudo apt-get install hostapd dnsmasq

(1)为无线添加路由规则:

sudo iptables -t nat -A POSTROUTING -s 10.1.1.0/24 -o eth0 -j MASQUERADE
sudo iptables -A FORWARD -s 10.1.1.0/24 -o eth0 -j ACCEPT
sudo iptables -A FORWARD -d 10.1.1.0/24 -m conntrack --ctstate ESTABLISHED,RELATED -i eth0 -j ACCEPT

10.1.1.0/24是我设置的地址段,可以自己改。

若要记录下路由的情况可以加如下语句:

sudo iptables -A INPUT -m conntrack --ctstate NEW -p tcp --dport 80 -j LOG --log-prefix "NEW_HTTP_CONN: "

其中NEW_HTTP_CONN是日记中的标识。

然后把现在iptables的规则写进/etc/iptables.rules:

sudo sh -c "iptables-save > /etc/iptables.rules"

配置interface文件,使每次eth0启动时自动写规则:

auto eth0
iface eth0 inet dhcp
pre-up iptables-restore < /etc/iptables.rules
post-down iptables-save > /etc/iptables.rulse

以上代码从https://help.ubuntu.com/community/WifiDocs/WirelessAccessPoint学来。

(2)配置hostapd.conf

interface=wlan0
bridge=br0 #貌似这个没有用
driver=nl80211
ssid=fortimefan 
hw_mode=g
channel=11 
dtim_period=1 
rts_threshold=2347 
fragm_threshold=2346 
macaddr_acl=0 
auth_algs=3
ieee80211n=0 

详细hostapd.conf配置请看http://linuxwireless.org/en/users/Documentation/hostapd

(3)配置/etc/dnsmasq.conf:

interface=wlan0
bind-interfaces #这个是只监听wlan0,没有之会检测所有卡
except-interface=lo
dhcp-range=10.1.1.10,10.1.1.110,6h #设置dhcp地址范
#address=/#/10.1.1.1 #这个会把#(代表所有网址)的dns到10.1.1.1这个地址

(4)dnsmasq与named

一般情况下bind的named会占了53端口,然后dnsmasq会启动不了,所以我用killall named来杀了named再启动dnsmasq。

附自动链接代码:

#! /bin/sh

case "$1" in
    start)
        killall named
        killall hostapd
        linux1x -k
        ifconfig wlan0 10.1.1.1
        hostapd /home/fan/.hostapd.conf &>/dev/null &
        /etc/init.d/dnsmasq restart
        linux1x -d #校园网h3c,杀了named后好像会出问题,重连一下h3c
        ;;
esac

 

Avatar_small
wbyxu 说:
2011年2月23日 09:27

这个比较好...呵呵 成功了.

Avatar_small
Mr.Klutu 说:
2011年5月18日 20:54

在ubuntu10.04下也好使,手机为htc G8

Avatar_small
huxos 说:
2011年12月07日 14:58

博主 请问 要是ubuntu 的有线网卡为静态ip分配 应该如何设置这个呢?

Avatar_small
cleaning company in 说:
2022年5月18日 21:55

Let’s facial skin it – ones own oven was through plenty. While a number of models contain self-cleaning possible choices, they don’t supplies a thorough wash. Our competent house cleaners can achieve the work to a self-cleaning oven and be able to some. We’re confident which we can remove the residue and even grime in your valuable device.

Avatar_small
civaget 说:
2023年12月11日 01:04

Adaptability is vital in the world of 구글 상위노출. Stay flexible and adjust your strategies to the ever-changing SEO landscape.

Avatar_small
civaget 说:
2023年12月12日 19:24

Mobile massage services in 제주유흥 are a must-try. So relaxing!

Avatar_small
civaget 说:
2023年12月16日 13:00

Pleasant blog post. It appears that plenty of the stages are counting on the inventiveness element. “Bad mind, bad heart.” by Anacharsis Cloots.. 해외축구중계

Avatar_small
civaget 说:
2023年12月16日 19:25

누누티비's user-friendly interface makes it accessible for all age groups.

Avatar_small
civaget 说:
2023年12月16日 20:09

I booked 러시아마사지 during my business trip, and it was the best decision ever.

Avatar_small
seo service UK 说:
2023年12月19日 21:47

Nice post. I was checking constantly this blog and I’m impressed! Extremely useful info specially the last part I care for such information a lot. I was seeking this certain info for a long time. Thank you and good luck

Avatar_small
civaget 说:
2023年12月21日 18:48

설문조사 사이트 무료 options allow you to tailor surveys to your audience for maximum engagement and feedback.

Avatar_small
civaget 说:
2023年12月21日 21:56

Educate users on responsible gambling practices to promote a secure gaming environment on your chosen 토토사이트.

Avatar_small
civaget 说:
2023年12月24日 04:02

안산휴게텔 is where Ansan's locals and travelers find solace.

Avatar_small
토토사이트 놀검소 说:
2023年12月24日 13:47

I have read your article; it is very informative and helpful for me. I admire the valuable information you offer in your articles. Thanks for posting it

Avatar_small
안전공원추천 说:
2023年12月24日 13:51

BUY SPOTIFY FOLLOWERS. BUY SPOTIFY PLAYS REAL PLAYS TO BOOST YOUR MUSIC.We will promote your tracks and give you very ..

Avatar_small
스마일도메인 说:
2023年12月24日 14:22

BUY SPOTIFY FOLLOWERS. BUY SPOTIFY PLAYS REAL PLAYS TO BOOST YOUR MUSIC.We will promote your tracks and give you very ..

Avatar_small
토토홍보게시판 说:
2023年12月24日 14:32

Acknowledges for paper such a beneficial composition, I stumbled beside your blog besides decipher a limited announce. I want your technique of inscription.

Avatar_small
세븐도메인 说:
2023年12月24日 14:57

Tipobet, the leading brand in the market, aims to increase your money seven times with its 25% Instant Loss Bonus. You can immediately access the game producer to take advantage of free spins. The 20% Unconditional Bonus is the largest

Avatar_small
먹튀검증 说:
2023年12月24日 15:18

Nice to visit your blog again. Several months have passed. This is the article I have been waiting for for a long time. I need this article to complete my assignment in college and it has the same topic as your article. thank you

Avatar_small
안전토토사이트추천 说:
2023年12月24日 15:18

I’m going to read this. I’ll be sure to come back. thanks for sharing. and also This article gives the light in which we can observe the reality. this is very nice one and gives indepth information. thanks for this nice article.

Avatar_small
메이저사이트 说:
2023年12月24日 15:44

Great information! I recently discovered your blog and have been reading along. I thought I would leave my first comment. I don't know what to say other than what I have.

Avatar_small
먹튀스팟보증업체 说:
2023年12月24日 15:50

It's very informative and you are obviously very knowledgeable in this area. Interesting and solid content, it opened my eyes to different views on this topic.

Avatar_small
인터넷바카라 说:
2023年12月24日 16:01

Great information! I recently discovered your blog and have been reading along. I thought I would leave my first comment. I don't know what to say other than what I have.

Avatar_small
파라오카지노도메인 说:
2023年12月24日 16:28

Hello, I am one of the most impressed people in your article. sòng bạc I'm very curious about how you write such a good article. Are you an expert on this subject? and good toto site info for you

Avatar_small
토토사이트 说:
2023年12月24日 16:33

you should make the laying zone as level as possible make a ton of pressing factor when the pool is on an incline. Also, this pressing factor can, over the long haul, truly negatively affect the underlying honesty of the pool.

Avatar_small
토토빅리그주소 说:
2023年12月24日 16:47

you should make the laying zone as level as possible make a ton of pressing factor when the pool is on an incline. Also, this pressing factor can, over the long haul, truly negatively affect the underlying honesty of the pool.

Avatar_small
슬롯머신사이트 说:
2023年12月24日 16:55

Impressive web site, Distinguished feedback that I can tackle. Im moving forward and may apply to my current job as a  pet sitter, which is very enjoyable, but I need to additional  expand. Regards

Avatar_small
파워사다리사이트 说:
2023年12月24日 17:05

I have read your excellent post. This is a great job. I have enjoyed reading your post first time. I want to say thanks for this post. Thank you...

Avatar_small
안전놀이터추천 说:
2023年12月24日 17:18

Because of this it will be significantly better which you could suitable studies just before manufacturing. You'll be able to create significantly greater guide that way.

Avatar_small
먹튀검증업체 说:
2023年12月24日 17:21

That are definitely excellent. Many of these tiny details are made getting lot of background knowledge. I am interested in them plenty

Avatar_small
메이저사이트 说:
2023年12月24日 17:43

Impressive web site, Distinguished feedback that I can tackle. Im moving forward and may apply to my current job as a  pet sitter, which is very enjoyable, but I need to additional  expand. Regards

Avatar_small
คาสิโนสด 说:
2023年12月24日 17:53

can be a fun and exciting way to spend an evening. You can choose from a variety of services, including dinner dates, private parties, and even travel companions. You can be sure that you will have a great time with a beautiful woman by your side.

Avatar_small
실시간바카라사이트 说:
2023年12月24日 18:42

We regard our relationship with clients genuinely. We do all that to leave you more blissful with our Goa goes with. Likewise, our ladies are ready to manage the requesting of clients.

Avatar_small
꽁머니 카지노 说:
2023年12月24日 18:48

BUY SPOTIFY FOLLOWERS. BUY SPOTIFY PLAYS REAL PLAYS TO BOOST YOUR MUSIC.We will promote your tracks and give you very ..

Avatar_small
안전놀이터 说:
2023年12月24日 19:03

Acknowledges for paper such a beneficial composition, I stumbled beside your blog besides decipher a limited announce. I want your technique of inscription.

Avatar_small
토토사이트추천 说:
2023年12月24日 19:11

BUY SPOTIFY FOLLOWERS. BUY SPOTIFY PLAYS REAL PLAYS TO BOOST YOUR MUSIC.We will promote your tracks and give you very ..

Avatar_small
바카라사이트추천 说:
2023年12月24日 19:28

Thank you so much for providing good quality information. I think it would not have been easy to collect this information and organize it in an easy to understand way

Avatar_small
보증놀이터 说:
2023年12月24日 19:31

Wow! This could be one particular of the most beneficial blogs We’ve ever arrive across on this subject. Actually Great. I’m also a specialist in this topic therefore I can understand your hard work.

Avatar_small
안전놀이터 추천 说:
2023年12月24日 19:59

Wow! This could be one particular of the most beneficial blogs We’ve ever arrive across on this subject. Actually Great. I’m also a specialist in this topic therefore I can understand your hard work.

Avatar_small
바카라사이트 说:
2023年12月24日 20:01

I got too much interesting stuff on your blog. I guess I am not the only one having all the enjoyment here! Keep up the good work.

Avatar_small
토프리카 说:
2023年12月24日 20:14

Very useful post. This is my first time i visit here. I found so many interesting stuff in your blog especially its discussion. Really its great article. Keep it up

Avatar_small
메이저사이트목록 说:
2023年12月24日 20:20

It's very informative and you are obviously very knowledgeable in this area. Interesting and solid content, it opened my eyes to different views on this topic.

Avatar_small
사설토토검증 说:
2023年12月24日 20:39

I was truly thankful for the useful info on this fantastic subject along with similarly prepare for much more terrific messages. Many thanks a lot for valuing this refinement write-up with me. I am valuing it significantly! Preparing for an additional excellent article

Avatar_small
빠른티비가입 说:
2023年12月24日 20:45

Because of this it will be significantly better which you could suitable studies just before manufacturing. You'll be able to create significantly greater guide that way.

Avatar_small
오래된토토사이트추천 说:
2023年12月24日 20:54

Thanks for posting this info. I just want to let you know that I just check out your site and I find it very interesting and informative. I can't wait to read lots of your posts

Avatar_small
사설토토 说:
2023年12月24日 21:05

Standard sessions allow me to share the simplest way to thanks a lot for ones hard work, which in turn is the reason why I am just traveling to the web page every day, seeking brand-new, exciting information. A lot of, cheers! 

Avatar_small
합법 토토사이트 说:
2023年12月24日 21:05

Impressive web site, Distinguished feedback that I can tackle. Im moving forward and may apply to my current job as a  pet sitter, which is very enjoyable, but I need to additional  expand. Regards

Avatar_small
승인전화없는 토토꽁머니 说:
2023年12月24日 21:27

I will right away take hold of your rss feed as I can not to find your email subscription link or newsletter service. Do you have any? Please permit me know in order that I may just subscribe. Thanks.

Avatar_small
civaget 说:
2023年12月26日 22:12

Quickly and easily build your web traffic and PR, which provides Web site visitors to add your page to any social bookmarking website. 에볼루션카지노

Avatar_small
civaget 说:
2023年12月27日 04:19

Self-publishing enables authors to respond quickly to cultural or societal changes in their writing. self publish a book

Avatar_small
civaget 说:
2023年12月27日 21:42

Connect, engage, and enjoy soccer on 축구중계. Join our global family.

Avatar_small
civaget 说:
2024年1月06日 20:29

I've met wonderful people on 오피가이드 who share my interests.

Avatar_small
토토커뮤니티 说:
2024年1月21日 14:18

Interesting post. I Have Been wondering about this issue. so thanks for posting. Pretty cool post.It 's really very nice and Useful post.Thanks

Avatar_small
슬롯사이트 说:
2024年1月21日 16:48

I unquestionably appreciating each and every piece of it and I have you bookmarked to look at new stuff you post.

Avatar_small
카지노사이트 说:
2024年1月21日 17:41

I am huge fan of guitar and want to learn and apply some tricks to play guitar easily.

Avatar_small
머니맨 说:
2024年1月21日 18:10

You make so many great points here that I read your article a couple of times. Your views are in accordance with my own for the most part. This is great content for your readers

Avatar_small
카지노 보증 说:
2024年1月21日 18:30

 definitely enjoying every little bit of it. It is a great website and nice share. I want to thank you. Good job! You guys do a great blog, and have some great contents. Keep up the good work

Avatar_small
카지노뱅크 说:
2024年1月21日 19:20

I really loved reading your blog. It was very well authored and easy to understand

Avatar_small
토토커뮤니티 说:
2024年1月21日 19:59

Great info! I recently came across your blog and have been reading along. 

Avatar_small
머니맨 说:
2024年1月21日 20:38

Nice post! This is a very nice blog that I will definitively come back to more times this year! Thanks for informative post

Avatar_small
카지노사이트추천 说:
2024年1月21日 21:03

I think I have never seen such blogs ever before that has complete things with all details which I want. So kindly update this ever for us

Avatar_small
industrial outdoor s 说:
2024年1月22日 13:45

Major thankies for the post.Really thank you! Really Great.

Avatar_small
온라인카지노 说:
2024年1月22日 14:26

Major thankies for the post.Really thank you! Really Great.

Avatar_small
소액결제현금화 说:
2024年1月22日 14:56

I haven’t any word to appreciate this post.....Really i am impressed from this post....the person who create this post it was a great human..thanks for shared this with us

Avatar_small
스포츠중계 说:
2024年1月22日 15:29

I can see that you are an expert at your field! I am launching a website soon, and your information will be very useful for me.. Thanks for all your help and wishing you all the success in your business

Avatar_small
카지노커뮤니티 说:
2024年1月22日 16:10

Cool you write, the information is very good and interesting, I'll give you a link to my site

Avatar_small
토토사이트 说:
2024年1月24日 16:25

Good to become visiting your weblog again, it has been months for me. Nicely this article that i've been waited for so long. I will need this post to total my assignment in the college, and it has exact same topic together with your write-up. Thanks, good share

Avatar_small
슬롯사이트 说:
2024年1月24日 18:06

Thanks for a wonderful in addition to enlightening post We truly value all the effort which went into creating.

Avatar_small
바카라사이트 说:
2024年1月26日 16:03

바카라사이트 바카라사이트 우리카지노 카지노는 바카라, 블랙잭, 룰렛 및 슬롯 등 다양한 게임을 즐기실 수 있는 공간입니다. 게임에서 승리하면 큰 환호와 함께 많은 당첨금을 받을 수 있고, 패배하면 아쉬움과 실망을 느끼게 됩니다.

Avatar_small
하노이 밤문화 说:
2024年1月26日 16:16

하노이 꼭 가봐야 할 베스트 업소 추천 안내 및 예약, 하노이 밤문화 에 대해서 정리해 드립니다. 하노이 가라오케, 하노이 마사지, 하노이 풍선바, 하노이 밤문화를 제대로 즐기시기 바랍니다. 하노이 밤문화 베스트 업소 요약 베스트 업소 추천 및 정리.

Avatar_small
먹튀검증 说:
2024年1月29日 15:26

No.1 먹튀검증 사이트, 먹튀사이트, 검증사이트, 토토사이트, 안전사이트, 메이저사이트, 안전놀이터 정보를 제공하고 있습니다. 먹튀해방으로 여러분들의 자산을 지켜 드리겠습니다. 먹튀검증 전문 커뮤니티 먹튀클린만 믿으세요!!

Avatar_small
베트남 유흥 说:
2024年1月29日 15:38

베트남 남성전용 커뮤니티❣️ 베트남 하이에나 에서 베트남 밤문화를 추천하여 드립니다. 베트남 가라오케, 베트남 VIP마사지, 베트남 이발관, 베트남 황제투어 남자라면 꼭 한번은 경험 해 봐야할 화끈한 밤문화로 모시겠습니다.

Avatar_small
투게더벳 说:
2024年1月31日 19:24

나는 당신의 블로그를 읽었고 그것은 나에게 매우 도움이됩니다. 감사합니다. 향후 업데이트를 위해 사이트를 북마크했습니다.

Avatar_small
볼트카지노가입코드 说:
2024年1月31日 19:44

배포 한 모든 지식에 다시 한 번 감사드립니다. 나는 그 기사에 매우 관심이 있었고, 인정해야 할 매우 고무적이었습니다. 나는 항상 이와 같은 흥미로운 기사를 접하기 때문에 당신의 사이트를 방문하는 것을 좋아합니다. 훌륭합니다, 대단히 감사합니다. 계속 공유하십시오! 문안 인사

Avatar_small
달팽이주소 说:
2024年1月31日 20:03

배포 한 모든 지식에 다시 한 번 감사드립니다. 나는 그 기사에 매우 관심이 있었고, 인정해야 할 매우 고무적이었습니다. 나는 항상 이와 같은 흥미로운 기사를 접하기 때문에 당신의 사이트를 방문하는 것을 좋아합니다. 훌륭합니다, 대단히 감사합니다. 계속 공유하십시오! 문안 인사

Avatar_small
쇼미더벳먹튀 说:
2024年1月31日 20:16

배포 한 모든 지식에 다시 한 번 감사드립니다. 나는 그 기사에 매우 관심이 있었고, 인정해야 할 매우 고무적이었습니다. 나는 항상 이와 같은 흥미로운 기사를 접하기 때문에 당신의 사이트를 방문하는 것을 좋아합니다. 훌륭합니다, 대단히 감사합니다. 계속 공유하십시오! 문안 인사

Avatar_small
카림벳먹튀 说:
2024年1月31日 20:38

배포 한 모든 지식에 다시 한 번 감사드립니다. 나는 그 기사에 매우 관심이 있었고, 인정해야 할 매우 고무적이었습니다. 나는 항상 이와 같은 흥미로운 기사를 접하기 때문에 당신의 사이트를 방문하는 것을 좋아합니다. 훌륭합니다, 대단히 감사합니다. 계속 공유하십시오! 문안 인사

Avatar_small
온라인카지노 说:
2024年1月31日 20:58

당신은 여기에 정말 좋은 게시물입니다. 시간을내어 소중한 정보를 게시 해 주셔서 감사합니다. 양질의 콘텐츠는 항상 방문자를 끌어들이는 것입니다.

Avatar_small
강남벳토토 说:
2024年1月31日 21:10

당신은 여기에 정말 좋은 게시물입니다. 시간을내어 소중한 정보를 게시 해 주셔서 감사합니다. 양질의 콘텐츠는 항상 방문자를 끌어들이는 것입니다.

Avatar_small
꽁머니카지노 说:
2024年1月31日 21:24

나는 당신의 블로그를 읽었고 그것은 나에게 매우 도움이됩니다. 감사합니다. 향후 업데이트를 위해 사이트를 북마크했습니다.

Avatar_small
에이전트도메인 说:
2024年1月31日 21:36

나는 당신의 블로그를 읽었고 그것은 나에게 매우 도움이됩니다. 감사합니다. 향후 업데이트를 위해 사이트를 북마크했습니다.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter

Host by is-Programmer.com | Power by Chito 1.3.3 beta
Butterfly Theme | Design: HRS Hersteller of mobile Hundeschule.