How to share Internet Access through ethernet cable
Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How to share Internet Access through ethernet cable
Hi, my question here is : How to share Internet Access through ethernet cable
I have connect 2 machines trhough en ETH cable by success (ping each other, up/down load files, ssh ).
So, now, i want to share my wirelless internet connection.
Hi. You will have to set up IP masquerading with NAT (Network Address Translation) on your local gateway box (i.e. "pc-2"), so that connections coming from "pc-1" and directed to hosts on the Internet will be automatically forwarded from the internal (10.10.10.10) to the external (192.168.1.64) interface. This is possible by defining rules with the "iptables" command, which is part of netfilter, the default firewalling and packet filtering software on GNU/Linux systems. There are also several front-ends for iptables that can help with setting up the rules (one or more front-ends might already be included in your distribution).
Why are you proposing the configuration shown? Why not use a router? We have a variety of devices that can simultaneously connect to the internet through a router (24/7). One limitation of your configuration is that pc-2 would have to be on in-order for pc-1 to have Internet access. This reminds that Microsoft Windows Version ??? (circa 1990 something) which used to have the option of designating one computer as a "gateway" so that other computers on the home LAN could access the internet. Anyway, beyond the advice of using a router, I do not have the technical knowledge you are requesting.
Apart from giving a LAN the access to another network (e.g. the Internet), a gateway box is useful whenever you want to have some additional (and controlled) filtering protection for your internal machines. B.t.w. the concept of gateway was not invented by wind0w$, but many years before, when networking was. While the configuration proposed by the OP shows only one box as part of the internal LAN, he might as well use a switch to allow more machines to connect through the gateway. Of course this makes more sense if a firewall is also configured and enabled on the gateway itself, while plugging the machine/switch directly into the (ISP) router would remove that additional and controlled filtering "layer".
Last edited by Philip Lacroix; 04-05-2014 at 07:55 PM.
1st of all, iwant to thanks all that reply.
I use Linux in both machine (Debian,kernel 3.12.6)
i still read the documentation that 'Philip Lacroix' points to, its more than full ...
because some already examples, found on net dont work in my case (or maybe i do something wrong ...)
Like, in 'schneidz's example ,
if i set the gateway of an iface, at an address on a different network, the (route, ip route,..),
dont accept this by error : "interface unreachable"
ie:
Code:
route add -net 10.10.10.0 netmask 255.255.255.0 gw 192.168.1.254 dev eth0
SIOCADDRT: Network is unreachable
and for what i have notice so far,
i think that to enable ip4-forwarding by the echo command,
before or after the route/iptable commands, have a meaning in the way, the above commands acts...,
Is this true, or not ?
I read the posts, but i will post again when i will have something to say, or when solved,
dont think my silince as ignorance.
Thank's
You can add this code to '/etc/rc.local'
BUT, I PREFFER TO, ..., make two links of this script,
1) /etc/network/if-up.d/ - Scripts to execute when an/all interface(s) goes UP
2) /etc/network/if-post-down.d/ - Scripts to execute when an/all interface(s) goes DOWN
When system calls this scripts, it sets the following vars
IFACE - the name of the interface or all
MODE - 'stop' when an ie : ifdown <iface> command happens
- 'start' when an inerface goes up
ADDRFAM - 'inet'
I know its been a long time, but it was such a long time ....
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.