LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   iptables router (https://www.linuxquestions.org/questions/linux-networking-3/iptables-router-14428/)

bbenz3 02-17-2002 10:28 AM

iptables router
 
I am currently learning linux slowly but surely. I am trying to get a router setup so that I can have more than two computers online.
This is my setup:
eth0 --> int lan
eth1 --> ext lan
eth2 --> ext lan
192.168.168.10 --> my int ip
I have this so that I can forward two differentent comps to diff ext ips for gaming purposes. The ftp server is running on 192.168.168.10 on port 2020. I also have a DHCP server running on the int NIC to provide IPs.

I have successfully gotten it to route everything through either ext NIC. However I can't seem to get it to send my int ip through the other NIC.

I used the following to setup the routes that work.
iptables -A FORWARD -i eth0 -o eth1 -j ACCEPT
that works fine. I tried doing:
iptables -I FORWARD -s 192.186.168.10 -o eth2 -j ACCEPT
but that had no affect on my routing.

LionKing 02-19-2002 12:34 AM

Your linux box is probably configured that at any given time, there is only one default gateway to external network.
i.e. your linux box can get through only one ISP at any given time.

Try to set your linux box with two gateways each with different metric, and perhaps you want it run some routing protocol as well, so the if any changes with your external network(say one ISP down), it will automatically re-calculate routing metric, and re-route packets out.

regds.

bbenz3 02-25-2002 01:18 PM

I have 2 default gateways.
eth1
eth2

I don't exactly have the money to have two ips's. I am pulling two IP's from the same Road Runner and I am trying to pass some int IPs through oen ext NIC card and the rest through the other.
any clues?

LionKing 02-25-2002 02:21 PM

You can't have TWO default gateways. i.e. Default gateway cannot be more than one. However, if you have some routing protocol running, then you can have dymanic routing tables(discovered by routing protocols) and it will assigned with prioity number (metric) to routing paths it finds. The discovered routing path are not gateways.

Default gateway is a gateway when there aren't any routing tables matching the destination, its also called 'gateway of last resort'.

regds.

bbenz3 02-27-2002 11:28 PM

when I type in route this is what I get.
Destination Gateway Genmask Flags Iface
192.168.168.0 * 255.255.255.0 U eth0
xx.xx.xx.0 * 255.255.254.0 U eth1
yy.yy.yy.0 * 255.255.252.0 U eth2
127.0.0.0 * 255.0.0.0 U lo
default yy.yy.yy.1.name 0.0.0.0 UG eth2
default xx.xx.xx.1.name 0.0.0.0 UG eth1


I think i understand why everything is going to eth2 now but I duno how to stop it and to change it.

LionKing 02-28-2002 01:05 PM

use the route command to manuplate your routing table and default gateway, example

route del default gw xx.xx.xx.1
route add default gw xx.xx.xx.1

man route
info route

good luck.

bbenz3 02-28-2002 01:14 PM

I have looked at that and done that but I don't understand exactly what I should be doing. I need to have two gateways. One should be default I assume and the other is the special one, which I want to route the "special" int IPs through.
plz help

bbenz3 02-28-2002 08:53 PM

I found the answer to the problem.

Here is how to do it.

iptables -t nat POSTROUTING -p all -d 0/0 -s "one int IP" -j SNAT --to-source "IP of one ext NIC"


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