LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Well I have the cards setup.. But now how do I share!!!? (https://www.linuxquestions.org/questions/linux-networking-3/well-i-have-the-cards-setup-but-now-how-do-i-share-522239/)

TheCowboy 01-23-2007 11:48 PM

Well I have the cards setup.. But now how do I share!!!?
 
I have two network cards installed on my Computer running Debian Sarge rc3 with Kernel Version 2.6.8(I do belive)

My first one is a NIC card 10/100 hooked upto my DSL router. I obtain IP address's via DHCP from the network..

My second card is a D-Link 520G RevA useing a BroadCom chip AR5212

I have my eth0 (Wired NIC) setup and running fine and my ath0 (WiFi) is setup as a Access Point. What i am trying to do is share my internet connection and eventually share a mounted drive from my computer along my wireless network.

My LapTop Does get an IP address Via DHCP but I still have no internet... Below I have included my dhcpd.conf file, my /etc/network/interfaces file and the results from iwconfig ath0 and ifconfig

Any and all help would be greatly appriciated. This is the first time I have attempted networking in Linux.

Thank you in advance!

--/etc/dhcpd.conf-- (I have removed all the commented lines)

LetsHaveAWar:~# cat /etc/dhcpd.conf
#
# Sample configuration file for ISC dhcpd for Debian
#
# $Id: dhcpd.conf,v 1.4.2.2 2002/07/10 03:50:33 peloy Exp $
#

# option definitions common to all supported networks...
#option domain-name "home.network";
#option domain-name-servers home.network;

option subnet-mask 255.255.255.0;
default-lease-time 600;
max-lease-time 7200;

subnet 192.168.2.0 netmask 255.255.255.0 {
range 192.168.2.2 192.168.2.30;
}

--/etc/network/interfaces--

LetsHaveAWar:~# cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp

# Wireless Access Point?
auto ath0
iface ath0 inet static
address 192.168.2.1
network 192.168.2.0
netmask 255.255.255.0
broadcast 192.168.2.255
gateway 192.168.2.1
wireless_essid OneZeroFourUnitEight
wireless_mode Master
wireless_key hello

--Results from iwconfig ath0--

ath0 IEEE 802.11g ESSID:"OneZeroFourUnitEight"
Mode:Master Frequency:2.437 GHz Access Point: 00:0F:3D:AD:B8:52
Bit Rate:0 kb/s Tx-Power:18 dBm Sensitivity=0/3
Retry: off RTS thr: off Fragment thr: off
Encryption key: off
Power Management: off
Link Quality=0/94 Signal level=-95 dBm Noise level=-95 dBm
Rx invalid nwid:438 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0

--Results from ifconfig--

ath0 Link encap:Ethernet HWaddr 00:0F:3D:AD:B8:52
inet6 addr: fe80::20f:3dff:fead:b852/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:18350 errors:0 dropped:0 overruns:0 frame:0
TX packets:825 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:358545 (350.1 KiB) TX bytes:129775 (126.7 KiB)

eth0 Link encap:Ethernet HWaddr 00:E0:29:83:61:6E
inet addr:199.126.196.196 Bcast:199.126.199.255 Mask:255.255.248.0
inet6 addr: fe80::2e0:29ff:fe83:616e/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:19334 errors:0 dropped:0 overruns:0 frame:0
TX packets:19440 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:13113094 (12.5 MiB) TX bytes:2386995 (2.2 MiB)
Interrupt:9 Base address:0xb400

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:80 errors:0 dropped:0 overruns:0 frame:0
TX packets:80 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:5216 (5.0 KiB) TX bytes:5216 (5.0 KiB)

wifi0 Link encap:UNSPEC HWaddr 00-0F-3D-AD-B8-52-00-00-00-00-00-00-00-00-00-00
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:32443 errors:0 dropped:0 overruns:0 frame:105224
TX packets:15227 errors:223 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:199
RX bytes:1855476 (1.7 MiB) TX bytes:998488 (975.0 KiB)
Interrupt:9 Memory:e09ba000-e09ca000


Thanks again for any and all help.

Samotnik 01-24-2007 12:38 AM

You can share your Internet connection in two different ways: with proxy-server (e.g. squid), or with iptables (IP Masquerading) and route utilities.
Detailed help on both this methods you can obtain from man help system to this programs, and from Linux HOWTO's.

cyberfreaker2k 01-24-2007 12:47 AM

Well this might of some help to you
http://www.tldp.org/HOWTO/IP-Masquer...WTO/index.html

Good luck :)

