A bridge is a device for forwarding packets between two or more Ethernets so that they behave in most respects as if they were a single network. It could be a physical device, but it is also possible for a bridge to be implemented entirely in software. The Linux kernel has the ability to perform bridging by means of the
Linux bridge setup can be done with a user-space command-line tool called brctl which allows you to create, remove and administer Linux ethernet bridges.
Here i describes how to bridge eth0 to wlan0
To use brctl command, you need to install the bridge-utils package.
sudo apt-get install bridge-utils
sudo yum install bridge-utils
After installation to see all current bridge interfaces, execute the command
To create a bridge
brctl addbr br0
To bring the interface up and to see in ifconfig issue this command
ifconfig br0 up
To add an interface to your bridge is simple
brctl addif br0 eth0
You can add multiple interfaces to the bridge
brctl addif br0 wlan0
Enable ip forwarding to share the internet
echo 1 > /proc/sys/net/ipv4/ip_forward
Finally you can either give br0 an ip address manually or can use the dhclient
dhclient -d br0
After this all the packets obtained via eth0 will be forwarded to wlan0.
Happy Hacking 🙂