Ubuntu 11.04 as Wifi Router

本文详细介绍如何在Ubuntu 11.04 Server Edition上配置并启动一个无线接入点(AP),包括安装所需软件、配置网络参数、设置DHCP服务及IP路由等步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Install Ubuntu 11.04 Server Edition on your netbook/old pc/thin client etc.. with default settings.
In my case I am using a thinclient (eth0 = wired ethernet adapter; wlan0 = wireless adapter).

Step 2

sudo apt-get install isc-dhcp-server hostapd

Step 3

sudo pico /etc/hostapd/hostapd.conf

	interface=wlan0
	driver=nl80211
	ssid=UbuntuAP
	hw_mode=g
	channel=11
	wpa=1
	wpa_passphrase=UbuntuAPPassPhrase
	wpa_key_mgmt=WPA-PSK
	wpa_pairwise=TKIP CCMP
	wpa_ptk_rekey=600
Step 4

sudo pico /etc/dhcp/dhcpd.conf

default-lease-time 600;
max-lease-time 7200;
option subnet-mask 255.255.255.0;
option broadcast-address 10.20.30.255;
option domain-name "mydomain.example";



subnet 10.20.30.0 netmask 255.255.255.0 {
        range 10.20.30.10 10.20.30.50;
        option domain-name-servers 8.8.4.4, 208.67.222.222;
        option routers 10.20.30.254;
}
Step 5

sudo pico /etc/default/isc-dhcp-server

	INTERFACES="wlan0"
Step 6

Enable IP Routing and save the IPtable rules.

	sudo bash
	echo "1" > /proc/sys/net/ipv4/ip_forward
	iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
	iptables-save > /etc/iptables.rules

Step 7

Assign static IP to Wireless adapter and auto load IPtable rules

sudo pico /etc/network/interfaces

auto wlan0
iface wlan0 inet static
 address 10.20.30.254
 netmask 255.255.255.0

pre-up iptables-restore < /etc/iptables.rules

Step 8

Auto start DHCP Server and hostapd (AccessPoint)

sudo pico /etc/rc.local

service isc-dhcp-server start
hostapd -dd /etc/hostapd/hostapd.conf
Reference
  • https://exain.wordpress.com/tag/rt2800usb/
  • https://help.ubuntu.com/community/IptablesHowTo


===============================================================================================================================

我自己的脚本[ArchLinux]:

vpn-connect
iptables -A FORWARD -s 10.42.0.0/24 -o ppp0 -j ACCEPT
iptables -t nat -A POSTROUTING -s 10.42.0.0/24 -o ppp0 -j MASQUERADE
echo 1 >/proc/sys/net/ipv4/ip_forward
ip addr add 10.42.0.0/24 dev wlan0
ip route add default via 10.42.0.1
rc.d start dhcp4
hostapd -B /etc/hostapd/hostapd.conf


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值