LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Linux OS as router (https://www.linuxquestions.org/questions/linux-networking-3/linux-os-as-router-863879/)

fukda 02-20-2011 10:40 AM

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

acid_kewpie 02-20-2011 10:53 AM

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.

fukda 02-20-2011 11:32 AM

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

acid_kewpie 02-20-2011 12:11 PM

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?

fukda 02-20-2011 12:57 PM

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.


All times are GMT -5. The time now is 11:40 AM.