LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Routing between 2 interfaces? (https://www.linuxquestions.org/questions/linux-networking-3/routing-between-2-interfaces-421953/)

m4rk0 03-05-2006 05:03 PM

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!

stefan_nicolau 03-05-2006 06:46 PM

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?

fotoguy 03-05-2006 07:15 PM

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.

m4rk0 03-06-2006 09:51 AM

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...

m4rk0 03-06-2006 09:54 AM

@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 ;)

stefan_nicolau 03-06-2006 10:48 AM

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?

m4rk0 03-06-2006 11:08 AM

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...

stefan_nicolau 03-06-2006 11:25 AM

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.

m4rk0 03-06-2006 12:28 PM

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

stefan_nicolau 03-06-2006 12:42 PM

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!

m4rk0 03-06-2006 12:53 PM

Than can you show me example how you would configure my network?

Thank you on fast answers :)

Brian1 03-06-2006 03:52 PM

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

m4rk0 03-06-2006 05:24 PM

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.

stefan_nicolau 03-06-2006 08:20 PM

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.

christopherccv 03-06-2006 08:51 PM

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


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