# Ok, total loss on internet sharing

## therobot

I'm trying to set up internet connection sharing, and I'm at just a total loss here. I've been trying to piece it together with stuff from all over this forum, but I just can't figure it out.

Would someone be able to help me out at all, explaining how to do it? Or is there somewhere I can go to get a simple explanation?

Any help would be greatly appreciated.

thanks.

----------

## delta407

What "internet connection sharing", exactly? What is your connection to the outside world? Do you have a private subnet? Are you routed, NAT-ed, or proxied? Or don't you have anything set up?

More information, please.

----------

## therobot

sorry. My setup is: I have DSL coming in through eth1, which uses DHCP to get an IP address, and I have a cable going from eth0 to a windows 2000 computer. I'm just wanting to share my connection with the other computer.

I'm not totally sure how to get it set up....

----------

## mksoft

Place somewere in your startup:

```
#This enables masquarding

iptables -A POSTROUTING -t nat -o eth1 -j MASQUERADE

# activate IP-Forwarding

echo 1 > /proc/sys/net/ipv4/ip_forward
```

You need to have support for masquareding in your kernel (compiled in or as modules). If you're using modules, don't forget to load them before.

And set the other computer's gateway to your machine (ip address of eth0. don't forget to set dns as well).

----------

## therobot

ok, i tried that, but i get these errors when starting up:

```
modprobe: Can't locate module ip_tables

iptables v1.2.6a: Can't initialize iptables table 'nat': Table does not exist(Do you need to insmod?)

Perhaps iptables on your kernel needs to be upgraded?
```

I'm pretty sure i loaded iptables into my kernel, but i'm not sure what this error means?

----------

## mb

u have to recompile your kernel an add iptables support + needed modules like ftp... and full nat + masq

Networking options  ---> 

  IP: Netfilter Configuration  --->

modprobe it before calling the script.... 

#mb

----------

## therobot

I already compiled my kernel that way...

what do i need to modprobe?

----------

## fbleagh

did u compile them as modules or builtin ?

----------

## Rylan

