You can use your PI as a router to share the ethernet connection to WiFi Devices , What about the other way ?
Here is tut for Ethernet to WiFi : http://elinux.org/RPI-Wireless-Hotspot ( This tut helped me to get idea )
- A Raspberry Pi, model B.
- A boot SD card for the Raspberry Pi.
- Connected to Networking Via WiFi
- An Ethernet cable to connect PC
Assumes that you have connected your device via WiFi and ssh logged in using WiFi .
If wifi is not setup perfectly please see this one :
Wifi auto connect : https://blog.arevindh.com/solved-raspberry-pi-wifi-disconnect-problems.html
1. Install the necessary software.
sudo apt-get install udhcpd
2. Configure DHCP. Edit the file /etc/udhcpd.conf and configure it like this:
start 192.168.42.2 # This is the range of IPs that the hostspot will give to client devices. end 192.168.42.20 interface eth0 # The device uDHCP listens on. remaining yes opt dns 188.8.131.52 184.108.40.206 # The DNS servers client devices will use. opt subnet 255.255.255.0 opt router 192.168.42.1 # The Pi's IP address on wlan0 which we will set up shortly. opt lease 864000 # 10 day DHCP lease time in seconds
Edit the file /etc/default/udhcpd and change the line:
You will need to give the Pi a static IP address with the following command:
sudo ifconfig eth0 192.168.42.1
To set this up automatically on boot, edit the file /etc/network/interfaces and replace the line “iface eth0 inet dhcp” to:
iface eth0 inet static address 192.168.42.1 netmask 255.255.255.0
If the line “iface eth0 inet dhcp” is not present, add the above lines to the bottom of the file.
Configure Your WiFi
auto wlan0 allow-hotplug wlan0 iface wlan0 inet static address 192.168.0.116 netmask 255.255.255.0 gateway 192.168.0.1 wpa-ssid "HOME" // your wifi ssid wpa-psk "xxxxxxxx" // your wifi pass dns-nameservers 220.127.116.11 18.104.22.168
3. Configure NAT (Network Address Translation). First, enable IP forwarding in the kernel:
sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
To set this up automatically on boot, edit the file /etc/sysctl.conf and add the following line to the bottom of the file:
Second, to enable NAT in the kernel, run the following commands:
sudo iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE sudo iptables -A FORWARD -i wlan0 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT sudo iptables -A FORWARD -i eth0 -o wlan0 -j ACCEPT
Your Pi is now NAT-ing. To make this permanent so you don’t have to run the commands after each reboot, run the following command:
sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
Now edit the file /etc/network/interfaces and add the following line to the bottom of the file:
up iptables-restore < /etc/iptables.ipv4.nat
4. Issue commands to start the dhcp server:
sudo service udhcpd start
Your Pi should now be hosting a ethernet hotspot. To get the hotspot to start on boot, run these additional commands:
sudo update-rc.d udhcpd enable
Reboot Pi and plugin the LAN cable and you can see the auto allocated ip on command ipconfig (on windows) / ifconfig (on linux).
If you have any problems please comment Below .