Share internet connection
posted by pennegaonMonday February 28th, 2011, 284259 total view
Sometimes you need to use a PC and at some point you realize you need on the internet but what happens if the PC is far from the modem / router and can not lay cables or PC is not equipped with wifi card? We have to move the PC into the room where is the router?Â This may be a solution, but there is one that is even better: share the connection of a PC (connected to wifi) via a simple network cable (cross).
In this case the pc A is a router for the pc B. It must have at least two network interfaces (in this case a wifi and an ethernet), one connected to the router (wlan0) and the other (eth0) to PC B.
To configure the pc A to share the connection, assuming that the interface wlan0 is already configured, and configure the eth0:
root@pennegaz:pennega # ifconfig eth0 192.168.2.1
Now you have to enable forwarding, entering “1 ” in /proc/sys/net/ipv4/ip_forward
root@pennegaz:xenserver # echo 1 > /proc/sys/net/ipv4/ip_forward
Now you must write a rule to iptables to ensure that the forwarding is performed:
root@pennegaz:xenserver # iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
Now configure the pc B to get static IP 192.168.2.x and the class as a gateway to enter the ip of eth0 pc A (192.168.2.1).
Ed ecco la connessione Ã¨ condivisa.