archtoad6 01-26-2007 11:04 AM

It may be that you only need to execute (as root):
Code:

echo "1" > /proc/sys/net/ipv4/ip_forward
this enables forwarding between your NIC's.

TheCowboy 01-27-2007 04:08 PM

Got it guys, I GOT IT!
 
Ok. So here is everything I had to do to build my access point on the DWL520 Rev A.

Now the DWL520+ Rev A Uses the Atheros AR5212 Chipset. Atheros is famous for FirmWare that supports both Master and Managed modes of wireless.

Now what to remember is that I already have installed the madwifi drivers and wireless tools to get my card working. You can get the latest MadWiFi drivers from http://sourceforge.net/projects/madwifi/ and the latest wireless-tool from http://www.hpl.hp.com/personal/Jean_...nux/Tools.html

Also another thing to remember is that the devices referred to in this howto are the names used on my system. Yours may be different. So use your device names as you do this on your system.

----------------------

First I brought down my interface with the ifconfig command:
LetsHaveAWar:~# ifconfig ath0 0.0.0.0 down

Next I checked to see what mode my Wireless interface was in by using the iwconfig utility. On my system the wireless device is refered to as "ath0".
This gave me the following result:

LetsHaveAWar:~# iwconfig ath0
ath0 IEEE 802.11g ESSID:
Mode: Managed Frequency: 0 GHz Access Point: 00:00:00:00:00:00
Bit Rate: 0 kb/s Tx-Power: 18 dBm Sensitivity=0/3
Retry: off RTS thr: off Fragment thr: off
Encryption key: off
Power Management: off
Link Quality=0/94 Signal level=-95 dBm Noise level=-95 dBm
Rx invalid nwid: 780 Rx invalid crypt: 0 Rx invalid frag: 0
Tx excessive retries: 0 Invalid misc: 0 Missed beacon: 0

Now if you see under "Mode:" it says "Managed". Now with a managed card we are not going to get very far in making an access point. So now lets destroy this interface and start over from new. This is where the Wireless-Tools come in...

Now what we do is "destroy" our wireless interface. Dont worry its essayer that it sounds.

essayer:~# wlanconfig ath0 destroy
LetsHaveAWar:~#

Now lets create a new device for our Wireless Access Point.
What we will do is acually "create" the interface into a different mode. Heres how that is done.

LetsHaveAWar:~# wlanconfig ath create wlandev wifi0 wlanmode ap
ath0
LetsHaveAWar:~#

Up above we see that we have created the wireless interface ath0. You see in that command where I put "wifi0" that is the actuall device that my wireless interface uses. ath0 is built on top of this. To find yours uses the ifconfig command at the command line.

Now if we look at "iwconfig ath0" again...

LetsHaveAWar:~# iwconfig ath0
ath0 IEEE 802.11g ESSID:
Mode: Master Frequency: 0 GHz Access Point: 00:00:00:00:00:00
Bit Rate: 0 kb/s Tx-Power: 18 dBm Sensitivity=0/3
Retry: off RTS thr: off Fragment thr: off
Encryption key: off
Power Management: off
Link Quality=0/94 Signal level=-95 dBm Noise level=-95 dBm
Rx invalid nwid: 780 Rx invalid crypt: 0 Rx invalid frag: 0
Tx excessive retries: 0 Invalid misc: 0 Missed beacon: 0

Now we are in Master mode. One step closer.
the next thing we are gonna want to do is install dhcpd if it is not yet installed. On my system I use "Debian Sarge 2.1RC4" with the "Linux GNU 2.6.8" kernel. So to install dhcpd I typed:

LetsHaveAWar:~# apt-get install dhcpd
LetsHaveAWar:~#

