|I have hired cable Internet, but the cable-modem they have given me is single-user, so to share the Internet by WIFI with the rest of the devices in my house I have to use my old telephone router and a few commands. Can be done.|
First, we will activate the ipforwarding editing the sysctl.conf file running, if nano is your favorite editor:
sudo nano /etc/sysctl.conf
and in the following line we change the value 0 to 1:
# net.ipv4.ip_forward = 0 net.ipv4.ip_forward = 1
sudo nano /etc/init.d/share.sh
#! / bin / bash iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
In my case the internet enters me through eth0 but you must check the name of your network interface that may change depending on the device or the GNU / Linux distribution used. To do this, you can use ifconfig from a terminal.
Then we execute the following command so that it is executed with the boot of our system in distributions based on Ubuntu / Debian:
sudo update-rc.d share.sh defaults
In those based on Arch Linux we put our script inside /etc/rc.local:
sudo nano /etc/rc.local/share.sh
With this systemd will execute it at system startup.
En OpenSuse instead of creating the script we can use YaST2 to configure our Firewall in graphic mode, which will need to be activated. We mark the option «Network Masking».
And finally we must bear in mind a fundamental concept so that everything works well, Default Gateway.
We must configure our router writing the IP of our wlan0, in my case, in the field corresponding to Default Gateway inside of the router. For this we must log in within the web interface of the same. It is convenient to configure the IP of our PC within the WIFI network manually so that it does not change when the equipment starts.
Thanks to what we have done, we can improve the coverage of our WIFI network at home, since we can place the router anywhere with an electrical outlet, as long as it is within reach of our PC with the two network cards (eth0 and wlan0) .