One of the most frequently questions I see on mailing lists, chat channels and newsgroups is "How do I set up Internet Connection sharing with Linux?" Well read on.
I will presume you already have an internet connection with a modem. Things that are needed:
All of the configuration will be on the command line, so open up a terminal and become root by typing su -
edit /etc/sysconfig/networking/devices/ifcfg-eth0 and make it look like this:
DEVICE=eth0 ONBOOT=yes BOOTPROTO=none NETMASK=255.255.255.0 USERCTL=yes PEERDNS=no GATEWAY=ppp0 TYPE=Ethernet IPADDR=192.168.100.1Then restart networking:
service network restart
Check that iptables is installed by typing as root:
rpm -q iptablesIf not
apt-get install iptables
Then:
lsmod | grep iptable_natIf this comes up blank, you need to load the right module:
modprobe iptable_natNow (if you have not issued "su -" and only "su", you will need to add /sbin/ to most of these commands, i.e. /sbin/iptables and /sbin/service):
iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADESave this by:
service iptables saveEnable ip forwarding by typing:
echo "1" > /proc/sys/net/ipv4/ip_forwardEdit /etc/sysctl.conf changing net.ipv4.ip_forward = 0 to 1 to keep this enabled at reboot. You make the system reread /etc/sysctl.conf by typing:
sysctl -pto check you haven't made a typo.
You can also setup a DHCP server to allow your clients whether it be Windows® or Linux clients to be given a IP address with the Gateway details included. Download DHCP by:
apt-get install dhcpand then as root, make /etc/dhcpd.conf look like:
ddns-update-style interim; default-lease-time 600; max-lease-time 7200; subnet 192.168.100.0 netmask 255.255.255.0 { option routers 192.168.100.1; option subnet-mask 255.255.255.0; option domain-name-servers ns1.example.com, ns2.example.com; range 192.168.100.2 192.168.100.20; }And:
service dhcpd startNow if DHCP is enabled on all your clients, then that is all you need to do. Use the setup command as root to checkout your network settings on your Fedora clients.
Well, that's it for now. For any comments or corrections, please e-mail me.