Skip to main content
Welcome guest. | Register | Login | Post

Setting up a LAN network on GNU/Linux

18 replies [Last post]
libervisco's picture
Offline
Joined: 2006-05-04

Hello

This is one of the things I am pretty much a noob at as I don't have any first hand experience with it. We just bought a new LAN cable and are intending to connect our two computers into a LAN network through which we can, among other things, share an internet connection.

I have connected both computers with this cable through an ethernet port and I suppose I now just have to bring up the ethernet interface somehow (detecting and loading the ethernet chip drivers beforehand of course). But what then?

I have some assumptions, but some help would be appreciated and then this thread can serve as a potential reference for others... especially since we not only need to connect the two computers, but share the internet connection of one at the same time. Smiling

(One computer is mine and another is of my sisters. Both run GNU/Linux. I currently run Arch and they're on Ubuntu Dapper.)

Thank you

whisper's picture
Offline
Joined: 2006-09-06
I think the driver for your

I think the driver for your ethernet card wont be a problem the Linux kernel already has compiled in drivers I think. The next thing you'll have to do is bring up the ethernet interface and attribute an ip using ifconfig and adding a route for your local net using the route command etc. I think the following tutorial will help you a lot on that: http://www.tldp.org/LDP/nag/node1.html
This tutorial will help you getting all the basic knowledge and much more about networking on linux including making gateways for other pcs to access the internet.
I hope this helps you Smiling

libervisco's picture
Offline
Joined: 2006-05-04
Thanks whisper! I am

Thanks whisper! Smiling

I am certainly hoping the driver wont be a problem. lspci currently doesn't show anything about ethernet though, but I'm guessing my ethernet chip should be via-rhine or in the worst case realtek. I found the kernel module for via-rhine so I suppose that shouldn't be a problem. I'm not sure about realtek though.

I'm going to BIOS to check if everything is set there just in case.

I'll check that tldp manual out.

libervisco's picture
Offline
Joined: 2006-05-04
Ok good news is that I

Ok good news is that I indeed have via-rhine. It was just disabled in BIOS so it wasn't showing on lspci. I enabled it now and it is there:

[daniel@libernode ~]$ lspci
00:00.0 Host bridge: VIA Technologies, Inc. VT8375 [KM266/KL266] Host Bridge
00:01.0 PCI bridge: VIA Technologies, Inc. VT8633 [Apollo Pro266 AGP]
00:09.0 Network controller: Techsan Electronics Co Ltd B2C2 FlexCopII DVB chip / Technisat SkyStar2 DVB card (rev 02)
00:10.0 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 80)
00:10.1 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 80)
00:10.2 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 80)
00:10.3 USB Controller: VIA Technologies, Inc. USB 2.0 (rev 82)
00:11.0 ISA bridge: VIA Technologies, Inc. VT8235 ISA Bridge
00:11.1 IDE interface: VIA Technologies, Inc. VT82C586A/B/VT82C686/A/B/VT823x/A/C PIPC Bus Master IDE (rev 06)
00:11.5 Multimedia audio controller: VIA Technologies, Inc. VT8233/A/8235/8237 AC97 Audio Controller (rev 50)
00:12.0 Ethernet controller: VIA Technologies, Inc. VT6102 [Rhine-II] (rev 74)
01:00.0 VGA compatible controller: S3 Inc. VT8375 [ProSavage8 KM266/KL266]
whisper's picture
Offline
Joined: 2006-09-06
Good! That tutorial I

Good! That tutorial I mentioned it's very extensive so I better give you a shortcut to the part that "matters" (everything matters Smiling): http://www.tldp.org/LDP/nag/node58.html#SECTION007000000 . But anyway I advise you to read from the begining of the tutorial because it introduces you to the basic concepts of ip networking if you don't have them. Good Luck Smiling

libervisco's picture
Offline
Joined: 2006-05-04
Thanks. I'll probably go