Along it goes installing. Done Yay. Now time to edit our configurations. In /etc you will find a file named "dhcpd.conf" I used pico to edit this file.

LetsHaveAWar:~# pico /etc/dhcpd.conf

I commented out all the lines in the example and made my own. I'll paste my configuration for you and explain a little about the settings.

# Setting for DHCPD to answer requests on Ath0

# Defaults for lease time on wireless network
# You can set these times to whatever you would like
default-lease-time 600;
max-lease-time 7200;

# Subnet Mask For Wireless Network
option subnet-mask 255.255.255.0;

# Broadcast Address For Wireless Network
option broadcast-address 192.168.2.255;

# Wireless Interfaces Address
# This is the actuall IP address of your Wireless AccessPoint
# You will need to remember this number to bring
# up your wireless network.
option routers 192.168.2.1;

# Name Server Address
# If you do not have your own DNS server installed on your
# system use the "DNS Servers" provided to you by
# Your ISP. Otherweis you set these to the values of your
# DNS Servers Ip Address.
option domain-name-servers 192.168.1.118, 192.168.2.213, 10.3.1.28, 192.168.0.118;

# Default Domain Name For Clients On Wireless Network
# This option is not required unless you have a
# Domain and the subnet is accessible to the rest
# of the "outside" network.
#option domain-name "ab.hsia.telus.net";

# Wireless network IP Range
# This is the working IP Range of your wireless network
# You shouldnt need more than 5 - 10 address's. A good
# Rule of thumb when it comes to setting your IP Range
# is to double the amount of address's that you need
# to establish your range.
subnet 192.168.2.0 netmask 255.255.255.0 {
range 192.168.2.10 192.168.2.15;
}
LetsHaveAWar:~#

In my configuration I decided to go with a subnet of 192.168.2.0 . So now lets set up Ip Forwarding for our new wireless network. This command would be...

LetsHaveAWar:~# sysctl -w net.ipv4.ip_forward=1
net.ipv4.ip_forward = 1
LestHaveAWar:~#

And just to make sure that that option is set to 1 (On) we type

LetsHaveAWar:~# cat /proc/sys/net/ipv4/ip_forward
1
LestHaveAWar:~#

Notice the returned "1" on its own line. That means "ON". So far So Good.

Now to enable NAT in iptables. Now this HowTo is assuming you do not have any firewall front ends or other firewalls running other than "iptables" For Directions on setting up nat POSTROUTING in any other you would have to consult the documentation for those specific firewalls.

So lets setup nat routing in iptables. Here are the commands that I used.

LestHaveAWar:~# iptables -I INPUT -p all -m state --state ESTABLISHED,RELATED -j ACCEPT
LetsHaveAWar:~# iptables -t nat -I POSTROUTING -o eth0 -j MASQUERADE
LetsHaveAWar:~#

Again I will state that in my iptables I have just a basic set of rules and no other firewall front ends/systems running, and of course "eth0" refers to the wired card that is connected to the outside network.

So now what is left to do. We have the card setup in "MASTER" mode, We have "dhcpd" installed and configured, we have setup "Ip Forwarding", and we have taken care of the "nat routing" in "iptables". Oh yes. We have to give our network an ssid. The ssid is a defining word for your network. For this howto mine it is "MyNetwork" but you can set yours to whatever you like.

LetsHaveAWar:~# iwconfig ath0 essid MyNetwork
LetsHaveAWar:~#

So lets bring up our interface. Do you remember the "router address" we set in our dhcpd.conf. Cause you do need that Ip Address. For me it was 192.168.2.1 so in that case the command I used was.

LetsHaveAWar:~# ifconfig ath0 192.168.2.1 up
LetsHaveAWar:~#

Now lets make sure that we are running. Lets look at iwconfig again.

LetsHaveAWar:~# iwconfig ath0
ath0 IEEE 802.11g ESSID:"MyNetwork"
Mode: Master Frequency: 2.417 GHz Access Point: 00:0F:3D:AD:B8:52
Bit Rate: 0 kb/s Tx-Power: 18 dBm Sensitivity=0/3
Retry: off RTS thr: off Fragment thr: off
Encryption key: off
Power Management: off
Link Quality=0/94 Signal level=-95 dBm Noise level=-95 dBm
Rx invalid nwid: 788 Rx invalid crypt: 0 Rx invalid frag: 0
Tx excessive retries: 0 Invalid misc: 0 Missed beacon: 0

