Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Simple IP Forwarding


    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 via wlan (interface wlan0).
    My 2nd computer (ubuntu, ip 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,

  2. #2
    Linux Enthusiast KenJackson's Avatar
    Join Date
    Jun 2006
    Maryland, USA
    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
    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 U 0 0 0 wlan0 U 0 0 0 eth0 UG 0 0 0 wlan0

    on the 2nd computer (which has not)
    Destination Gateway Genmask Flags MSS Window irtt Iface * U 0 0 0 eth0
    default 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. $spacer_open
  5. #4
    Linux Enthusiast KenJackson's Avatar
    Join Date
    Jun 2006
    Maryland, USA
    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, then try this on the second PC:
    route del default
    route add default gw

  6. #5
    Sorry, in my first post I switched the two IPs (edited correctly now).
    Notebook has .101 and 2nd computer has .100

    The problem remains.

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

  8. #7
    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 dapper-security Release.gpg
    Temporärer Fehlschlag beim Auflösen von >><<

    which means (roughly) "temporary failure trying to solve >><<"

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

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

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


  10. #9
    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 from the 2nd computer doesn't work.

    And I do not have a /etc/resolv.conf on my 2nd computer (Ubuntu).

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

Posting Permissions

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