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

    (Should Be) Basic Networking Problem

    Hi guys, im trying to setup a very basic network with both linux and windows machines. What i have is a server running debian linux with two nics and i want a cable from my modem (internet) to come in one and out of the other i want to be able to share my connection with a switch or hub to which other windows computers are connected. Heres a Diagram of what i want

    (Internet)_________LINUX SERVER____________SWITCH_________WIN PC

    WWW---------NIC1(ETH0)--NIC2(ETH1)---------SWITCH---------pc1 pc2 pc3

    Any help on how i would set this up is appreciated as right now none of my windows pcs can access the internet.

  2. #2
    Linux Enthusiast KenJackson's Avatar
    Join Date
    Jun 2006
    Maryland, USA
    You need to do three things on your Linux PC: 1) enable routing in the kernel, 2) setup iptables for network address translation or NAT, and 3) setup the routing table.

    To enable routing, edit /etc/sysctl.conf and add or uncomment this line:
    net.ipv4.ip_forward  = 1
    That will set it up the next time you start up, but to enable it immediately, run this:
    echo 1>/proc/sys/net/ip_forward
    You need to select a local address range for your PCs. The most popular local address range seems to be That is, the 254 IP addresses from to

    Your Linux PC has two NICs so it will have two IP addresses. The one connected to the modem get's a real IP address assigned by your ISP. You must assign the other one--the one that connects to your local network. Traditionally, the gateway/server/router is assigned the lowest IP address in the range.

    Setting up iptables will take some trial and error. It's best to read a little about setting up NAT. There is a lot of material available, including the documentation at netfilter.

    Hang in there. It takes a little effort to get everything setup like you want, but it's fun, and doing it gives you very valuable insight into a lot of networking issues.

Posting Permissions

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