You said you have a "cable" going from eth0 to the win2000 box.  Is this a crossover cable?  You can't just plug cat 5 into two nic's, you need to have one end go into a hub/switch (unless it's a crossover cable).

My first step, were I you-- would be to give each computer a nic with a 192.168.0.x/24 address (the /24 means the first 3 fields' numbers are set in stone.  /8 would mean the first field is the only constant 10.x.x.x).  Then cable them together and see if they can ping each other.  If so, that means both ethernet cards are working, and can talk to each other.  

Then step two, which other people are helping you with, is getting iptables working right.  Let me know how it goes.

----------

## mb

 *therobot wrote:*   

> I already compiled my kernel that way...
> 
> what do i need to modprobe?

 

for gateways, routers and servers it's a good idea to include this into the kernel and disable loadable module support for security reasons...

#mb

----------

## therobot

yes, it is a crossover cable, and they can ping each other.

----------

## Al'Capone

 *Quote:*   

> I have DSL coming in through eth1, which uses DHCP to get an IP address

 

eth1 gets its IP address from what DHCP server?? is the DSL CPE a Router??

if that is the case just buy a cheap hub and you are set to go plug in both your gentoo box and your Winblows 2000 machine to the hub.

If the DSL CPE is just a bridge then you need to enable routing support on your kernel under Network option TCP/IP  firts and foremost!!!  then you can go on configuring NAT , IPtables, and DNS of course you need to setup gentoo to provide dhcp services to your Winblows machine only if you plan to add more network nodes later on .

 if all you have is one machine then no need for dhcp, or nat at all  just do a static ip portmap to your winblows machine you do however need dns services on the winblows machine configured and the static entries of your winblows machine set up on your /etc/host and /etc/hostname configuration on the gentoo machine.

This could be overwhelming but have no fear head over to http://www.tldp.org/HOWTO/Net-HOWTO/ it is the linux network how to and browse through it for help.

Mind you the painless and quicker way to get your internet sharing going if you have a DSL bridge is to get a DSL router/switch like linksys or d-link or if you have an old 486 box sitting around with no harddrive but a floppy head over to http://www.coyotelinux.com/ and make your own   :Very Happy:   it loads from floppy and it is quick and better than cisco   :Razz: 

Hope that helped

Cheers

----------

## hamletmun

HOWTO  - Make your Internet Connection Sharing to work

From ISP to GENTOO - (eth0:DHCP or STATIC IP)

From GENTOO to WINDOWS - (eth1:192.168.0.1)

1.

insmod your.nic.module (i.e. "insmod 3c59x") for both nics if differ

2.

if your ISP uses DHCP, "dhcpcd eth0"

if static, "ifconfig eth0 your.static.ip netmask 255.255.255.0 gateway your.isp.gateway"

Now is time to configure the connection sharing

this is just for kenels greater than 2.4.x with iptables

1.

insmod iptables_nat

2. 

echo 1 >/proc/sys/net/ipv4/ip_forward

3.

iptables -F 

iptables -t nat -F 

iptables -P INPUT ACCEPT 

iptables -P OUTPUT ACCEPT 

iptables -P FORWARD ACCEPT 

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

(if your linux uses eth0 to connect your isp)

4.

In the Windows Machine:

192.168.0.1 in the gateway

numbers from your /etc/resolv.conf in DNS server

----------

## sulu

Fully ACK.

Thats exactly the same what i did and it works flawlessy.

----------

## thegazer

uhhmmm..

I can't find iptables_nat which option I have to enable/modulize on the kernel config to have this??

----------

## thegazer

oops my bad 

got it solved 

thanks!

----------

## 870Fragmaster

how do I use the iptables init script? Where do you put the rules and what are the rules?

----------

## WarMachine

I use PPPoE, so the interface that I actually connect with is ppp0.  Would I set 

```

-o interface

```

to ppp0, or eth0, my guess is ppp0 but not sure

also, my ISP is refusing to give me the IP of my DNS server, saying it's assigned "dynamically" on logon.  Is there any way I can find it so I can specify in resolv.conf and on the windows machines? (I use bellsouth from central florida)

----------

## sciack

Hi all,

please help me as well. I got another situation.

192.168.0.1 my linux box with a speedtouch adsl (ip gotten through dhcp) on ppp0

192.168.0.20 winxp

192.168.0.30 win98

i have set them with gateway 192.168.0.1 i have enabled iptables with the forwarding but it still doesnt work at all. i cannot ping from my windows machines.

I have just a eth0 connected to a switch such as all the other windows machines.

help me!

 :Wink: 

----------

## cato`

LinWall is a firewall using linux-2.4-kernels iptables. Iptables is a packet filter supporting the use of NAT. This way you will have full control of what you do with what packets while you in the same time have the possibility to share your internet-connection with your LAN. Of course you can run LinWall on a stand-alone machine, or a transparent firewall (with certain modifications). LinWall is perfect for home-users and small offices, both with static and dynamic IP.

Features

The newest release (v2.6) has the following features:

    * NAT (sharing of internet-connection)

    * Open/close UDP and TCP ports

    * Port-forwarding UDP and TCP ports

    * State-full inspection of packets (like in FTP)

    * Support for many internal networks

    * Protects against an attack towards certain Alcatel DSL-modems

    * Nice for both dynamic and static connections

URL: http://www.linnet.no/firewall/

It's really simple, but you still need the iptables stuff in your kernel!

----------

## Braempje

 *WarMachine wrote:*   

> I use PPPoE, so the interface that I actually connect with is ppp0.  Would I set 
> 
> ```
> 
> -o interface
> ...

 

The interface is ppp0, eth0 doesn't work.

About your dns: it will be in your resolv.conf whenever you make a connection (if you have specified it in the setup of the adslpackage). 

I also have an isp who assigns his dns automatically, but I know that if you take to dns servers fixed, most of the time you have them all... They don't change that often because most isps also have dialup users, and they don't have a dynamic dns facility (I think).

----------

## tgoodaire

 *mb wrote:*   

>  *therobot wrote:*   I already compiled my kernel that way...
> 
> what do i need to modprobe? 
> 
> for gateways, routers and servers it's a good idea to include this into the kernel and disable loadable module support for security reasons...
> ...

 

What security reasons? You need to be root to load a kernel module. If someone has hacked root on your gateway, router, or server, it's game over anyway.

----------

## HeadHolio

 *hamletmun wrote:*   

> HOWTO  - Make your Internet Connection Sharing to work
> 
> From ISP to GENTOO - (eth0:DHCP or STATIC IP)
> 
> From GENTOO to WINDOWS - (eth1:192.168.0.1)
> ...

 

hamletmun: Those are the easiest and most helpful instructions I have seen on getting internet connection sharing to work.  Thank you.

----------

## anil_et

Hi All

Here I am in trouble

when I do 

```
 echo 1 >/proc/sys/net/ipv4/ip_forward 

 

```

getting error

```
puppy anil # echo "1" > /proc/sys/net/ipv4/ip_forward

bash: /proc/sys/net/ipv4/ip_forward: No such file or directory
```

What could be wrong ?

my lsmod shows

```
Module                  Size  Used by

appletalk              28640   1  (autoclean)

ipx                    23864   1  (autoclean)

floppy                 53596   0  (autoclean)

ipt_MASQUERADE          1656   1  (autoclean)

af_packet              16488   1  (autoclean)

rtc                     8136   0  (autoclean)

iptable_nat            18950   1  [ipt_MASQUERADE]

ip_conntrack           22524   1  [ipt_MASQUERADE iptable_nat]

ip_tables              13568   4  [ipt_MASQUERADE iptable_nat]

fglrx                 174440 206

sr_mod                 16024   0  (unused)

cdrom                  25220   0  [sr_mod]

ide-scsi               10672   0

sg                     30076   0  (unused)

sd_mod                 11276   0  (unused)

i810_audio             27164   1

ac97_codec             14040   0  [i810_audio]

soundcore               4612   2  [i810_audio]

uhci                   28412   0  (unused)

hid                    21988   0  (unused)

input                   3968   0  [hid]

usb-storage           124432   0  (unused)

usbcore                69292   1  [uhci hid usb-storage]

scsi_mod               63924   4  [sr_mod ide-scsi sg sd_mod usb-storage]

e100                   53128   1

3c59x                  27664   1

```

Pls help me

Anil

----------

