Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Because my wireless router's ethernet ports are defective, I set up a shared wireless connection from my laptop (which has wifi) to my eMac (which does not) via a crossover ethernet cable. The laptop is behind a router as, and the eMac is behind the laptop as .

The laptop is running Ubuntu 9.10 (Karmic). I achieved the shared connection through NetworkManager Applet. I right-clicked on the network icon at the topright, went to Edit Connections, selected the Wired connection named "Auto eth0", clicked "Edit...", went to the "IPv4 Settings" tab, and selected the Method "Shared to other computers". The eMac can now access the Internet.

Now I want to enable port forwarding. There's a game I want to play that needs port 6112 forwarded (both TCP and UDP) in order to host games. I set up the router to enable port forwarding for (the laptop), but port forwarding still isn't available on the eMac.

I suppose I need to pretend my laptop is a router and configure port forwarding on it, indicating that incoming connections to the laptop ( should be forwarded to the eMac on the shared connection ( ). Thus, packets coming into the router on port 6112 would be redirected to the laptop (by the router), then to the eMac (by the laptop).

My question is, how would I do that on Ubuntu (in light of NetworkManager's presence)? Also, if I can't get this to work, does anyone mind hosting a comp stomp? :D

share|improve this question

Don't know anything about Ubuntu config utils but here's the classic way:

echo 1 > /proc/sys/net/ipv4/ip_forward # enable forwarding
iptables -I FORWARD -p tcp -d --dport 6112 -j ACCEPT #just to be sure firewall doesn't block
iptables -t nat -A PREROUTING -p tcp -i eth0 --dport 6112 -j DNAT --to #actual forward
#same for UDP
iptables -I FORWARD -p udp -d --dport 6112 -j ACCEPT
iptables -t nat -A PREROUTING -p udp -i eth0 --dport 6112 -j DNAT --to 

You have to change -i eth0 to your wlan connection name. Generally

iptables -t nat -A PREROUTING [-p protocol] --dport [external port on router] -i ${WAN} -j DNAT --to [ip/port to forward to]

For more check Frozentux iptables guide.

share|improve this answer

Consider installing the Shorewall package to configure your routing. Your forwarding rules would be done using DNAT rules. I would suggesst starting with the example 2 interface configuration.

share|improve this answer

Your Answer


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.