LetsHaveAWar:~#

Now notice how we have ESSID as "MyNetwork", our mode is "Master" and we have something else that we didnt before... "Access Point: 00:0F:3D:AD:B8:52" Now one last step...

LetsHaveAWar:~# dhcpd ath0
Internet Software Consortium DHCP Server 2.0pl5
Copyright 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium.
All rights reserved.

Please contribute if you find this software useful.
For info, please visit http://www.isc.org/dhcp-contrib.html

Listening on LPF/ath0/00:0f:3d:ad:b8:52/192.168.2.0
Sending on LPF/ath0/00:0f:3d:ad:b8:52/192.168.2.0

LetsHaveAWar:~#

Done. Thats all there was too it. I would like to thank everyone that has helped me in getting my Wireless AccessPoint running and going. And of course encourage anyone else to spread some of their wisdom on this subject. Another way or a better way. Thanks to the guys here on LinuxQuestions and #Linux on the DALnet IRC Network irc.dal.net for all their help.

Micro420 01-27-2007 04:11 PM

Awesome! Glad you got it working, and best of all, you put detailed instructions on how to get it up and running for future reference. This should go in the how-to section.

archtoad6 01-29-2007 02:36 PM

I hope piling on w/ praise & positive feedback is ok :)

Nicely done. And I should have mentioned:
Code:

cat /proc/sys/net/ipv4/ip_forward
as a way check the state of IP fwd'ing.

Let me mention for others reading this why it's so important to post the solution as well as the problem --
it creates an archive of solutions for those who come after.

Again good job & thank you.

TheCowboy 02-01-2007 11:41 AM

OK guys, Thanks for your compliments on my howto. I do plan on putting it in the howto's sections but there are more things that I think need to be included. I have done a lil research but havent found much "Helpful" information on setting this up.

Now whenever I restart my system. Everything gets set back to normal settings. ath0 gets reset from master to managed, ip forwarding gets set back to 0. and I do belive my iptables rules are getting reset(Not sure on this). So now I need to know how to get everything setup at boot without me haveing to "manually" do it(Im getting really good at setting it up now. LOL) I dont know exactly how inittab works. Thanks in advance for you help guys.

IAamDave 02-02-2007 03:55 AM

Thanks for the howto.
 
Cowboy.

Brilliant stuff.

I'm about to set up a wireless netword on Suse 10.0, I am in fact going to use a pair of wireless routers, one at the phone point downstairt (allready set up for my IP with an XP laptop), and then plug another unit the same into the back of my Linux box (via the network port obviously).

Now I am hoping that this will work straight out of the box, or alternatively only need a little bit of IPing set up.

but I have a feeling that your instruction may come in very usefull... I actually set up another thread (under Balkin F5D7633-4 wireless setup). As I wasn't sure if this was a possibility, but I've decided to jump in feet first and see what happens!

I do have one question of the howto you have posted.

You regularly use a number of commands from the command line. This looks to me as though they are changing the settings for the network setup.

My question is this, the commands are obviously being used to change the setup during system boot up. How are they saved? and why not edit the file directly - assuming that they are saved to a file somewhere.


Cheers guys.

:newbie:

TheCowboy 02-02-2007 11:10 PM

Dave;

I do belive I have to for it to set itself up On Boot in the init. Im not sure on this. I'll be posting as soon as I find the answer to my questions.

One thing you might want to make sure of is that both the wireless network devices you are useing will work in "master" mode.

All the command line stuff I did was changeing network settings, The first bunch are basicly setting the wireless card up for master mode, and the iptables so it routes the WAN through the firewall to my wireless card that containes the WAN. the sysctl command that I use is to setup IPv4.Forwarding through to the other nic card. DHCPD is used of course to assign IP Address's to the connecting computers on the wireless network.

