我的 ubuntu 10.04 服务器上安装了 3 个网卡,我想eth1
为有线用户和wlan0
无线用户配置 Internet 共享和文件共享。
静态 IP::
eth0
192.168.1.1
eth1
:10.0.0.15
wlan0
:10.0.0.20
/etc/network/interfaces
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.1.15
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
#The secondary network interfaces
auto eth1
iface eth1 inet static
address 10.0.0.15
netmask 255.0.0.0
network 10.0.0.0
broadcast 10.255.255.255
auto wlan0
iface wlan0 inet static
address 10.0.0.20
netmask 255.0.0.0
network 10.0.0.0
broadcast 10.255.255.255
我使用 squid 和 dansguardian 进行互联网配置
我已在 hostapd 中/etc/hostapd/hostapd.conf
使用 WPA 身份验证选项进行如下配置。
01 interface=wlan0
02 driver=nl80211
03 ssid=dontMessWithVincentValentine
04 hw_mode=g
05 channel=6
06 macaddr_acl=0
07 auth_algs=1
08 ignore_broadcast_ssid=0
09 wpa=3
10 wpa_passphrase=KeePGuessinG
11 wpa_key_mgmt=WPA-PSK
12 wpa_pairwise=TKIP
13 rsn_pairwise=CCMP
DHCP 服务器也已配置(/etc/dhcp3/dhcpd.conf
)
ddns-update-style none;
ignore client-updates;
authoritative;
option local-wpad code 252 = text;
subnet 10.0.0.0 netmask 255.255.255.0 {
# --- default gateway
option routers 10.0.0.15;
# --- Netmask
option subnet-mask 255.255.255.0;
# --- Broadcast Address
option broadcast-address 10.0.0.255;
# --- Domain name servers, tells the clients which DNS servers to use.
option domain-name-servers 10.0.0.15, 127.0.0.1, 192.168.1.1;
option time-offset 0;
range 10.0.0.21 10.0.0.30;
default-lease-time 1209600;
max-lease-time 1814400;
}
/etc/default/dhcp3-server
INTERFACES="eth1 wlan0"
我已启用 IPv4 和 IPv6 数据包转发 ( /etc/sysctl.conf
)
Net.ipv4.ip_forward = 1
Net.ipv6.conf.all.forwarding = 1
/etc/rc.local
iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 -j REDIRECT --to-port 8080
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
客户端电脑能够在 eth1 上接收 Internet 共享以及 dhcp 地址并 ping 另一个网络。
从 wlan 到客户端 PC 能够接收 dhcp 地址,但无法 ping 到 10.0.0.20,通过该地址他们接收 dhcp 地址或网络中的任何其他 PC,我的防火墙也没有启用。
无线局域网用户无法 ping 或通信的原因可能是什么?想要配置防火墙和路由器,通过它可以将互联网共享给有线连接用户和无线用户。
答案1
DHCP 服务器告知所有客户端使用eth1
IP 地址作为网关,但 Wi-Fi 客户端无法访问该地址,因此无法路由到其他网络。Wi-Fi 客户端甚至无法 pingwlan0
地址,因为eth1
和都wlan0
位于同一子网和有线接口上优先于无线接口,因此 ping 响应出去eth1
并且无法到达无线客户端。
您必须分离eth1
子网wlan0
并相应地配置 DHCP。
/etc/network/interfaces
:
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.1.15
netmask 255.255.255.0
gateway 192.168.1.1
#The secondary network interfaces
auto eth1
iface eth1 inet static
address 10.0.0.15
netmask 255.255.255.0
auto wlan0
iface wlan0 inet static
address 10.0.1.15
netmask 255.255.255.0
/etc/dhcp3/dhcpd.conf
:
ddns-update-style none;
ignore client-updates;
authoritative;
default-lease-time 1209600;
max-lease-time 1814400;
option local-wpad code 252 = text;
option domain-name-servers 192.168.1.15;
option time-offset 0;
subnet 10.0.0.0 netmask 255.255.255.0 {
option routers 10.0.0.15;
range 10.0.0.21 10.0.0.30;
}
subnet 10.0.1.0 netmask 255.255.255.0 {
option routers 10.0.1.15;
range 10.0.1.21 10.0.1.30;
}