Доброго времени суток. Купил HTC Wildfire S. Выяснлось, что Android не поддерживает работу с ad-hoc сетями. Пришлось разбираться, как переводить WiFi-карточку в режим точки доступа. Стояла Intel WiFi Link 5100 --- драйвера под Linux не поддерживают Master mode. Купил с рук Atheros AR5BXB63, заработала сразу с драйвером ath5k.
dvolosnykh@xakac:~$ lspci -vnn | grep Wireless
06:00.0 Ethernet controller [0200]: Atheros Communications Inc. AR5001 Wireless Network Adapter [168c:001c] (rev 01)
dvolosnykh@xakac:~$ dmesg | grep Atheros
[ 21.680659] ath5k phy0: Atheros AR2425 chip found (MAC: 0xe2, PHY: 0x70)
Установил hostapd:
dvolosnykh@xakac:~$ sudo cat /etc/hostapd/hostapd.conf
interface=wlan1
bridge=br0
driver=nl80211
ssid=xakac
hw_mode=g
channel=1
macaddr_acl=0
auth_algs=1
wpa=3
wpa_passphrase=1234567890
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
dvolosnykh@xakac:~$
dvolosnykh@xakac:~$ ifconfig
eth0 Link encap:Ethernet HWaddr 00:90:f5:8c:4a:ac
inet addr:192.168.55.151 Bcast:192.168.55.255 Mask:255.255.255.0
inet6 addr: fe80::290:f5ff:fe8c:4aac/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3505136 errors:0 dropped:3262 overruns:0 frame:0
TX packets:1819583 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:5031292449 (5.0 GB) TX bytes:138240106 (138.2 MB)
Interrupt:46 Base address:0x8000
lo Link encap:Локальная петля (Loopback)
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:6192 errors:0 dropped:0 overruns:0 frame:0
TX packets:6192 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:586316 (586.3 KB) TX bytes:586316 (586.3 KB)
mon.wlan1 Link encap:UNSPEC HWaddr 00-1D-D9-29-00-6C-00-00-00-00-00-00-00-00-00-00
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:5328 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:352746 (352.7 KB) TX bytes:0 (0.0 B)
wlan1 Link encap:Ethernet HWaddr 00:1d:d9:29:00:6c
inet addr:10.42.43.1 Bcast:10.42.43.255 Mask:255.255.255.0
inet6 addr: fe80::21d:d9ff:fe29:6c/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:26734 errors:0 dropped:0 overruns:0 frame:0
TX packets:21584 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3433974 (3.4 MB) TX bytes:10725844 (10.7 MB)
dvolosnykh@xakac:~$ iwconfig
lo no wireless extensions.
eth0 no wireless extensions.
wlan1 IEEE 802.11bg Mode:Master Frequency:2.412 GHz Tx-Power=20 dBm
Retry long limit:7 RTS thr:off Fragment thr:off
Power Management:off
mon.wlan1 IEEE 802.11bg Mode:Monitor Tx-Power=20 dBm
Retry long limit:7 RTS thr:off Fragment thr:off
Power Management:off
Интерфейс mon.wlan1, судя по всему, результат работы hostapd.
Конфигурация сети:
dvolosnykh@xakac:~$ sudo cat /etc/network/interfaces
auto lo
iface lo inet loopback
auto eth0
#iface eth0 inet dhcp
iface eth0 inet static
address 192.168.55.151
netmask 255.255.255.0
gateway 192.168.55.1
#auto wlan1
iface wlan1 inet static
address 10.42.43.1
netmask 255.255.255.0
pre-up iptables --table mangle --append PREROUTING --in-interface wlan1 --jump TTL --ttl-set 64
pre-up iptables --table nat --append PREROUTING --in-interface wlan1 --protocol tcp --match multiport --destination-ports 80,25,443,1025:65535 -j REDIRECT --to-port 3128
pre-up iptables --table nat --append POSTROUTING --out-interface eth0 --jump MASQUERADE
post-down iptables --table nat --flush
dvolosnykh@xakac:~$ sudo cat /etc/hosts
127.0.0.1 xakac localhost.localdomain localhost
::1 xakac localhost6.localdomain6 localhost6
127.0.1.1 xakac
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
dvolosnykh@xakac:~$ sudo cat /etc/resolv.conf
# Generated by NetworkManager
search icn.bmstu.ru
nameserver 195.19.37.129
nameserver 195.19.37.140
IP-forwarding включил:
dvolosnykh@xakac:~$ sed 's/#.*//;s/^[ \t]*//;s/[ \t]*$//' /etc/sysctl.conf | grep -v '^$'
net.ipv4.ip_forward=1
DNS и DHCP настроил:
dvolosnykh@xakac:~$ sed 's/#.*//;s/^[ \t]*//;s/[ \t]*$//' /etc/dnsmasq.conf | grep -v '^$'
domain-needed
bogus-priv
interface=wlan1
dhcp-range=10.42.43.10,10.42.43.254,12h
log-dhcp
log-facility=/var/log/dnsmasq.log
Установил Squid как прозрачный proxy-сервер:
dvolosnykh@xakac:~$ sudo sed 's/#.*//;s/^[ \t]*//;s/[ \t]*$//' /etc/squid/squid.conf | grep -v '^$'
acl all src all
acl manager proto cache_object
acl localhost src 127.0.0.1/32
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32
acl virbr0net src 192.168.122.0/24
acl wifinet src 10.42.43.0/24
acl SSL_ports port 443
acl SSL_ports port 563
acl SSL_ports port 873
acl Safe_ports port 80
acl Safe_ports port 21
acl Safe_ports port 25
acl Safe_ports port 110
acl Safe_ports port 143
acl Safe_ports port 443
acl Safe_ports port 70
acl Safe_ports port 210
acl Safe_ports port 1025-65535
acl Safe_ports port 280
acl Safe_ports port 488
acl Safe_ports port 591
acl Safe_ports port 777
acl Safe_ports port 631
acl Safe_ports port 873
acl Safe_ports port 901
acl purge method PURGE
acl CONNECT method CONNECT
http_access allow manager localhost
http_access deny manager
http_access allow purge localhost
http_access deny purge
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow virbr0net
http_access allow wifinet
http_access allow localhost
http_access deny all
icp_access allow virbr0net
icp_access allow wifinet
icp_access deny all
http_port 3128 transparent
hierarchy_stoplist cgi-bin ?
access_log /var/log/squid/access.log squid
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern (Release|Package(.gz)*)$ 0 20% 2880
refresh_pattern . 0 20% 4320
acl shoutcast rep_header X-HTTP09-First-Line ^ICY.[0-9]
upgrade_http0.9 deny shoutcast
acl apache rep_header Server ^Apache
broken_vary_encoding allow apache
extension_methods REPORT MERGE MKACTIVITY CHECKOUT
hosts_file /etc/hosts
coredump_dir /var/spool/squid
PS. Из-за ограничения на размер сообщения --- всё не влезло. См. продолжение ниже.