Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13
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 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just 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

  2. #2
    Linux Enthusiast KenJackson's Avatar
    Join Date
    Jun 2006
    Location
    Maryland, USA
    Posts
    510
    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.

  3. #3
    Just 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.

  4. #4
    Linux Enthusiast KenJackson's Avatar
    Join Date
    Jun 2006
    Location
    Maryland, USA
    Posts
    510
    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

  5. #5
    Just 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.

  6. #6
    Linux Enthusiast KenJackson's Avatar
    Join Date
    Jun 2006
    Location
    Maryland, USA
    Posts
    510
    Type the command "/sbin/sysctl net.ipv4.ip_forward" and confirm that you get this answer:
    Code:
    net.ipv4.ip_forward = 1
    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".

  7. #7
    Just 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<<"

  8. #8
    Just Joined!
    Join Date
    Jun 2006
    Location
    Maryland
    Posts
    8
    Verify that forwarding is enabled:

    Code:
    # echo "1" > /proc/sys/net/ipv4/ip_forward
    on your notebook, ensure that iptables is not interfering by typing the following:

    Code:
    # iptables -F
    # iptables -P INPUT ACCEPT
    # iptables -P OUTPUT ACCEPT 
    # iptables -P FORWARD ACCEPT
    from your notebook, ping your default gateway and your 2nd computer.

    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.

  9. #9
    Just 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).

  10. #10
    Just 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.

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •