LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Can I share my lan connection? (https://www.linuxquestions.org/questions/linux-newbie-8/can-i-share-my-lan-connection-687704/)

baig 12-02-2008 07:09 AM

Can I share my lan connection?
 
Hello,

I wonder if I could share my LAN connection with other Computer, W$ndows XP installed on it...

Background:

I have two PCś I can share my LAN Connection from xp to Fedora Through "Share My Connection " option. I have two LAN Cards Installed on my new PC,
1. Through first LAN Card I am connected to my LAN server.
2. Through Second LAN Card My Both PCs are connected together by CAT5 Crossed Wire cable..

Problem:

I don't know how to configure Fedora 9 to make it share LAN connection with my other pc ?

Is there any "Connection Sharing Option " like W$ndows?

Sketch:

It Works:

------[^^]<------------>[^^]<---------------->[^^]

LAN SERVER-----My W$n(OS)--------My Fedora(OS)


How to make it Work?

-------[^^]<------------->[^^]<--------------->[^^]

LAN SERVER<--->My Fedora(OS)----?----W$n(OS)


Thanks in advance.

farslayer 12-02-2008 07:56 AM

If you want a connection sharing option, you can install firestarter, and check the box for Internet Connection Sharing..
It should be in the repository for your Distro..

http://www.fs-security.com/

http://www.fs-security.com/docs/connection-sharing.php

There are other methods of enabling that functionality as well, that can be done from the command line..

David1357 12-02-2008 08:08 AM

Quote:

Originally Posted by baig (Post 3361702)
Is there any "Connection Sharing Option " like W$ndows?

If you need a GUI, then farslayer has given you the right path. If you just want to bridge traffic from one card to the other, you need to create a network bridge on the Fedora box. You will need bridge-utils installed. Here are the steps
Code:

$ brctl addbr bridge0        # Create the bridge
$ brctl addif bridge0 eth0    # Add an interface to the bridge
$ brctl addif bridge0 eth1    # Add an interface to the bridge
$ ifconfig eth0 0            # Remove the IP address from the interface
$ ifconfig eth1 0            # Remove the IP address from the interface
$ ifconfig bridge0 x.x.x.x    # Give the bridge an IP address

If you are using DHCP for the IP address of the Fedora box, you might have to kill dhclient. Run "ps aux | grep dhc" to see what kind of DHCP client might be running.

If you need to make all this permanent, there are several ways to do it. If you need to know how, please post a reply to this thread.

theNbomr 12-02-2008 08:41 AM

There are several GUI-based firewall/router packages. There are also some good canned packages that perform the same purpose. The one I prefer and recommend is http://homelansecurity.sourceforge.net/index.php.
There are examples of how to customize your setup, and it runs right out of the box with very simple configurations.
You may want to run a DHCP server on the firewall, to replace the functionality of your ISP's DHCP if you were using that for your local LAN hosts.
--- rod.

baig 12-02-2008 08:59 AM

@David
 
Yes of Course I would love to hear form you in detail...



I have only on pc as my client and i am my self a client to LAN server..


So let me know how to make it permanent..??

Cheers!!

David1357 12-02-2008 01:34 PM

Quote:

Originally Posted by baig (Post 3361799)
Yes of Course I would love to hear form you in detail...

Are you sure?

Quote:

Originally Posted by baig (Post 3361799)
I have only on pc as my client and i am my self a client to LAN server..
So let me know how to make it permanent..??

The easy way is to add the commands to "/etc/rc.local". The hard way is to write an init script for your system.

If you do not use a splash screen at boot up, an init script can give you visual feedback about whether or not your script succeeded (e.g. the [OK] and [FAIL] messages that show up during boot).

If you do add your commands to "rc.local", you will probably want to make sure you handle errors gracefully. If one of your commands fails, the "rc.local" script will exit, and anything after your commands will not get executed.

You will also want to add logging.

Here is an example of what you might add to "rc.local":
Code:

# Create a network bridge and use DHCP to get an IP address
BRIDGE=bridge0
INTERFACES="eth0 eth1"
LOGFILE="/var/log/bridge.log"

rm -f $LOGFILE
echo "Creating bridge..." >> $LOGFILE 2>&1
if [ ! /usr/sbin/brctl addbr $BRIDGE >> $LOGFILE 2>&1 ] ; then
    echo "Failed." >> $LOGFILE 2>&1
    exit 0
fi
echo "Done." >> $LOGFILE 2>&1

for nic in $INTERFACES ;
do
    echo "Adding interface ${nic}..." >> $LOGFILE 2>&1
    if [ ! brctl addif $BRIDGE $nic ] ; then
        echo "Failed." >> $LOGFILE 2>&1
        exit 0;
    fi;
done
echo "Done." >> $LOGFILE 2>&1

echo "Getting IP address for bridge ${BRIDGE}..." >> $LOGFILE 2>&1
if [ ! dhclient $BRIDGE ] ; then
    echo "Failed." >> $LOGFILE 2>&1
    exit 0
fi
echo "Done." >> $LOGFILE 2>&1

Obviously, this could be improved. The biggest problem is that it does not remove the bridge if adding one of the interfaces fails.

baig 12-02-2008 01:51 PM

Pretty complicated shell script...At least for me....

Anyway, Thank you so very much for your help and suggestion..

firestater is doing its job perfect... as some body had suggested ..Let me examine it first..


Once again thanks to you all above.. and to David for his Script!

Cheers!!

hikerguy 12-03-2008 06:16 PM

Why not go the easy route and install a router? I have a Linux box and a WinXP box connected to a router,
and it works great. If you're simply looking for a way for two different systems to access the Internet, IMHO, that's the best route to go. Not sure if your looking to be able share files between the two, but if it's just Internet access, give that some thought. A router is pretty easy to set up. If you decide to go that route and need help setting it up, I'm sure you'll find a lot of people willing to help out.

Andy

baig 12-03-2008 06:27 PM

Thank you for you suggestion..

But if I simply connect a router then who is going to learn every aspect of Networking? ;-) Never mind!!

The situation will be even more worse than this if I go for a router because till now I don't know anything more that its definition. I do share my printer, Combo and File system inbetween my both pcs. Only one connection can be made at a time using my LAN CABLE... so I need to be acting like Server for my old pc...


Situation is under control with the help of Firestater firewall.
Am able to share my net connection from Fedora 9 to windows.. and I have to run DHCP for my single coz there were probs in static configuration.

Cheers!!


All times are GMT -5. The time now is 10:50 AM.