Internet Sharing-EN

Da PoliArch.

Altre Pagine: · Home Page · Documentazione · Downloads · Screenshots · Contatti

Prerequisites

  • An internet connection (ethX/wlanX/pppX)
  • Two network interfaces (ethX/wlanX)
  • Ip forwarding enabled

Cleaning

Clean iptables rules

# iptables -F
# iptables -F INPUT
# iptables -F OUTPUT
# iptables -F FORWARD
# iptables -F -t mangle
# iptables -F -t nat
# iptables -X

Enable ip_forwarding

Enable ip_forwading for the current session

# echo 1 > /proc/sys/net/ipv4/ip_forward

NAT

Nat connection

# iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
Warning: In this sample eth1 is the WAN interface, can be different, depending on your configuration!

Script

A scripted version of the previous commands

File: internet_sharing.sh
# iptables binary
IPT="/sbin/iptables"

WAN="eth1" # Edit as need

# Clean iptables rules
$IPT -F
$IPT -F INPUT
$IPT -F OUTPUT
$IPT -F FORWARD
$IPT -F -t mangle
$IPT -F -t nat
$IPT -X

# Enable ip forwarding
echo 1 > /proc/sys/net/ipv4/ip_forward

# Nat connection
$IPT -t nat -A POSTROUTING -o $WAN -j MASQUERADE
  • Run with:
# chmod +x internet_sharing.sh
# ./internet_sharing.sh

Altre Pagine: · Home Page · Documentazione · Downloads · Screenshots · Contatti