LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 06-06-2006, 04:21 PM   #1
techk
LQ Newbie
 
Registered: Apr 2006
Posts: 6

Rep: Reputation: 0
Question Linux router help


Hey ppl,
I am trying to make a linux router with NAT from Fedora core 5 system.
My dilemma is what gateway should I assign to the NIC card facing the internal machines.

I have router machine name A with two NIC cards eth0 and eth1 .
eth0 is connected to Internet using DHCP.
eth1 is connected to a windows machine and I am setting its IP address statically.
I can chose 192.x.x.x. kind of addresses. But what kind of gateway adderess I should provide ??/
eth1 shloud have gateway as IP of eth0 ..right ?? Just want to make sure..
If u guys may have done similar kind of work please list problem areas where i need to be carefull.
Regards,
techk
 
Old 06-06-2006, 05:10 PM   #2
Linux.tar.gz
Senior Member
 
Registered: Dec 2003
Location: Paris
Distribution: Slackware forever.
Posts: 2,534

Rep: Reputation: 100Reputation: 100
If eth1 of the NAT router is 192.168.0.1, then on other machines, you have to specify this IP as the gateway.
 
Old 06-06-2006, 05:15 PM   #3
techk
LQ Newbie
 
Registered: Apr 2006
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Linux.tar.gz
If eth1 of the NAT router is 192.168.0.1, then on other machines, you have to specify this IP as the gateway.
Hi Linux.tar.gz
What will be the gateway for eth1 . will it be eth0 ??
 
Old 06-06-2006, 05:20 PM   #4
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
This is the way I do it.
eth0 ( outside wan ) setup as dhcp or static depending on providers requiremnets.
If static define IP, gateway, Subnet, and DNS IP.

For eth1
IP lets say 192.168.0.1
Subnet 255.255.255.0
Gateway Do not define a gateway for the eth1. Masquerading takes care of this for you.

Enable ip masquerading and off.

Easiest way to build one is goto this site and answer the questions it ask to generate one. http://easyfwgen.morizot.net/gen/


Brian1
 
Old 06-06-2006, 09:23 PM   #5
Linux.tar.gz
Senior Member
 
Registered: Dec 2003
Location: Paris
Distribution: Slackware forever.
Posts: 2,534

Rep: Reputation: 100Reputation: 100
Brian1 is right, you don't need to assign a gateway to you NAT box.
But if you have a static IP from your ISP, you don't need masquerade.

You will need this:
iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to 92.125.235.122
(assuming, of course, that 92.125.235.122 is your public eth0 IP)

And maybe this too:
echo 1 > /proc/sys/net/ipv4/ip_forward

Don't forget to give the dns values to your other boxes.
Check /etc/resolv.conf for this.
 
Old 06-14-2006, 03:24 PM   #6
techk
LQ Newbie
 
Registered: Apr 2006
Posts: 6

Original Poster
Rep: Reputation: 0
thanks still working on it

Hey Brian1 and Linux.tar.gz,
thanks for getting my doubts clear . I am still working on setting up the whole thing.
I will let u guys know in case I need some sort of help and clarifications.
In between anybody used gateway to make failover for bunch of servers.It may look like gateway( eth0 ,eth1 and eth2) conencts to internet on eth0 and eth1 and eth2 are connect to secure part of network. As soon as server conencted to eth1 dies gateway sdirect all traffic to eth2 .
Do i need to change firewall rules at the runtime through a script.
Regards,
techk
 
Old 06-14-2006, 04:15 PM   #7
charon79m
Member
 
Registered: Oct 2003
Distribution: Just about anything... so long as it is Debain based.
Posts: 297

Rep: Reputation: 30
Perhaps the issue is that you're thinking of a routing table as a per interface thing. It's not. Routing tables are per box. You only need to have an entry for that machine saying to route all (0.0.0.0 netmaks 0.0.0.0) through the IP your ISP gives you. DHCP will place that entry in the routing table for you, so the point is moot.

As long as your machines in your internal network have their gateway set to the LAN address of your router box, you're golden.

It should also be noted that RFC1918 states 192.168.x.x is available for private, not 192.x.x.x. You also have 10.x.x.x and 172.16.x.x-172.31.x.x too!

Michael Knisely
 
Old 06-14-2006, 04:38 PM   #8
techk
LQ Newbie
 
Registered: Apr 2006
Posts: 6

Original Poster
Rep: Reputation: 0
i repharse my question

Quote:
Originally Posted by charon79m
Perhaps the issue is that you're thinking of a routing table as a per interface thing. It's not. Routing tables are per box. You only need to have an entry for that machine saying to route all (0.0.0.0 netmaks 0.0.0.0) through the IP your ISP gives you. DHCP will place that entry in the routing table for you, so the point is moot.

As long as your machines in your internal network have their gateway set to the LAN address of your router box, you're golden.

It should also be noted that RFC1918 states 192.168.x.x is available for private, not 192.x.x.x. You also have 10.x.x.x and 172.16.x.x-172.31.x.x too!

Michael Knisely
Hi Michael,
My question was can I use my gateway such that all forwarded traffic goes to machine connected to eth1 ( on gateway) and as soon as machine connected to eth1 ( on gateway) dies all the forwarded traffic goes to eth2 only.
Can u correct me how long this solution is valid. ( through a script)
firewall rule..
all forward traffic goes to eth1
test to see if machine on eth1 is alive
if not then change the rule to all forward traffic gose to eth2.

regards,
techk
 
  


Reply



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
Small Linux Router/firewall behind D-Link Hardware router dleidlein Linux - Networking 6 04-30-2007 05:12 AM
linux as router/gateway/firewall to dsl-router sjoerdvvu Linux - Networking 2 02-24-2006 10:56 PM
Linux Router & Netgear Wireless Router DMaCATO Linux - Wireless Networking 1 04-30-2004 09:16 AM
/etc/resolv.conf configuration when behind a router(not a linux router) rmanocha Linux - Networking 2 04-28-2004 01:52 AM
ADSL Router + Linux Router + LAN = HELP!!! linuxlois Linux - General 2 09-16-2003 08:24 AM

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

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

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