Bridge wlan0 to eth0: Difference between revisions

From Alpine Linux
(Methods to Bridge Network Traffic Between Wired and Wireless Interfaces)
 
m (added Networking category, minor formatting)
 
(18 intermediate revisions by one other user not shown)
Line 1: Line 1:
{{TOC right}}
{{TOC right}}
= Introduction =
 
This wiki describes a method to prep an sd card for a raspberry pi so that the pi will connect to your local wifi on first boot and allow password-less root login over ssh to continue setupThis allows you to setup a raspberry pi without connecting a keyboard or monitor.
== Introduction ==
 
This wiki describes methods to bridge a wired and wireless interface to enable network communication between hosts reachable via either interface. This allows one or more wired hosts to share the wireless interface on the bridge host.
 
In my use case, I have a desk with a wired switch with multiple hosts connected. All wired devices on this switch can access my home wifi network via the bridge host's wireless interface.
 
I am only going to document the proxy ARP method as that's what I'm currently using.  Please feel free to add additional methods and remove this section of the introduction.
 
== Method 1: Proxy ARP ==
 
These steps result in a working solution where hosts on the wired side and hosts on the wireless side are all in the same ip network. There are no frills added, such as dhcp or automatic route entries for the wired hosts. Each wired host needs to have a manually configured IP address and an entry manually added to the bridge host's routing table.
 
Note: For your wired hosts, use IP addresses in the same IP range as the rest of your network but outside of the scope used by a local DHCP server, if applicable. You may need to reduce your DHCP scope to free up IP addresses for this purpose.
 
Configure the network interfaces on your bridge host:
 
{{Cat|/etc/network/interfaces|
auto lo
iface lo inet loopback
 
auto wlan0
iface wlan0 inet dhcp
hostname wyse3030-3
 
auto eth0
iface eth0 inet manual
pre-up ifconfig $IFACE up
pre-down ifconfig $IFACE down
 
}}
 
Notice that the wireless interface (wlan0) uses dhcp from the home network as usual and that an IP address is not used at all on the wired interface (eth0).
 
Enable and create a local start-up script to add route entries at boot:
 
{{Cmd| # rc-update add local default
# touch /etc/local.d/RouteAdd.start
  # chmod +x /etc/local.d/RouteAdd.start
}}
 
Add route statements for each host on the wired side of the bridge:
 
{{Cat|/etc/local.d/RouteAdd.start|
ip route add 10.0.0.51/32 dev eth0
ip route add 10.0.0.52/32 dev eth0
ip route add 10.0.0.53/32 dev eth0
}}
 
Enable proxy arp:
 
{{Cat|/etc/sysctl.d/local.conf|
<nowiki>
net.ipv4.conf.all.proxy_arp = 1
net.ipv4.ip_forward = 1
</nowiki>
}}
 
{{Cmd|# reboot}}
 
[[Category:Networking]]

Latest revision as of 14:19, 18 April 2023

Introduction

This wiki describes methods to bridge a wired and wireless interface to enable network communication between hosts reachable via either interface. This allows one or more wired hosts to share the wireless interface on the bridge host.

In my use case, I have a desk with a wired switch with multiple hosts connected. All wired devices on this switch can access my home wifi network via the bridge host's wireless interface.

I am only going to document the proxy ARP method as that's what I'm currently using. Please feel free to add additional methods and remove this section of the introduction.

Method 1: Proxy ARP

These steps result in a working solution where hosts on the wired side and hosts on the wireless side are all in the same ip network. There are no frills added, such as dhcp or automatic route entries for the wired hosts. Each wired host needs to have a manually configured IP address and an entry manually added to the bridge host's routing table.

Note: For your wired hosts, use IP addresses in the same IP range as the rest of your network but outside of the scope used by a local DHCP server, if applicable. You may need to reduce your DHCP scope to free up IP addresses for this purpose.

Configure the network interfaces on your bridge host:

Contents of /etc/network/interfaces

auto lo iface lo inet loopback auto wlan0 iface wlan0 inet dhcp hostname wyse3030-3 auto eth0 iface eth0 inet manual pre-up ifconfig $IFACE up pre-down ifconfig $IFACE down

Notice that the wireless interface (wlan0) uses dhcp from the home network as usual and that an IP address is not used at all on the wired interface (eth0).

Enable and create a local start-up script to add route entries at boot:

# rc-update add local default # touch /etc/local.d/RouteAdd.start # chmod +x /etc/local.d/RouteAdd.start

Add route statements for each host on the wired side of the bridge:

Contents of /etc/local.d/RouteAdd.start

ip route add 10.0.0.51/32 dev eth0 ip route add 10.0.0.52/32 dev eth0 ip route add 10.0.0.53/32 dev eth0

Enable proxy arp:

Contents of /etc/sysctl.d/local.conf

net.ipv4.conf.all.proxy_arp = 1 net.ipv4.ip_forward = 1

# reboot