Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I just installed Ubuntu 10.04 LTS server on a old desktop PC with a dual port network card I would like to use as router for my home network. How do I have to set up the interfaces so that the internet connection is passed through the server?

share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted

The first step when configuring Linux as a router is to enable IP forwarding:

$ echo "1" > /proc/sys/net/ipv4/ip_forward

Now the OS can route packets between interfaces.

Next use iptables and netfilter to create traffic rules.

I would suggest that you use a front-end to iptables and Netfilter in order to configure your router and manage the interface rules and policies.

If you prefer a GUI then see some of the other helpful answers on this page.

If you would like to hack at the command line and experience the true power of the Force, then try the excellent Shorewall front-end to iptables and netfilter which will allow you to easily configure your router straight away. Yet, as you learn more about routing Shorewall will allow increasingly fine-grained configurations and packet level network flow control.

The shorewall package is available in the Ubuntu repositories (choose either the shell or Perl package). The Shorewall site has great documentation and helpful tutorials for a multitude of scenarios. The basic 2- or 3- interface examples should get you going.

share|improve this answer
    
I'm trying to set up shorewall as well. If I follow this approach, do I need to set up all NIC's in /etc/network/interfaces first? The shorewall docs simply don't mention it at all. Some other tutorials do show it. I spent a couple hours yesterday trying to get 12.04 happy with this file and gave up after playing the rebooting guessing game basically ruled out everything I tried. (I tried some router distros but I need something complex.) –  Paul Jul 26 '13 at 15:00
    
@Paul Ubuntu's Network Manager is probably trying to control those NICs and overwriting the /etc/network/interfaces and /etc/resolv.conf files. Yes, you will have to configure the NICs at OS level prior to configuring shorewall. I suggest you install ubuntu-server distro or uninstall network-manager –  venzen Jul 28 '13 at 11:19
    
this should help (with or without NM): <askubuntu.com/questions/196640/…; –  venzen Jul 28 '13 at 11:24
    
Thanks! I got it working. –  Paul Jul 31 '13 at 21:12
    
@Paul mind sharing what the issue turned out to be and how you solved it (briefly) ? –  venzen Aug 3 '13 at 9:16
show 1 more comment

The easiest way would be to use iptables. Have a read on iptables over on the Ubuntu community site. You could also use something like firestarter for a nicer GUI experience.

Personally, I would recommend using a dedicated gateway distro such as ipcop, m0n0wall or an all-in-one system like ClearOS or Untangle. It would simplify the management of the firewall as well as offer you quite a few other features (also, with simplicity built in).

share|improve this answer
    
Thanks for the answer! The only problem I have at the moment is that the other network interfaces (three in total, two on the two port network card and one integrated into the mainboard) are not listed under /etc/network/interfaces. How can I get them to be listed? They were correctly shown during setup of Ubuntu. –  wowpatrick Dec 30 '11 at 0:40
    
@wowpatrick I think it would work to your advantage to make a whole new question since that's completely different than the question posted above. Try the Ubuntu Stack Exchange site: askubuntu.com –  Wesley Dec 30 '11 at 3:18
    
Thanks! Will do that! –  wowpatrick Dec 30 '11 at 15:40
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.