7

I want to bridge wlan0 and eth0 to get Internet from wlan0 to eth0 to plug in a switch.
I configured wpa-supplicant and have this interfaces file:

auto lo

iface lo inet loopback

iface eth0 inet manual

auto wlan0
iface wlan0 inet manual

auto br0
iface br0 inet static
      address 192.168.1.5   #ip in wlan0 for Internet
      netmask 255.255.255.0   #netmask in wlan0 for Internet
      gateway 192.168.1.1   #gateway in wlan0 for Internet
      bridge_ports wlan0 eth0
      bridge_stp off
      bridge_maxwait 5

wpa-iface wlan0
wpa-bridge br0
wpa-driver wext
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

It seems not to work. What could be the problem?

Edit

Now I know: bridging from wifi to ethernet doesn't work, if the WiFi adapter isn't in host mode because it isn't allowed to send any information with an different MAC address! I thought that's only the problem with bridging from Ethernet to WiFi.

  • Did you already create the br0 interface using the command brctl addbr br0? What does ip show addr display? – HeatfanJohn Feb 5 '14 at 20:26
  • plz paste you ifconfig! – Alex Tape Feb 6 '14 at 9:18
3

just a sharp shoot:

To share wlan0 and eth0

/etc/network/interfaces:

auto lo
iface lo inet loopback

auto wlan0 
iface wlan0 inet dhcp
     wpa-driver wext
     wpa-ssid YOUR_SSID
     wpa-ap-scan 1
     wpa-proto RSN
     wpa-pairwise CCMP
     wpa-group CCMP
     wpa-key-mgmt WPA-PSK
     wpa-psk "passphrase"

auto eth0
iface eth0 inet static
address 192.168.3.1
netmask 255.255.255.0
broadcast 192.168.3.255

## remove rules and chains first
up /sbin/iptables -F
 up /sbin/iptables -X
  up /sbin/iptables -t nat -F

    ## mask eth0, activate port forwarding and nat
up /sbin/iptables -A FORWARD -o wlan0 -i eth0 -s 192.168.0.0/24 -m conntrack --ctstate NEW -j ACCEPT
 up /sbin/iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
  up /sbin/iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE 
   up /sbin/sysctl -w net.ipv4.ip_forward=1 

## use dnsmasq-base
## on range 192.168.3.10 - 192.168.3.20
up /usr/bin/killall dnsmasq
 up /bin/sleep 2
  post-up /usr/sbin/dnsmasq -i eth0 -I wlan0 -F 192.168.3.10,192.168.3.20,infinite

## if you use dnsmasq activate this
## if dnsmasq-base deactive this
## dnsmasq restart
# post-up /etc/init.d/dnsmasq restart

for dnsmasq

/etc/dnsmasq.conf:

# dhcp active for eth0
interface=eth0

# no dhcp for wlan0
no-dhcp-interface=wlan0

# range / Lease-Time
dhcp-range=interface:eth0,192.168.3.10,192.168.3.20,infinite
  • I have had problems because I haven't installed dnsmasq. Now it works! – user2737037 Feb 8 '14 at 15:28
  • Interesting. This is what I was looking for.. Upvote. – SDsolar May 5 '17 at 15:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.