Results 1 to 10 of 13
Thread: Simple IP Forwarding
|
|
Enjoy an ad free experience by logging in. Not a member yet? Register.
|
|
-
06-25-2006 #1Just Joined!
- Join Date
- Jun 2006
- Posts
- 6
Simple IP Forwarding
Hi,
although this seems to be the most simple IP-forwarding-scenario possible, I habe not found any How-Tos. Let me add I'm a newby to Linux and Networkung.
I have access to the internet on my notebook (debian, internal ip 192.168.1.101) via wlan (interface wlan0).
My 2nd computer (ubuntu, ip 192.168.1.100) is connected to my notebook via a switch (interfaces eth0 on both machines). Pinging works fine with this connection.
I want to be able to access the internet from my 2nd computer via my notebook;
how can i do that?
Thank you very much,
Lucebike
-
06-27-2006 #2
If you want your notebook to route packets from one interface to another, you need to do two things: enable forwarding and setup you routing tables properly on both machines.
To enable forwarding, edit the appropriate line in /etc/sysctl.conf like this:
net.ipv4.ip_forward = 1
You can enable it immediately for testing like this:
echo "1" > /proc/sys/net/ipv4/ip_forward
If you can't get your routing tables right, do "netstat -nr" on both machines and post the results here.
-
06-27-2006 #3Just Joined!
- Join Date
- Jun 2006
- Posts
- 6
Ok, I typed
echo "1" > /proc/sys/net/ipv4/ip_forward
and set up my routing tables like this:
on the notebook (which has internet connection)
Destination Gateway Genmask Flags MSS Window irtt Iface
192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 wlan0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
0.0.0.0 192.168.2.1 0.0.0.0 UG 0 0 0 wlan0
on the 2nd computer (which has not)
Destination Gateway Genmask Flags MSS Window irtt Iface
192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
default 192.168.1.101 0.0.0.0 UG 0 0 0 eth0
Now if I try to ping my notebook's internet-IP-address from the 2nd computer as a test, the packages are received by eth0 my notebook, forwarded via wlan0, but not received by wlan0.
So it seems that something is forwarded, but not properly.
-
06-27-2006 #4
The default route on your second PC should have your notebook as a gateway. I think you have the wrong address. If the notebook is 192.168.1.100, then try this on the second PC:
Code:route del default route add default gw 192.168.1.100
-
06-27-2006 #5Just Joined!
- Join Date
- Jun 2006
- Posts
- 6
Sorry, in my first post I switched the two IPs (edited correctly now).
Notebook has .101 and 2nd computer has .100
The problem remains.
-
06-28-2006 #6
Type the command "/sbin/sysctl net.ipv4.ip_forward" and confirm that you get this answer:
If that is correct, and ifconfig shows the interfaces are up, the only other thing I can think of is any firewall you may have established. Try flushing all the rules with "iptables -F" or better yet, "service iptables stop".Code:net.ipv4.ip_forward = 1
-
06-29-2006 #7Just Joined!
- Join Date
- Jun 2006
- Posts
- 6
I tried all that and it doesn't work.
When installing ubuntu on my 2nd computer I chose to "configure network later". Maybe there is still some basic configuration needed?
When I try
sudo apt-get update
the result is
Fehl http://security.ubuntu.com dapper-security Release.gpg
Temporärer Fehlschlag beim Auflösen von >>security.ubuntu.com<<
which means (roughly) "temporary failure trying to solve >>security.ubuntu.com<<"
-
06-30-2006 #8Just Joined!
- Join Date
- Jun 2006
- Location
- Maryland
- Posts
- 8
Verify that forwarding is enabled:
on your notebook, ensure that iptables is not interfering by typing the following:Code:# echo "1" > /proc/sys/net/ipv4/ip_forward
from your notebook, ping your default gateway and your 2nd computer.Code:# iptables -F # iptables -P INPUT ACCEPT # iptables -P OUTPUT ACCEPT # iptables -P FORWARD ACCEPT
from your 2nd computer, ping your notebook.
from your 2nd computer, ping your notebook's default gateway.
If all of those pings respond, forwarding is working. If "apt-get update" still fails, its probably a DNS issue. /etc/resolv.conf on your 2nd computer should look the same as it does on the notebook.
hth.
-
07-08-2006 #9Just Joined!
- Join Date
- Jun 2006
- Posts
- 6
Thanks for the help, tdeloggio.
All the pings work but one: I cannot ping my notebook's default gateway from my 2nd computer, i.e. ping 192.168.2.1 from the 2nd computer doesn't work.
And I do not have a /etc/resolv.conf on my 2nd computer (Ubuntu).
-
07-08-2006 #10Just Joined!
- Join Date
- Jul 2006
- Posts
- 8
If you don't have an /etc/resolv.conf file on the second pc, then create one with an editior like vi. In the file, put in the ip adresses of your ISP's nameservers like this:
nameserver (ip adress from them)
After you save the file, see if you can ping the nameserver ip you just entered.


