LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   gateway for a linux router?? (https://www.linuxquestions.org/questions/linux-networking-3/gateway-for-a-linux-router-116484/)

jmono 11-15-2003 06:47 PM

middle router
 
hi
ě`m trying to set up a linux router between two machines using Mandrake 9

the Linux machine (in the middle) has two network cards->
eth0-->
addr 10.1.0.1 mask 255.255.0.0
eth1-->
addr 10.2.0.1 mask 255.255.0.0

the first client is 10.1.0.2 with gateway 10.1.0.1 and the second one is 10.2.0.2 with gateway 10.2.0.1, both with the same mask 255.255.0.0

is this configuration ok??? i hope so... :confused:

anyway what i need is->
communicate the client 1 with the client 2 = router

i type this->
echo '1' > /proc/sys/net/ipv4/ip_forward
then
route add -net 10.1.0.0 netmask 255.255.0.0 gw 10.2.0.1 dev eth1
and
route add -net 10.2.0.0 netmask 255.255.0.0 gw 10.1.0.1 dev eth0
but nothing happen when i try to make ping to the client 2 from the client 1

do i miss something??

:cry:

/bin/bash 11-15-2003 08:04 PM

Could you post the contents of these files:

/etc/sysconfig/network
/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/sysconfig/network-scripts/ifcfg-eth1

Also what do you get when you type these two commands?
route
ifconfig

/bin/bash 11-15-2003 08:08 PM

You should be able to use mcc (Mandrake Control Center) to do most of this quite easily.
Click on Network & Internet -> DrakConnect will allow you to setup the NIC cards.
Click on Network & Internet -> DrakGw will allow you to setup a Gateway.

jmono 11-16-2003 12:34 PM

the contents.
network->
NETWORKING=yes
FORWARD_IPV4="yes"
HOSTNAME="server.a.a"
DOMAINNAME=a.a
GATEWAY="10.1.0.1"
GATEWAYDEV="eth0"

ifcfg-eth0->
DEVICE·="eth0"
BOOTPROTO="none"
IPADDR="10.1.0.1"
NETMASK="255.255.0.0"
NETWORK=10.1.0.0
BROADCAST=10.1.255.255
ONBOOT="yes"
IPXNETNUM_802_2=""
IPXPRIMARY_802_2="no"
IPXACTIVE_802_2="no"
IPXNETNUM_802_3=""
IPXPRIMARY_802_3="no"
IPXACTIVE_802_3="no"
IPXNETNUM_ETHERII=""
IPXPRIMARY_ETHERII="no"
IPXACTIVE_ETHERII="no"
IPXNETNUM_SNAP=""
IPXPRIMARY_SNAP="no"
IPXACTIVE_SNAP="no"

the ifcfg-eth1 the same as the eth0 but in the other sub-network -> 10.2.0.0

and when i type route i get->
Kernel IP routing
Destination Gateway Genmask Flags Interface
10.2.0.0 10.1.0.1 255.255.0.0 U eth0
10.1.0.0 10.2.0.1 255.255.0.0 U eth1

and ifconfig shows me eth0 and eth1 configuration and they are ok as in the above files.

about MCC, that is the last option i wanna use, i want to do it in the console mode ;)

thanks mate for your help!!!

jmono 11-17-2003 02:02 PM

i have some progress now... but i really need help now

i`m able to communicate the client 2 with the client 1 after this:
iptables -A FORWARD -i eth1 -j ACCEPT
iptables - t nat -A POSTROUTING -o eth0 -j MASQUERADE
but i also read that i do not need MASQUERADE if i am not using dynamic-IPs ??????

anyway it works, but the client 1 is not bale to communicate with the client 2

is the gateway the problem?????
when i read the file /etc/sysconfig/network it says GATEWAY=10.1.0.1 GATEWAYDEV= eth0

do i need anything like GATEWAY=10.2.0.1 GATEWAYDEV=eth1 to resolve my problem???
can i do that???

/bin/bash 11-17-2003 02:27 PM

Is this a Novell network?

Try changing BOOTPROTO="none" to BOOTPROTO="static" in the ifcfg-eth0/1 files. Then type this to restart the network, service network restart.

Also could you post the results of ifconfig.

jmono 11-17-2003 02:55 PM

i already did that but it still doesn`t work!!

my ifconfig result for eth0 and eth1->
eth0
Link encap: Ethernet HWaddr 00:00:E8:86:3E:2E
inet addr: 10.1.0.1 broadcat: 10.1.255.255 mask: 255.255.0.0
UP BROADCAST RUNNING MULTIMCAST MTU: 1500 Mmetric:1
RX packets: 357 errors: 0 dropped: 0 overruns: 0 frame: 0
TX packets: 618 errors: 0 dropped: 0 overruns: 0 carrier: 0
collisions: 0 txqueuelen: 100
RX bytes:120724 (117.8 Kb) TX bytes: 48492 (47.3 kb)
Interrupt:11 Base address 0xf800

eth1
Link encap: Ethernet HWaddr 00:00:E8:86:3E:2E
inet addr: 10.2.0.1 broadcat: 10.2.255.255 mask: 255.255.0.0
UP BROADCAST RUNNING MULTIMCAST MTU: 1500 Mmetric:1
RX packets: 365 errors: 0 dropped: 0 overruns: 0 frame: 0
TX packets: 809 errors: 0 dropped: 0 overruns: 0 carrier: 0
collisions: 0 txqueuelen: 100
RX bytes:33132 (32.3 Kb) TX bytes: 143620 (140.2 kb)
Interrupt:11 Base address 0x8c00

and lo but this is not necessary i think...

jmono 11-17-2003 03:17 PM

and no, it is not a novell network!!!
i don`t know why IPX there!!!

zaphodiv 11-17-2003 03:37 PM

>nothing happen when i try to make ping to the client 2 from the client 1
>do i miss something??

You need the routing table on client1 set so it sends packets addressed to 10.2.x.x to 10.1.0.1

You need the routing table on client2 set so it sends packets addresses to 10.1.x.x to 10.2.0.1

>then route add -net 10.1.0.0 netmask 255.255.0.0 gw 10.2.0.1 dev eth1
>and
>route add -net 10.2.0.0 netmask 255.255.0.0 gw 10.1.0.1 dev eth0

You are doing the above command on the server when you should be doing them on the clients.

Just setting the ip and netmask on you network cards should leave your routing table in a state that will send traffic in the right direction.

Typing those route commands on the router will probably break it by sending packets out the wrong network card.

If the client will allways need to send traffic to a destination outside their subnet via the router (and not, for example, access the internet via a different gateway) then you can set the default route of the clients in
the 10.1.x.x network to 10.1.0.1 and set the default route of the clients in
the 10.2.x.x network to 10.2.0.1

I guess you have the default route of client 1 set to the router because it worked when you set the linux box to do network address translation instead of forwarding packets unmolested.

>i`m able to communicate the client 2 with the client 1 after this:
>iptables -A FORWARD -i eth1 -j ACCEPT
>iptables - t nat -A POSTROUTING -o eth0 -j MASQUERADE

Doing it this way means that when client1 connects to client2, client2 sees an incoming connection from the router's ip address instead of from client1's ip address.

You are only NATing one way through the router.
You could try NATing the other way as well eg
iptables -A FORWARD -i eth0 -j ACCEPT
iptables - t nat -A POSTROUTING -o eth1 -j MASQUERADE

I don't know if a two way NAT will work, let us know if you try it.

jmono 11-17-2003 04:01 PM

it doesn`t work
i set up the other NAT way too
but the client 1 doesn`t ping the client 2 in the other subnetwork!!

i don`t know what else to do!!

jmono 11-17-2003 04:03 PM

the client 1 has the following configuration
IP address 10.1.0.2
netmask 255.255.0.0
gateway 10.1.0.1
running on Windows 2000 pro

and the client 2
IP address 10.2.0.2
netmask 255.255.0.0
running on W98
gateway 10.2.0.1

zaphodiv 11-17-2003 04:45 PM

If you set up the linux router as you said in the first post but don#'t mess with the routing on it tehn in theory that should work.

Preshaps it is time to start sniffing to see exactly where the packets get lost.

/bin/bash 11-17-2003 09:33 PM

eth0
Link encap: Ethernet HWaddr 00:00:E8:86:3E:2E
eth1
Link encap: Ethernet HWaddr 00:00:E8:86:3E:2E

What are the odds that you would have two ethernet cards with the same HWaddr? Is this a dual port NIC?


Now I noticed an error in /etc/sysconfig/network
GATEWAY="10.1.0.1"
Try removing that then
service network restart

If you still have problems would you post the routing table?
route


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