无法设置 wlan0/ppp0 桥接

无法设置 wlan0/ppp0 桥接

不知道我花了多少小时/天来解决这个“简单”的问题,但我被难住了......

我想要做的是将 eth0/wlan0 桥接到 ppp 会话(换句话说,通过 eth0 和 wlan0 共享到 Internet 的 ppp 连接。)以下是详细信息:

我使用的是 Ubuntu 3.8.13 内核,在 wlan0 上运行 hostapd。使用 dnsmasq 为 wlan0 上的客户端分配 192.168.15.0 子网中的 IP。还有一个 eth0 接口,其静态 IP 为 192.168.15.1。eth0 和 wlan0 使用 br0 组合在一起,我正在尝试将 ppp 连接的地址 nat 到 eth0/wlan0 网桥。

我在用:

iptables -t nat -A POSTROUTING -s 192.168.15.0/24 -o ppp0 -j MASQUERADE

创建 nat,但是当 ppp 会话启动时,我只能 ping 本地 ppp 地址,而不能 ping 远程或 Internet 上的任何地址。我严格通过 IP 地址进行 ping,甚至还没有使用 DNS 解析。

以下是相关数据:

一、网络接口:

auto lo br0
iface lo inet loopback


#bridge
iface br0 inet static
    bridge_ports wlan0 eth0
    address 192.168.15.1
    netmask 255.255.255.0
    network 192.168.15.0
    broacast 192.168.15.255

# primary interface
allow-hotplug eth0
iface eth0 inet manual

# wireless wlan0
allow-hotplug wlan0
iface wlan0 inet manual

#internet connection
auto ppp0
iface ppp0 inet wvdial

我相信 ppp 会话已正常启动:

Apr 23 21:29:08 beaglebone pppd[3657]: Script chat -v -f /etc/ppp/chat/gsp1720 finished (pid 3658), status = 0x0
Apr 23 21:29:08 beaglebone pppd[3657]: Serial connection established.
Apr 23 21:29:08 beaglebone pppd[3657]: using channel 3
Apr 23 21:29:08 beaglebone pppd[3657]: Using interface ppp0
Apr 23 21:29:08 beaglebone pppd[3657]: Connect: ppp0 <--> /dev/ttyO4
Apr 23 21:29:08 beaglebone pppd[3657]: rcvd [LCP ConfReq id=0x57 <asyncmap 0x0> <magic 0x98a10ed8> <pcomp> <accomp>]
Apr 23 21:29:08 beaglebone pppd[3657]: sent [LCP ConfReq id=0x1 <asyncmap 0xa0000> <magic 0x888b7ceb> <pcomp> <accomp>]
Apr 23 21:29:08 beaglebone pppd[3657]: sent [LCP ConfAck id=0x57 <asyncmap 0x0> <magic 0x98a10ed8> <pcomp> <accomp>]
Apr 23 21:29:09 beaglebone pppd[3657]: rcvd [LCP ConfAck id=0x1 <asyncmap 0xa0000> <magic 0x888b7ceb> <pcomp> <accomp>]
Apr 23 21:29:09 beaglebone pppd[3657]: sent [LCP EchoReq id=0x0 magic=0x888b7ceb]
Apr 23 21:29:09 beaglebone pppd[3657]: sent [IPCP ConfReq id=0x1 <compress VJ 0f 01> <addr 0.0.0.0>]
Apr 23 21:29:09 beaglebone pppd[3657]: rcvd [LCP DiscReq id=0x58 magic=0x98a10ed8]
Apr 23 21:29:09 beaglebone pppd[3657]: rcvd [IPCP ConfReq id=0x59 <compress VJ 0f 01> <addr 10.153.1.1>]
Apr 23 21:29:09 beaglebone pppd[3657]: sent [IPCP ConfAck id=0x59 <compress VJ 0f 01> <addr 10.153.1.1>]
Apr 23 21:29:09 beaglebone pppd[3657]: rcvd [LCP EchoRep id=0x0 magic=0x98a10ed8 88 8b 7c eb]
Apr 23 21:29:09 beaglebone pppd[3657]: rcvd [IPCP ConfNak id=0x1 <addr 10.159.124.84>]
Apr 23 21:29:09 beaglebone pppd[3657]: sent [IPCP ConfReq id=0x2 <compress VJ 0f 01> <addr 10.159.124.84>]
Apr 23 21:29:09 beaglebone pppd[3657]: rcvd [IPCP ConfAck id=0x2 <compress VJ 0f 01> <addr 10.159.124.84>]
Apr 23 21:29:09 beaglebone pppd[3657]: local  IP address 10.159.124.84
Apr 23 21:29:09 beaglebone pppd[3657]: remote IP address 10.153.1.1
Apr 23 21:29:09 beaglebone pppd[3657]: Script /etc/ppp/ip-up started (pid 3665)
Apr 23 21:29:09 beaglebone pppd[3657]: Script /etc/ppp/ip-up finished (pid 3665), status = 0x0

ppp0 在 ifconfig 中显示为:

root@beaglebone:~# ifconfig
br0       Link encap:Ethernet  HWaddr 00:e0:4c:81:7b:38
          inet addr:192.168.15.1  Bcast:192.168.15.255  Mask:255.255.255.0
          inet6 addr: fe80::2e0:4cff:fe81:7b38/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:14847 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6907 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1257312 (1.1 MiB)  TX bytes:824099 (804.7 KiB)

eth0      Link encap:Ethernet  HWaddr 1c:ba:8c:d6:32:fa
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 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:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:40

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

ppp0      Link encap:Point-to-Point Protocol
          inet addr:10.159.124.84  P-t-P:10.153.1.1  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
          RX packets:35 errors:0 dropped:0 overruns:0 frame:0
          TX packets:313 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3
          RX bytes:1690 (1.6 KiB)  TX bytes:35628 (34.7 KiB)


wlan0     Link encap:Ethernet  HWaddr 00:e0:4c:81:7b:38
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:15693 errors:0 dropped:335 overruns:0 frame:0
          TX packets:13238 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:2211558 (2.1 MiB)  TX bytes:1872234 (1.7 MiB)

ppp0 启动时的路由表:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         *               0.0.0.0         U     0      0        0 ppp0
10.153.1.1      *               255.255.255.255 UH    0      0        0 ppp0
192.168.15.0    *               255.255.255.0   U     0      0        0 br0

iptables:

root@beaglebone:~# cat /proc/sys/net/ipv4/ip_forward
1


root@beaglebone:~# iptables -t nat -L -nv
Chain PREROUTING (policy ACCEPT 66 packets, 17496 bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain INPUT (policy ACCEPT 26 packets, 1715 bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain OUTPUT (policy ACCEPT 1 packets, 108 bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain POSTROUTING (policy ACCEPT 1 packets, 108 bytes)
 pkts bytes target     prot opt in     out     source               destination
    0     0 MASQUERADE  all  --  *      ppp0    192.168.15.0/24      0.0.0.0/0

但是,和上面一样,没有成功。可以 ping ppp0 分配的地址 (10.159.124.84),但其他地址都无法ping通。我漏掉了什么?

谢谢 -

相关内容