Sharing the Internet __linux under Linux

Source: Internet
Author: User
Tags iptables
Sharing the Internet under Linux

Reprint, please indicate the source and author contact information
Author Contact: Li Xianjing <xianjimli at hotmail Dot com>

My desktop has two network adapters, one connecting the moden of Tianwei, one connecting the notebook computer. There is no problem sharing data between laptops and desktops, but laptops sometimes have to access the extranet. Previously installed on the desktop computer windows, to share the Internet is very simple, the network connection set to share on the line. Now installed Fedora 7, according to the conventional view, to achieve a more simple sharing of the Internet, as long as the TCP forwarding (forward) switch can be turned on.

In the configuration file/etc/sysctl.conf increased Net.ipv4.ip_forward = 1, after the restart, the content of the/proc/sys/net/ipv4/ip_forward to 1, but still can not achieve shared Internet. Later in http://www.aboutdebian.com/proxy.htm find a script, run it on it, very easy to use, excerpts from here to do the memo.

#!/bin/sh
intif= "Eth0"
extif= "Eth1"
Extip= "'/sbin/ifconfig eth1 | grep ' inet addr ' | awk ' {print $} ' | Sed-e ' s/.*://' "

/sbin/depmod-a
/sbin/modprobe Ip_tables
/sbin/modprobe Ip_conntrack
/sbin/modprobe ip_conntrack_ftp
/sbin/modprobe Ip_conntrack_irc
/sbin/modprobe Iptable_nat
/sbin/modprobe ip_nat_ftp

echo "1" >/proc/sys/net/ipv4/ip_forward
echo "1" >/proc/sys/net/ipv4/ip_dynaddr
Iptables-p INPUT ACCEPT
Iptables-f INPUT
Iptables-p OUTPUT ACCEPT
Iptables-f OUTPUT
Iptables-p FORWARD DROP
Iptables-f FORWARD
Iptables-t nat-f
Iptables-a forward-i $EXTIF-o $INTIF-M state--state Established,related-j ACCEPT
Iptables-a forward-i $INTIF-o $EXTIF-j ACCEPT
Iptables-t nat-a postrouting-o $EXTIF-j Masquerade

~~end~~
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.