Thanks. I'll probably go through all that to fine tune the LAN. Smiling For now I've found a quick guide here http://www.linuxquestions.org/linux/answers/Networking/Newbies_Guide_to_Small_Home_LAN and managed to set up a working host on my (first) computer with an IP address and a hostname. When I ping daniel.libernode.com which I've assigned as my hostname currently it actually pings the localhost, which is actually the way its supposed to be so I assume it's alright.

[daniel@libernode ~]$ ping daniel.libernode.com
PING localhost.localdomain (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost.localdomain (127.0.0.1): icmp_seq=1 ttl=64 time=0.105 ms
64 bytes from localhost.localdomain (127.0.0.1): icmp_seq=2 ttl=64 time=0.102 ms

And this is what route -n shows:

[daniel@libernode ~]$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.6.6.6        0.0.0.0         255.255.255.255 UH    0      0        0 ppp0
192.169.10.0    0.0.0.0         255.255.255.0   U     0      0        0 eth0
192.168.238.0   0.0.0.0         255.255.255.0   U     0      0        0 dvb0_0
192.168.238.0   0.0.0.0         255.255.255.0   U     0      0        0 dvb0_1
0.0.0.0         0.0.0.0         0.0.0.0         U     0      0        0 ppp0

The dvb inerfaces are for my SatADSL connection, from before (it's my download connection I use through a proxy). The eth0 is there too and shows an IP address of 192.169.10.0 as destination although the local address I set to this computer was 192.169.10.1 so I assume that it has automatically set the expected connection of the other computer as 192.169.10.0 or something..

Oh well I'll look through that tutorial you linked to figure it out. Smiling

Thanks

whisper's picture
Offline
Joined: 2006-09-06
The 192.169.10.0 ip number

The 192.169.10.0 ip number isn't the ip number of your ehternet interface but rather the route of your local network, it allows ip to know where to send the ip datagrams that belong to your network, it is the path to the rest of the computers in your local network. It is this number that defines your network virtually.
Note that I could be wrong on any concept i mentioned because I'm also a noob at this area so read the
ip routing chapter on the tutorial I linked and All your doubts will be enlightned Smiling, but again i advise you to read it from the begining.
I should start reading this tutorial too bacause I never had the conditions to read it decently Smiling

libervisco's picture
Offline
Joined: 2006-05-04
I see.. For the sake of

I see..

For the sake of better differentiating I've changed the eth0 IP to 192.170.0.1 and the destination in the routing table was hence 192.170.0.0.

So I suppose that 192.170.0.0 is the IP address of my network as a whole, 192.170.0.1 is the IP address of my first host as reachable through eth0 and once I assign it on the second host (sisters computer) the 192.170.0.2 will be the address of the second host as reachable through eth0 that is running there.

So the kernel looks to 192.170.0.0 to deal with the network and then sends data back and forth between 192.170.0.1 and 192.170.0.2 and I can then ping each other from each computer, right?

So to set up the basic connection (ability to ping back and forth at the least) the only thing necessary is to do this on both computers:

ifconfig eth0 192.170.0.x

And of course for both computers I can set a hostnamee which is already there anyway... Correct me if I'm wrong..

Well I'll be checking that now anyway. Smiling

whisper's picture
Offline
Joined: 2006-09-06
yep You'reright.

yep You're right. That's it! Smiling But you also have to add the route everytime you set a network using the route command. In your case would be : route add -net 192.170.0.0 netmask 255.255.255.0 If your machine didn't already do that for you.

libervisco's picture
Offline
Joined: 2006-05-04
Cool. I verfied it too. I

Cool. I verfied it too. I pinged the other box succesfully and just to make sure even disconnected the cable to see if anything would change and indeed I couldn't ping it then, so that's it. The basics are set.

Now I just need to set up internet connection sharing. I suppose that I need to create a route between eth0 and ppp0 so that they can use ppp0. My set up is a bit more complex though as I also have a proxy for SatADSL download so I need to make that available to the other computer through eth0 as well. Gonna have to explore the manual to set that up.

Thanks alot for the help so far whisper! Smiling

whisper's picture
Offline
Joined: 2006-09-06
To give a internet access to

To give a internet access to you sisters' computer you'll have to add a default route wich will send any datagrams from you sister computer that dont belong to your network to the gateway (which is your computer) through eth0 and then your computer will send that datagrams through ppp0. You'll have to specify to route that the route your adding it's a default route. But read the tutorial, It explains this stuff better than I Smiling By the way, this time the route must be pointing to a machine and not a net

libervisco's picture
Offline
Joined: 2006-05-04
I see.. I'll read that

I see..

I'll read that tutorial more extensively now.

So far I can only send pings. Still can't ssh from sisters computer to mine or access a web server I started on it.

whisper's picture
Offline
Joined: 2006-09-06
Maybe ssh server/client

Maybe ssh server/client isn't configured yet... can't figure out that because I don't know much about that stuff Puzzled. I hope you can fix that.
Good Luck Smiling

libervisco's picture
Offline
Joined: 2006-05-04
No problem, I'll figure it

No problem, I'll figure it out. Smiling

Thank you

libervisco's picture
Offline
Joined: 2006-05-04
I found out why I couldn't

I found out why I couldn't connect to ssh and http on my first computer. I misapplied the IP address on the second computer. Laughing out loud

Also, after being suggested by a guy from IRC to use iptables for sharing an internet connection over ppp0 I found this page: http://www.linuxsolved.com/forums/ftopic115.html

It instructs making a nice script that sets up a NAT with iptables forwarding traffic from ppp0 to eth0. After setting that up it works now.

Now the tricky part is that ppp0 only represents my EDGE connection which is charged per MB and is hence expensive for anything more than upload. I use my SatADSL connection through a proxy for download stuff and would like to apply that proxy to eth0 as well. My sisters will probably want to download some stuff when I'm not using the connection so this could be great to set up. Smiling

I'm looking into iptables proxying for that...

libervisco's picture
Offline
Joined: 2006-05-04
I was searching and trying

I was searching and trying for hours and I couldn't find out how to wrap up my eth0 connection on my proxy. I experimented a bit with IP tables modifying existing lines that deal with proxying, but nothing.

I was then thinking that if proxy server is located under a 9202 port on the localhost of the first computer then I can just enter its IP/port to firefox and it could work, but it didn't. It needed those special dvb0 interfaces. I even tried forwarding them too through eth0, but only ended up with proxy timeouts do to inability to communicate.

Now I'm not sure anymore what else to try. I just want the other computer which is sharing this computer's internet connection to share in its proxy redirecting download through SatADSL instead of ordinary ppp0. There *must* be a way to achieve that.

libervisco's picture
Offline
Joined: 2006-05-04
I've managed to set all this

I've managed to set all this up. Sisters computer now has access to the same internet connection as this one and all is cool. We also share one folder (a whole partition actually) from my computer as read only on theirs so whatever interesting I may download there it will be available to them. And through ssh and sshfs I have access to their whole computer as their admin, though I've set up a user for myself there as well. Sticking out tongue

The way I did connection sharing is by doing a NAT masquerade as it seems to be called. I "masqueraded" all interfaces used for my full connection (proxy redirects download through a special dvb interface) and then forwarded them to eth0. To use the proxy they have exactly the same setup as I do, just insert the proxy info in firefox and other net and proxy aware applications and that's it, the download will go over SatADSL. For programs which don't support proxying we wrap them in tsocks which overrides their connection replacing it with the one that goes over proxy. Smiling

Thanks for all the help again whisper!

whisper's picture
Offline
Joined: 2006-09-06
I'm glad we had this

I'm glad we had this conversation Smiling. Since I'm no expert at this area there were many concepts i didn't have yet and I needed to clear some doubts i had about networking like this one of ip masquerading (and others) which this conversation put on the surface so I also have to thank you for that.

Thank you for the enlightment libervisco! Smiling

libervisco's picture
Offline
Joined: 2006-05-04
Hehe that's cool.

Hehe that's cool. Smiling

Comment viewing options

Select your preferred way to display the comments and click "Save sett