How to make a router. Easy, fast and dirty.
If you:
- Have Linux (on the computer that will be normal_pc + router )
- Have only one network card
- Have only one Ip
- Want to share connexion with other computers on your Lan.
Instructions:
1-Connect your internet cable to a hub/switch.
2-Connect the computer that is going to act as a router to the switch. Connect
it to Internet with your IP. Execute the script.
3-Connect the other computers to the hub/switch
4-Enable dhcp on the router or put static addresses to the pcs.
addr range:192.168.1.1 ... 192.168.1.253
Bcast:192.168.1.255
Mask:255.255.255.0
gateway and dns: 192.168.1.254
Possible problems:
-Possible Solution=> Restart the hub/switch and start again.
Script (taken from somewhere and adapted to me)
==============
#!/bin/bash
ifconfig eth0:0 192.168.1.254
#iptables:
iptables --flush #- Flush all
the rules in filter and nat tables
iptables --table nat --flush
iptables --delete-chain # - Delete all
chains that are not in default filter and nat table
iptables --table nat --delete-chain
# Set up IP FORWARDing and Masquerading
iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
iptables --append FORWARD --in-interface eth0 -j ACCEPT # - Assuming
one NIC to local LAN
echo 1 > /proc/sys/net/ipv4/ip_forward # - Enables
packet forwarding by kernel
# Not neccesary but I let it there.
#ipchains:
#!/bin/sh
#ipchains -F forward # - Flush all previous
rules and settings
#ipchains -P forward DENY # - Default set to deny
packet forwarding
#ipchains -A forward -s 192.168.1.0/24 -j MASQ #- Use IP address of
gateway for private network
#ipchains -A forward -i eth0 -j MASQ # - Sets up external
internet connection
#echo 1 > /proc/sys/net/ipv4/ip_forward # - Enables packet
forwarding by kernel
0 Comments:
Post a Comment
<< Home