There will be more posted to this as soon as possible. Thanks for the compliment and I look foward to seeing you get yours setup and working.

Micro420 02-03-2007 12:32 AM

Quote:

Originally Posted by TheCowboy
OK guys, Thanks for your compliments on my howto. I do plan on putting it in the howto's sections but there are more things that I think need to be included. I have done a lil research but havent found much "Helpful" information on setting this up.

Now whenever I restart my system. Everything gets set back to normal settings. ath0 gets reset from master to managed, ip forwarding gets set back to 0. and I do belive my iptables rules are getting reset(Not sure on this). So now I need to know how to get everything setup at boot without me haveing to "manually" do it(Im getting really good at setting it up now. LOL) I dont know exactly how inittab works. Thanks in advance for you help guys.

I found this on how to save your iptables

Code:

Rules created with the iptables command are stored in memory. If the system is restarted before saving the iptables rule set, all rules will be lost. For netfilter rules to persist through system reboot, they need to be saved. To do this, log in as root and type:

/sbin/service iptables save

This executes the iptables init script, which runs the /sbin/iptables-save program and writes the current iptables configuration to /etc/sysconfig/iptables. The existing /etc/sysconfig/iptables file is saved as /etc/sysconfig/iptables.save.

The next time the system boots, the iptables init script reapplies the rules saved in /etc/sysconfig/iptables by using the /sbin/iptables-restore command.

While it is always a good idea to test a new iptables rule before committing it to the /etc/sysconfig/iptables file, it is possible to copy iptables rules into this file from another system's version of this file. This provides a quick way to distribute sets of iptables rules to multiple machines.

source: http://mirror.centos.org/centos/3/do...es-saving.html

IAamDave 02-06-2007 04:56 PM

playing at setting up wireless . oh joy of joys!
 
OK brief background on what I am attempting to set up at home.

I have got 2 Belking F5D7633-4 modem routers.

First is hooked to the interet (ADSL) and works beatufilly when I use my XP laptop (either hooked straight into the back of with a USB wireless adapter.

The second is hooked into my linux box via the Ethernet port (eth0).

it is possible to set the routers up with a web browser by accessing the router via it's IP (default 192.168.2.1).

I have set this detail to be 192.168.2.100 on the router connected to the linux box. I have done this to prevent any potential confusion with trying to route through to the internet.

I have had to set up the router as a host using the command

# ip route add 192.168.2.100 via 192.168.2.2

192.168.2.2 is the IP I have designated for my eth0 port. This has enabled me to ping my router that is at 192.168.2.100

I though that I was getting somewhere so I then used the same command to set a route from the linux router (192...100) to the main router plugged into the phone command

# ip route add 192.168.2.1 via 192.168.2.100

the ip table then suggest that everthing has configured Ok but I am unable to ping to the 192...1 address, and I can't ping back to the Linux router from my xp laptop either.....

I just tried to change the setting on the Main router to enable ICMP, then tried to ping it from the linux box... nothing seems to happen?? not messages or anthing until I ctrl^c and then I juest get

[14]+ stopped ping 192.168.2.1

:scratch:

Anyone got any ideas?? I have allready tried Cowboys command for searching for wireless networks etc?

In fact I am about to "give up" for the evening and see if I can make it work from XP (it is on dual boot).

Will report back later if I can!

:newbie:

TheCowboy 02-08-2007 09:22 PM

hrmmmm
 
Im a little confused on your setup. So your ADSL modem goes into a router that goes into a linux box... but the linux box is also a router?

UhhMaybe 04-18-2007 05:34 PM

To view the router from a browser in the Linux Box...open the browser and instead of an URL use the IP of the router. More often, it Will be the IP that sets up the router from the Vendor. If YOU do not see the setup page or the welcome screen, then YOU'RE using the wrong IP. Assuming the router is functioning correctly. Try going to the Vendors website for details. Or www.google.com for manufacturers details, manuals, versions and possible work-arounds. Just a note: both Computers need to be with the same IP configuration. Like [xxx.yyy.zzz.1] and [xxx.yyy.zzz.2]. Good luck.


All times are GMT -5. The time now is 04:58 PM.