What's your requirement can you tell me?
Normally, it is good plan to use NAT to share Internet.
Solution Given by Group Members
Login as the root user. Open /etc/sysctl.conf file
# vi /etc/sysctl.conf
Add the following line to enable packet forwarding for IPv4:
net.ipv4.conf.default.
forwarding=1
Save and close the file. Restart networking:
# service network restart
Step # 2: Enable IP masquerading
In Linux networking, Network Address Translation (NAT) or Network Masquerading (IP Masquerading) is a technique of transceiving network traffic through a router that involves re-writing the source and/or destination IP addresses and usually also the TCP/UDP port numbers of IP packets as they pass through. In short, IP masquerading is used to share the internet connection.
Share internet connection
To share network connection via eth1, enter the following rule at command prompt (following useful for ppp0 or dial up connection):
# service iptables stop
# iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
# service iptables save
# service iptables restart
Open your Windows / Mac / Linux computer networking GUI tool and point router IP to 192.168.1.254 (eth0 Linux IP). You also need to setup DNS IP such as 208.67.222.222 and 208.67.220.220. You should now able to ping or browse the internet:
c:> ping 202.54.1.20
c:> ping google.com
Shell Script to Setup Basic Linux Network Sharing
This is basic connection sharing, following shell script is for more advance user. [ Download the script here and modify SHARE_IF as per your requirements. ]
#!/bin/bash
# Created by joseph saj
IPT="/sbin/iptables"
MOD="/sbin/modprobe"
# set wan interface such as eth1 or ppp0
SHARE_IF="eth1"
# clean old fw
echo "Clearing old firewall rules..."
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
# Get some kernel modules
echo "Loading kernel modules..."
$MOD ip_tables
$MOD iptable_filter
$MOD iptable_nat
$MOD ip_conntrack
$MOD ipt_MASQUERADE
$MOD ip_nat_ftp
$MOD ip_nat_irc
$MOD ip_conntrack_ftp
$MOD ip_conntrack_irc
# Clean old rules if any, rhel specific but above will take care of everything
# service iptables stop
# unlimited traffic via loopback device
$IPT -A INPUT -i lo -j ACCEPT
$IPT -A OUTPUT -o lo -j ACCEPT
echo "Setting ${SHARE_IF} as router interface..."
$IPT --table nat --append POSTROUTING --out-interface ${SHARE_IF} -j MASQUERADE
# Start other custom rules
#$IPT
# End other custom rules
echo "*** Instructions on TCP/IP On The Windows / Mac / Linux Masqueraded Client ***"
echo "1. Login to your other LAN desktop computers"
echo "2. Open network configuration GUI tool such. Under Windows XP - Click Start, click Control Panel, click Network and Internet Connections, and then click Network Connections"
echo "3. Set DNS (NS1 and NS2) to 208.67.222.222 and 208.67.220.220"
echo "4. Select the 'Gateway' tab in the TCP/IP properties dialog."
echo "5. Enter $(ifconfig ${SHARE_IF} grep 'inet addr:' grep -v '127.0.0.1' cut -d: -f2 awk '{ print $1}') as the default gateway."
Normally, it is good plan to use NAT to share Internet.
Solution Given by Group Members
Login as the root user. Open /etc/sysctl.conf file
# vi /etc/sysctl.conf
Add the following line to enable packet forwarding for IPv4:
net.ipv4.conf.default.
Save and close the file. Restart networking:
# service network restart
Step # 2: Enable IP masquerading
In Linux networking, Network Address Translation (NAT) or Network Masquerading (IP Masquerading) is a technique of transceiving network traffic through a router that involves re-writing the source and/or destination IP addresses and usually also the TCP/UDP port numbers of IP packets as they pass through. In short, IP masquerading is used to share the internet connection.
Share internet connection
To share network connection via eth1, enter the following rule at command prompt (following useful for ppp0 or dial up connection):
# service iptables stop
# iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
# service iptables save
# service iptables restart
Open your Windows / Mac / Linux computer networking GUI tool and point router IP to 192.168.1.254 (eth0 Linux IP). You also need to setup DNS IP such as 208.67.222.222 and 208.67.220.220. You should now able to ping or browse the internet:
c:> ping 202.54.1.20
c:> ping google.com
Shell Script to Setup Basic Linux Network Sharing
This is basic connection sharing, following shell script is for more advance user. [ Download the script here and modify SHARE_IF as per your requirements. ]
#!/bin/bash
# Created by joseph saj
IPT="/sbin/iptables"
MOD="/sbin/modprobe"
# set wan interface such as eth1 or ppp0
SHARE_IF="eth1"
# clean old fw
echo "Clearing old firewall rules..."
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
# Get some kernel modules
echo "Loading kernel modules..."
$MOD ip_tables
$MOD iptable_filter
$MOD iptable_nat
$MOD ip_conntrack
$MOD ipt_MASQUERADE
$MOD ip_nat_ftp
$MOD ip_nat_irc
$MOD ip_conntrack_ftp
$MOD ip_conntrack_irc
# Clean old rules if any, rhel specific but above will take care of everything
# service iptables stop
# unlimited traffic via loopback device
$IPT -A INPUT -i lo -j ACCEPT
$IPT -A OUTPUT -o lo -j ACCEPT
echo "Setting ${SHARE_IF} as router interface..."
$IPT --table nat --append POSTROUTING --out-interface ${SHARE_IF} -j MASQUERADE
# Start other custom rules
#$IPT
# End other custom rules
echo "*** Instructions on TCP/IP On The Windows / Mac / Linux Masqueraded Client ***"
echo "1. Login to your other LAN desktop computers"
echo "2. Open network configuration GUI tool such. Under Windows XP - Click Start, click Control Panel, click Network and Internet Connections, and then click Network Connections"
echo "3. Set DNS (NS1 and NS2) to 208.67.222.222 and 208.67.220.220"
echo "4. Select the 'Gateway' tab in the TCP/IP properties dialog."
echo "5. Enter $(ifconfig ${SHARE_IF} grep 'inet addr:' grep -v '127.0.0.1' cut -d: -f2 awk '{ print $1}') as the default gateway."
No comments:
Post a Comment