LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 02-20-2011, 10:40 AM   #1
fukda
LQ Newbie
 
Registered: Feb 2011
Location: Munich
Distribution: Debian Lenny
Posts: 8

Rep: Reputation: 0
Linux OS as router


HI,
I have two network cards in my computer (Debian). One (eth0) is connected to the router which is connected to the internet, the other one (eth1) is connected to my laptop (Gentoo). Now I want to surf the web both on my computer and on my laptop. I obeyed some tutorials "Linux as router":
1. On my Debian system IP-Forwarding is on:
Code:
takada:/home/sam# sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 1
2. Laptop has IP 192.168.0.2 and this is the output of 'cat /etc/network/interfaces' on my computer:
Code:
takada:/etc/network# cat interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# eth0
auto eth0
iface eth0 inet static
	address	192.168.1.97
	netmask 255.255.255.0
	network	192.168.1.0
	broadcast 192.168.1.255
	gateway 192.168.1.1

# eth1
auto eth1
iface eth1 inet static
	address 192.168.0.1
	netmask 255.255.255.0
	network 192.168.0.0
	broadcast 192.168.0.255
But a ping from my laptop to 192.168.1.1 (router to internet) still gives:
Code:
connect: Network is unreachable
What am I doing wrong?
Thanks for any help
 
Old 02-20-2011, 10:53 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
Ok, two obvious things missing, at least in your info provided

1) is the laptop configured with a default route of the debian box?

2) you need to further a) also use iptables masquerade to source nat the traffic from your laptop to come from it's eth0 addres OR b) ensure that the actual internet router knows how to get back to the laptop address, I.e. write via the debian box.
 
Old 02-20-2011, 11:32 AM   #3
fukda
LQ Newbie
 
Registered: Feb 2011
Location: Munich
Distribution: Debian Lenny
Posts: 8

Original Poster
Rep: Reputation: 0
Yes, laptop is configured with with a default route to 192.168.0.1 (actually it wasn't when I posted the output of "ping 192.168.1.1" from laptop, but I tried that earlier already; with that default gateway the output changes to 100% packet loss instead of "Network is unreachable").
To 2) I'd rather take option b). So I looked up the configuration page of my router. There's a category 'Static routes' which asks for the IP-Destination, IP-Subnetmask, IP-Gateway and metrics. I tried with "192.168.0.2", "255.255.255.0", "192.168.1.97" and "2", but it has no effect. Is there someone with an idea what to do??

Last edited by fukda; 02-20-2011 at 11:50 AM.
 
Old 02-20-2011, 12:11 PM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
ok, well the "IP-Destination" would be "192.168.0.0" but other than that it looks ok. You should now be at the level of iptables firewalling on the debian box. are you permitting traffic in the "FORWARD" table?
 
Old 02-20-2011, 12:57 PM   #5
fukda
LQ Newbie
 
Registered: Feb 2011
Location: Munich
Distribution: Debian Lenny
Posts: 8

Original Poster
Rep: Reputation: 0
yes, I am:
Code:
takada:/home/sam# iptables --list
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
I also changed the IP-Destination to 192.168.0.0. No effect.

Last edited by fukda; 02-20-2011 at 12:59 PM.
 
  


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
Adding new Linux firewall/router on network with pre-existing gateway/router grittyminder Linux - Networking 4 08-13-2008 02:17 AM
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

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

All times are GMT -5. The time now is 10:42 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