LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 07-16-2007, 07:30 PM   #1
tntcoder
Member
 
Registered: Sep 2003
Distribution: Arch
Posts: 89

Rep: Reputation: 15
AdHoc Gateway Configuration Advice


Hi,

I have one eth0 device on my pc, 192.168.1.65 using default gateway 192.168.1.1.

I have added a wireless card using ndiswrappers with the view of setting it up in AdHoc mode, to allow my laptop to connect to the network and access the internet through the gateway 192.168.1.1.

Now my wireless card ra0 is setup and running in adhoc mode:

Code:
ra0       RT2500 Wireless  ESSID:"mynetwork"  
          Mode:Ad-Hoc  Frequency=2.412 GHz  Cell: 6A:39:88:E7:1E:70   
          Bit Rate:11 Mb/s   Tx-Power:2 dBm   
          RTS thr:off   Fragment thr:off
          Encryption key:off
          Link Quality=66/100  Signal level=-46 dBm  Noise level:-208 dBm
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0
My laptop finds the "mynetwork" fine and i have configured it to connect to it with IP 192.168.1.20 / 255.255.255.0 and gateway 192.168.1.1, so its on the same subnet as the eth0 device.

It seems to connect to the network perfectly, but i cant browse the net or ping any other PCs on the network.


Any idea how i can fix this, do i have to enable some kind of packet forwarding to get packets from the ra0 interface moved onto the eth0 interface and along to the gateway?

Also the ra0 interface doesnt seem to have an IP address, are adhoc interfaces supposed to?

I created the adhoc network simply by: iwconfig ra0 essid mynetwork mode Ad-Hoc

Thanks very much for any help,
Jack
 
Old 07-16-2007, 07:41 PM   #2
MS3FGX
Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,747

Rep: Reputation: 333Reputation: 333Reputation: 333Reputation: 333
Yes, the ad-hoc card must be configured with proper TCP/IP information before you can do anything else. The wireless card should have an address that is not in the same network as eth0. So if your eth0 is 192.168.1.65, then the wireless card should be 192.168.2.1. That means the devices connecting to the wireless card must have an IP in that network, for example, 192.168.2.2. The laptop would also be using 192.168.2.1 as the gateway in this example, not 192.168.1.1.

This is because the computer needs to act as a router in this case, and to do that you must have each interface in a separate network.

Now, to setup routing you need to do the following:

Code:
iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
iptables --append FORWARD --in-interface ra0 -j ACCEPT
echo 1 > /proc/sys/net/ipv4/ip_forward
Obviously you don't want to type that out every time, so you should either put those lines into your boot scripts, or just make a script that contains those lines.

Once you have a correct IP for ra0 and the laptop, and the iptables lines have been run, you should be able to connect to the Internet from the laptop side.
 
Old 07-17-2007, 02:44 AM   #3
tntcoder
Member
 
Registered: Sep 2003
Distribution: Arch
Posts: 89

Original Poster
Rep: Reputation: 15
Thanks alot,

Ive done everything you suggested but it still isn't working

The ra0 card now has an IP of 192.168.2.2, and the connecting laptop has an IP: 192.168.2.4 Subnet: 255.255.255.0 Gw: 192.168.2.2

Heres the relevant data:

Code:
ra0       RT2500 Wireless  ESSID:"mynetwork"
          Mode:Managed  Frequency=2.412 GHz  Bit Rate:11 Mb/s   Tx-Power:0 dBm  
          RTS thr:off   Fragment thr:off
          Link Quality=0/100  Signal level=-120 dBm  Noise level:-200 dBm
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

ra0       Link encap:Ethernet  HWaddr 00:11:50:8F:51:71
          inet addr:192.168.2.2  Bcast:192.168.2.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:642716 errors:0 dropped:0 overruns:0 carrier:0
          collisions:1 txqueuelen:1000
          RX bytes:0 (0.0 b)  TX bytes:31416327 (29.9 MiB)
          Interrupt:19


eth0      Link encap:Ethernet  HWaddr 00:11:D8:D9:80:F0
          inet addr:192.168.1.65  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::211:d8ff:fed9:80f0/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3380 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1987 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1531268 (1.4 MiB)  TX bytes:331836 (324.0 KiB)
          Interrupt:16 Base address:0xa000

Kernel IP routeing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
172.16.176.0    *               255.255.255.0   U     0      0        0 vmnet8
192.168.2.0     *               255.255.255.0   U     0      0        0 ra0
192.168.1.0     *               255.255.255.0   U     0      0        0 eth0
192.168.157.0   *               255.255.255.0   U     0      0        0 vmnet1
link-local      *               255.255.0.0     U     1000   0        0 eth0
default         192.168.1.1     0.0.0.0         UG    0      0        0 eth0

IPTables:
Chain FORWARD (policy ACCEPT)
target     prot opt source               destination
ACCEPT     0    --  anywhere             anywhere
ACCEPT     0    --  anywhere             anywhere
Any ideas on why its not working?
 
Old 07-17-2007, 06:46 AM   #4
tntcoder
Member
 
Registered: Sep 2003
Distribution: Arch
Posts: 89

Original Poster
Rep: Reputation: 15
I just rebooted and did it all again, and i can now on the laptop browse my local webserver (http://192.168.1.20) on the laptop, however i cannot access exterenal internet IP/FQDNs any ideas?
 
Old 07-17-2007, 04:03 PM   #5
MS3FGX
Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,747

Rep: Reputation: 333Reputation: 333Reputation: 333Reputation: 333
What DNS servers are you using on the laptop side? It would be best to use your ISPs servers directly, or at least public ones on the Internet (such as 4.2.2.2 and 4.2.2.3). If you are trying to use the gateway (192.168.2.1) as DNS as you would when connecting to the router directly, then that is not going to work.
 
Old 07-17-2007, 04:22 PM   #6
tntcoder
Member
 
Registered: Sep 2003
Distribution: Arch
Posts: 89

Original Poster
Rep: Reputation: 15
Thanks, ive tried with the ISPs DNS servers, but it still isn't connecting, even using website IPs rather than the domain name doesn't work. Just seems as though the routing isnt hitting my actual router (192.168.1.1)
 
Old 07-17-2007, 06:44 PM   #7
MS3FGX
Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,747

Rep: Reputation: 333Reputation: 333Reputation: 333Reputation: 333
That's strange. I assume you can ping websites and connect from the Linux computer doing the routing?

Have you tried doing a traceroute from the laptop to the Internet to see where it is stopping?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Looking to configure linux as a Gateway/Firewall + Other Services but need advice! BadTim Linux - Networking 5 07-06-2007 03:31 PM
Atypical Gateway Configuration Centinul Linux - Networking 24 08-05-2005 05:10 PM
Gateway Configuration JustJD Linux - Networking 6 07-22-2005 01:47 AM
Sendmail configuration with DynDns... need advice verbal Linux - Software 4 04-16-2004 06:11 PM
Advice on Gateway and IP address bruce1271 Linux - Networking 10 06-18-2003 06:20 PM


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

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration