LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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
  Search this Thread
Old 03-05-2006, 05:03 PM   #1
m4rk0
LQ Newbie
 
Registered: Jul 2005
Distribution: Debian, CentOS
Posts: 12

Rep: Reputation: 0
Unhappy Routing between 2 interfaces?


Hello everyone.

I'm playing with this about 3 days, and sometimes works sometimes not but never perfect.

I have eth0 (connected in switch with internet connection) and ra0 (wireless card where few users connects).

I need to use gateway 192.168.0.160 / 16

I want to route internet trought eth0 to ra0 and I want to access another computers which are in switch where is connected eth0...

Please help me...

I tried to make it eye-candy (like eth0 @ 192.168.1.1 lan users .1.XXX & ra0 @ 192.168.2.1 wifi users .2.XXX) but no luck.

Thank You in advance!
 
Old 03-05-2006, 06:46 PM   #2
stefan_nicolau
Member
 
Registered: Jun 2005
Location: Canada
Distribution: Debian Etch/Sid, Ubuntu
Posts: 529

Rep: Reputation: 32
a) Please post details of your network settitngs.
b) Be more precise: what do you want to achieve?
c) What have you tried?
d) What exactly is not working?
 
Old 03-05-2006, 07:15 PM   #3
fotoguy
Senior Member
 
Registered: Mar 2003
Location: Brisbane Queensland Australia
Distribution: Custom Debian Live ISO's
Posts: 1,291

Rep: Reputation: 62
Quote:
Originally Posted by m4rk0
Hello everyone.

I'm playing with this about 3 days, and sometimes works sometimes not but never perfect.

I have eth0 (connected in switch with internet connection) and ra0 (wireless card where few users connects).

I need to use gateway 192.168.0.160 / 16

I want to route internet trought eth0 to ra0 and I want to access another computers which are in switch where is connected eth0...

Please help me...

I tried to make it eye-candy (like eth0 @ 192.168.1.1 lan users .1.XXX & ra0 @ 192.168.2.1 wifi users .2.XXX) but no luck.

Thank You in advance!
Yes this is very vague and hard to understand what you are trying to achieve. You have a gateway at 192.168.0.160, your eth0 card is on 192.168.1.1, these are 2 different networks. eth0 must be set to the same network as the gateway it needs to use something like 192.168.0.100

Also need to have a look at your routing table on the machine with the eth0 and ra0 card in it. To see the routing tables at the command prompt as root type:

route -n

It will give you something like this, this is from one of my machines:

billyg@gateway:~ $ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
111.222.333.444 0.0.0.0 255.255.255.255 UH 0 0 0 ppp0
111.222.333.444 0.0.0.0 255.255.255.255 UH 0 0 0 ipsec0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
1.1.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
0.0.0.0 111.222.333.444 0.0.0.0 UG 0 0 0 ppp0

The 111.222.333.444 is not a real address, i'm just masking my real ip address. Plus your interfaces will vary from this, but it will give you a general idea.
 
Old 03-06-2006, 09:51 AM   #4
m4rk0
LQ Newbie
 
Registered: Jul 2005
Distribution: Debian, CentOS
Posts: 12

Original Poster
Rep: Reputation: 0
Hello again...

First I tried this:
Code:
ifconfig eth0 192.168.1.1 netmask 255.255.0.0 up
ifconfig ra0 down
ifconfig ra0 10.0.0.1 netmask 255.0.0.0 up

route add default gw 192.168.0.160

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

iptables -F
iptables -X

iptables -t nat -A POSTROUTING -s 10.0.0.0/24 -j MASQUERADE
And that worked for a while, and after restart i tried same setup and it doesn't works...

After that I tried
Code:
# Set up interfaces

ifconfig eth0 192.168.1.1 netmask 255.255.0.0 broadcast 192.168.255.255 up
ifconfig ra0 192.168.10.1 netmask 255.255.0.0 broadcast 192.168.10.255 up

# Delete and flush iptables

iptables -F
iptables -X
iptables --flush
iptables --table nat --flush
iptables --delete-chain 
iptables --table nat --delete-chain

# Set up IP FORWARDing and Masquerading

iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
iptables --append FORWARD --in-interface ra0 -j ACCEPT

# Enables packet forwarding by kernel

echo 1 > /proc/sys/net/ipv4/ip_forward
And It doesn't works too...

And lots of other not saved tricks...
 
Old 03-06-2006, 09:54 AM   #5
m4rk0
LQ Newbie
 
Registered: Jul 2005
Distribution: Debian, CentOS
Posts: 12

Original Poster
Rep: Reputation: 0
@stefan_nicolau:
d) I want to share internet connection on eth0 with ra0, and communication with users on wireless and users on switch where is eth0 connected.
I get this once with some stupid routes, and restarted machine and everything is gone
 
Old 03-06-2006, 10:48 AM   #6
stefan_nicolau
Member
 
Registered: Jun 2005
Location: Canada
Distribution: Debian Etch/Sid, Ubuntu
Posts: 529

Rep: Reputation: 32
Quote:
And that worked for a while, and after restart i tried same setup and it doesn't works...
I assume that you know that all the settings are lost on reboot, and that you have to do them again.

I don't think that you need masquarading (correct me if I missed something)

And I repeat my original question: in what way does this setup not work?
 
Old 03-06-2006, 11:08 AM   #7
m4rk0
LQ Newbie
 
Registered: Jul 2005
Distribution: Debian, CentOS
Posts: 12

Original Poster
Rep: Reputation: 0
But I tried already to back old configs but it doesn't works maybe I missed something but anyway it doesn't works...

It doesn't work in way that users connected at ra0 doesn't have internet connection and can't ping ra0 ip or eth0 ip or any user behind eth0...

That worked for I while and I messed something...
 
Old 03-06-2006, 11:25 AM   #8
stefan_nicolau
Member
 
Registered: Jun 2005
Location: Canada
Distribution: Debian Etch/Sid, Ubuntu
Posts: 529

Rep: Reputation: 32
Quote:
users connected at ra0 doesn't have internet connection and can't ping ra0 ip
Then, how do you know the users are actually connected? This looks more like a wireless connection problem than a routing problem. You should double-check your wireless and firewall settings.
 
Old 03-06-2006, 12:28 PM   #9
m4rk0
LQ Newbie
 
Registered: Jul 2005
Distribution: Debian, CentOS
Posts: 12

Original Poster
Rep: Reputation: 0
Look, I can now ping linux box (eth0 & ra0 ip) but I can't ping gateway or any user in network behind eth0....

My network configuration now looks like:
Code:
ifconfig eth0 192.168.0.1 netmask 255.255.0.0 up
ifconfig ra0 192.168.10.1 netmask 255.255.255.0 up

route del default gw 192.168.0.160

echo "1" > /proc/sys/net/ipv4/ip_forward
Quote:
# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.10.0 0.0.0.0 255.255.255.0 U 0 0 0 ra0
192.168.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
0.0.0.0 192.168.0.160 0.0.0.0 UG 0 0 0 eth0
Quote:
# ifconfig
eth0 Link encap:Ethernet HWaddr 00:80:48:D9:F0:56
inet addr:192.168.0.1 Bcast:192.168.0.255 Mask:255.255.0.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:37601 errors:0 dropped:0 overruns:0 frame:30
TX packets:5106 errors:0 dropped:0 overruns:0 carrier:0
collisions:46 txqueuelen:1000
RX bytes:3004970 (2.8 Mb) TX bytes:861113 (840.9 Kb)
Interrupt:5 Base address:0xec00

ra0 Link encap:Ethernet HWaddr 00:09:F3:72:11:1B
inet addr:192.168.10.1 Bcast:192.168.10.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:362 errors:0 dropped:0 overruns:0 frame:0
TX packets:1408 errors:7014 dropped:7014 overruns:0 carrier:0
collisions:324 txqueuelen:1000
RX bytes:41333 (40.3 Kb) TX bytes:555738 (542.7 Kb)
Interrupt:11 Base address:0x5000

Last edited by m4rk0; 03-06-2006 at 12:30 PM. Reason: Disable smilies in text
 
Old 03-06-2006, 12:42 PM   #10
stefan_nicolau
Member
 
Registered: Jun 2005
Location: Canada
Distribution: Debian Etch/Sid, Ubuntu
Posts: 529

Rep: Reputation: 32
Quote:
ifconfig eth0 192.168.0.1 netmask 255.255.0.0 up
ifconfig ra0 192.168.10.1 netmask 255.255.255.0 up
These networks overlap!
 
Old 03-06-2006, 12:53 PM   #11
m4rk0
LQ Newbie
 
Registered: Jul 2005
Distribution: Debian, CentOS
Posts: 12

Original Poster
Rep: Reputation: 0
Than can you show me example how you would configure my network?

Thank you on fast answers
 
Old 03-06-2006, 03:52 PM   #12
Brian1
LQ Guru
 
Registered: Jan 2003
Location: Seymour, Indiana
Distribution: Distribution: RHEL 5 with Pieces of this and that. Kernel 2.6.23.1, KDE 3.5.8 and KDE 4.0 beta, Plu
Posts: 5,700

Rep: Reputation: 65
If using ip masquerading from ra0 to eth0 then I don't think overlapping makes a difference here. This is the way I would get started based on info provided and assuming eth0 is the outside nic and ra0 would be and inside nic.

eth0
IP 192.168.0.1
Subnet 255.255.0.0
Gateway 192.168.0.160
DNS IP ***.***.***.***

ra0
IP 192.168.10.1
Subnet 255.255.255.0
No Gateway defined for ra0

Then goto http://easyfwgen.morizot.net/gen/ to build the iptables rules and ip masquerading. Only concern is the use of going from a class C on ra0 to a class B on eth0. Never done that before so cannot say if that is and issue. If worst case make ra0 172.16.0.1

edit:
Check out this link. http://www.faqs.org/docs/linux_netwo...addresses.html It talks about the limits for IP classes 192.168.0.160 cannot be a class B network. Only 128.0.0.0 through 191.255.0.0 for class B and the non routable for is 172.16.0.0 through 172.31.0.0. Same for Class C 192.0.0.0 through 223.255.255.0 and the non routable ones 192.168.0.0 through 192.168.255.0. Use non routables ip if you do not have real IP's. New I was missing something.

So this is wrong for a class B
eth0
IP 192.168.0.1
Subnet 255.255.0.0
Gateway 192.168.0.160
DNS IP ***.***.***.***

Needs to be like
eth0
IP 172.16.0.1
Subnet 255.255.0.0
Gateway 172.16.0.160
DNS IP ***.***.***.***

If you not need more than 255 IP on the eth0 side then I would make it a class C and use something like this and ra0 the same as above.
eth0
IP 192.168.0.1
Subnet 255.255.255.0
Gateway 192.168.0.160
DNS IP ***.***.***.***
edit:

Can goto the following to learn more on iptables and firewalls.
http://www.linuxguruz.com/iptables/v http://iptables-tutorial.frozentux.n...-tutorial.html
http://www.netfilter.org/

Brian1

Last edited by Brian1; 03-06-2006 at 03:55 PM.
 
Old 03-06-2006, 05:24 PM   #13
m4rk0
LQ Newbie
 
Registered: Jul 2005
Distribution: Debian, CentOS
Posts: 12

Original Poster
Rep: Reputation: 0
Hello Brian1.
Thank You on lots of informations.

But my gateway must be 192.168.0.160 /16 (defined by isp).

So what should I do now? iptables generator didn't helped me.

Thank You in advance.
 
Old 03-06-2006, 08:20 PM   #14
stefan_nicolau
Member
 
Registered: Jun 2005
Location: Canada
Distribution: Debian Etch/Sid, Ubuntu
Posts: 529

Rep: Reputation: 32
a) I think that the overlaping networks are a problem: On which network should a packet for 192.168.10.5 go? Because of the order in which they are in the routing table, this will probably work as expected, but it's still a very bad idea.
b)
Quote:
It talks about the limits for IP classes 192.168.0.160 cannot be a class B network.
Says who? It's just a convention/standard, not a technical limitation (and obvoiusly, m4rk0's ISP hasn't heard about it) Also, the whole concept of classes was kind of dropped when netmasks came in. Classes are now more or less a historical concept. It's certainly not the source of the problems here.
 
Old 03-06-2006, 08:51 PM   #15
christopherccv
Member
 
Registered: Jul 2003
Location: malaysia
Distribution: redhat
Posts: 31

Rep: Reputation: 15
change your another network to different class of ip address like 172.16.1.0/16 or others.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Having problems routing between two interfaces... stakhous Linux - Networking 8 12-05-2004 06:10 PM
Routing between interfaces? cryptical Linux - Networking 13 08-18-2004 07:29 AM
Routing Between Virtual Interfaces on Web Server Louie55 Linux - Networking 2 02-20-2004 09:17 AM
Problem with routing between interfaces Kostko Linux - Networking 6 12-01-2003 01:47 PM
Setting of Interfaces and Routing Table swmok Linux - Networking 1 07-31-2003 06:44 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 01:23 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration