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.

Just a quick question ( I Hope ) To find out if what I'm trying is even possible. I am trying to share internet connection with Fedora12 as default gateway and XP machine hooked up via NIC using iptables commands as shown in Mark Sobell's book 'A Practical Guide To Fedora And Red Hat Enterprise Linux' These are the commands as placed in /etc/rc.local

iptables -A FORWARD -i eth1 -o eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT

iptables -A FORWARD -i eth0 -o eth1 -j ACCEPT

iptables -A FORWARD -j LOG

iptables -t NAT  -A POSTROUTING  -o eth1  -j MASQUERADE

I did flip the in and out parameters to match my NIC configuration ( as opposed to example from book ) but other than that followed example. One thing to note is that Sobell did not mention whether this should work with mix of Linux and XP. One other note ( maybe meaningless ) is that I do have samba working between the two machines. Thanks for any insights anyone might have. PL

share|improve this question

migrated from stackoverflow.com Feb 1 '11 at 6:51

This question came from our site for professional and enthusiast programmers.

1  
Might want to post this on: superuser.com or unix.stackexchange.com –  Tim Cooper Feb 1 '11 at 3:18
add comment

2 Answers

It will work.

First. Make sure your ip_forwarding is enabled. By default it is disabled on most Linux systems. Run this: Using sysctl

sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 0

or using value in /proc


cat /proc/sys/net/ipv4/ip_forward
0

Enable ip_forward permanently

Add net.ipv4.ip_forward = 1 line in /etc/sysctl.conf 

cat "net.ipv4.ip_forward > /etc/sysctl.conf
sysctl -p /etc/sysctl.conf
service network restart

You have to make sure you identify your outgoing and incoming network interfaces.

This might be helpful: http://www.howtoforge.com/nat_iptables

share|improve this answer
    
Tim, Thanks for your response. I previously set ip_forward=1, then added commands to /etc/rc.local and restarted server. XP browser justs gives standard "cannot display webpage"error. I did try entering iptable commands in bash in /sbin as root and got following error FATAL: Module ip_tables not found. iptables v1.4.5: can't initialize iptables table `NAT': Table does not exist (do you need to insmod?) Perhaps iptables or your kernel needs to be upgraded. So anyway I will follow up on that error message and try a few things. PL –  Paul L Feb 1 '11 at 3:44
    
Check if you have iptables installed by running this command: rpm -qa | grep iptables –  PSS Feb 1 '11 at 4:12
add comment

In addition to @PSS's answer, you want to do the following, since you are using a Fedora based system

  1. After everything works, you want to use the command service iptables save to make your iptables settings persistent
  2. modify the file /etc/sysctl.conf and set the net.ipv4.ip_forward = 1 in there, again for the same reason.

If you are using the default kernel (or one provided by updates) make sure that the relevant kernel modules are loaded by modprobe iptable_nat and ipt_MASQUERADE - the /etc/init.d/iptables script that starts the iptables 'service' should also load the modules, so you can try service iptables start as well.

share|improve this answer
add comment

Your Answer

 
discard

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