Share internet connection

posted by onMonday February 28th, 2011, 315128 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

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 (

Ed ecco la connessione è condivisa.

1 Replay for “Share internet connection”

  1. Ireland says:

    Your article was ecxelnlet and erudite.

Leave a Reply

Your email address will not be published. Required fields are marked *