Search Members Help

» Welcome Guest
[ Log In :: Register ]

Mini-ITX Boards Sale, Fanless BareBones Mini-ITX, Bootable 1G DSL USBs, 533MHz Fanless PC <-- SALE $200 each!
Get The Official Damn Small Linux Book. DSL Market , Great VPS hosting provided by Tektonic
 

[ Track this topic :: Email this topic :: Print this topic ]

reply to topic new topic new poll
Topic: Be a NAT Router (like linksys), configure apt, routing, NAT+ dhcp< Next Oldest | Next Newest >
bburns35 Offline





Group: Members
Posts: 2
Joined: April 2005
Posted: April 24 2005,19:35 QUOTE

# HOW TO:
# configure a standard (unmodified) DSL live-CD
# on a machine w/ two network interfaces
# (eth0 on internet-side and eth1 on LAN side)
# in order to provide NAT routing

# using iptables and dhcp3-server.

# I hope you can get most of the work done by
# "sourcing" this document.
# If you can figure out a way to download this
# as a single file without too much cruft...

# boot: dsl 2
# Who needs a GUI?

# Got Root?
# sudo sh

# maybe you need this if/with wireless stuff?
# pump -i wlan0

# download ibiblio... mydsl/system/iptables.dsl
wget http://ibiblio.org/pub....les.dsl

# install iptables
mydsl-load iptables.dsl

# configure subnet for eth1
ifconfig eth1 192.168.2.1 netmask 255.255.255.0

# clear iptables info?
# iptables --flush
# iptables --table nat --flush
# iptables --delete-chain
# iptables --table nat --delete-chain

# create NAT rule
iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE

# I didn't need this line. but maybe you do?
# (in case you have deny rules somewhere?)
# iptables --append FORWARD --in-interface eth1 -j ACCEPT

# turn on routing
echo 1 > /proc/sys/net/ipv4/ip_forward

# ??? /etc/init.d/dhcpd3-server start doesn't work!
# (I guess I was supposed to know to use "apt-get install" on dhcp3-server)

# get apt-get working
dpkg-restore

# Do I need to run this too? Maybe not.
# apt-get update

# install the dhcp server (and why do I need to uninstall dhcp3-common?)
apt-get remove dhcp3-common
apt-get install dhcp3-server


cd /etc/dhcp3
mv dhcpd.conf dhcpd.conf.dsl
cat dhcpd.conf.dsl /etc/resolv.conf >> dhcpd.conf
cat >> dhcpd.conf << EOF
# Comment out the search and nameserver entries.
# Copy their values into the domain-name and domain-name-servers entries

subnet 192.168.2.0 netmask 255.255.255.0 {
 range 192.168.2.100 192.168.2.200;
 option routers 192.168.2.1;
}
EOF


# vi dhcpd.conf

# type /etc/init.d/dhcpd3-server start
# the dhcp server should start

# --------------------------------------------

# It doesn't work?
# try hitting <alt-f2> to get another window.
# type tail -f /var/log/messages

# hit <alt-f1> to get back to the original shell
# and try again

# Does it work yet?
# Try connecting another machine to the network attached
# to eth1.
# it should get the ip address 192.168.2.200

# if this does not work, you can try to manually
# configure your second machine for testing purposes.
#
# ifconfig eth0 192.168.2.99
# route add default gw 192.168.2.1
# ping 192.168.2.1
# (If that works, your LAN works...)
# ping your-damn-router-eth0-address
# (If that works, the routing table on your test client is correct)
# ping an-address-on-the-internet
# (like your ISPs DHCP server, or nameserver, or router)
# (If that works the "damn" routing and NAT stuff works)
# Do you have a name-service issue?
# Ping your name-server!
# and do an nslookup!
# nslookup www.netsol.com your-name-server-address

# Ok... What do you guys think?
# Did that work?
# Comments?
Back to top
Profile PM 
bburns35 Offline





Group: Members
Posts: 2
Joined: April 2005
Posted: April 24 2005,20:42 QUOTE

How to: get the previous post as a text file.

Code Sample
links damnsmalllinux.org


Select Forums (w/ right-cursor)

Search for HowTos by typing:
Code Sample
/ HowTos

Select HowTos (w/ right-cursor)

Search for NAT by typing:
Code Sample
/ NAT

Select "Be a NAT Router (like linksys)"

type keys:
Code Sample
<esc> <f> <d>

When prompted w "Save as file"
enter "natconfig.sh"
Hit <q> key.

Now that you've downdoaded this file, you'll have to clean it up
w/ your favorite editor (vi)

Type:
Code Sample
vi natconfig.sh

and waitaminute.
It's all indented, and the URL got munged.
How do I fix this?

Oh. I'll re-post inside "code" markups
no... that's still indented...

Ok, so edit this file... go to the line above the (2nd copy of the) code and type:
Code Sample
d1G

That should delete everything up to the top of the file.

Now go to the line below the code and  type:
Code Sample
dG

That should delete the rest of the cruft.

Now eliminate mysterious trailing blanks by typing: (note <esc> referrs to the "escape" key)
Code Sample
?EOF
ddOEOF<esc>


Now unindent by going back to the first line in the file, and typing:
Code Sample
55<j

repeat this step until the code is flush to the left.

now exit vi by typing
Code Sample
:wq


Now cross your fingers
And run the script by typing
Code Sample
. ./natconfig.sh


Things should download.
apt-get will spew errors 'cause it can't write to your CD + stuff...
apt will also ask you where your dhcp server should listen.
(eth1)

If you're lucky you can ignore all the errors and it'll all just work.

Don't forget to tailor the dhcpd.conf file for your network
And to run the /etc/init.d/dhcpd3-server script.

Here's the re-posted code.
-------------------------------------------------------------------
Code Sample


# download ibiblio /pub/Linux/distributions/damnsmall/mydsl/system/iptables.dsl
wget http://ibiblio.org/pub/Linux/distributions/damnsmall/mydsl/system/iptables.dsl

# install iptables
mydsl-load iptables.dsl

# configure subnet for eth1
ifconfig eth1 192.168.2.1 netmask 255.255.255.0

# clear iptables info?
# iptables --flush
# iptables --table nat --flush
# iptables --delete-chain
# iptables --table nat --delete-chain

# create NAT rule
iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE

# I didn't need this line. but maybe you do?
# (in case you have deny rules somewhere?)
# iptables --append FORWARD --in-interface eth1 -j ACCEPT

# turn on routing
echo 1 > /proc/sys/net/ipv4/ip_forward

# ??? /etc/init.d/dhcpd3-server start doesn't work!
# (I guess I was supposed to know to use "apt-get install" on dhcp3-server)

# get apt-get working
dpkg-restore

# Do I need to run this too? Maybe not.
# apt-get update

# install the dhcp server (why do I need to uninstall dhcp3-common?)
apt-get remove dhcp3-common
apt-get install dhcp3-server

cd /etc/dhcp3
mv dhcpd.conf dhcpd.conf.dsl
cat dhcpd.conf.dsl /etc/resolv.conf >> dhcpd.conf
cat >> dhcpd.conf << EOF
# Comment out the search and nameserver entries.
# Copy their values into the domain-name and domain-name-servers entries

subnet 192.168.2.0 netmask 255.255.255.0 {
 range 192.168.2.100 192.168.2.200;
 option routers 192.168.2.1;
}
EOF

# vi dhcpd.conf

# type /etc/init.d/dhcpd3-server start
# the dhcp server should start



This should work on machines w/ at least 64 megs of ram.
For some reason, 32 megs won't cut it. (scheesh)

Good luck.
Back to top
Profile PM 
tonyh Offline





Group: Members
Posts: 1
Joined: May 2005
Posted: May 03 2005,21:59 QUOTE

Thanks for this info--got it working.  However, I have two problems I'd like to resolve:

1. eth0 is configured by DHCP, eth1 is static?.  Whenever I reboot, eth1 is disabled--how can I get it to be enabled at startup?

2. I have to run "iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUER" and "echo 1 > /proc/sys/net/ipv4/ip_forward" after reboot for NAT to work.  Any way to make these settings static?.  I am trying to find the answers in the documentation, but haven't been able to dig it up yet.

Thanks!
Back to top
Profile PM 
gjhicks Offline





Group: Members
Posts: 108
Joined: April 2004
Posted: May 06 2005,12:04 QUOTE

Hi,

Have been trying to get the suggested approach in your post to work but have had a few problems.

My little system "should" look like this:

adsl-->[modem/router]-->[ethx]-->{box}-->[ethy]-->[wireless AP]-.-.-.-.several wireless connected boxes

Where the modem/router, eth0, eth1 and the wireless AP all have IP addresses.

I couldn't figure out which of the various IP addressed bits should be eth0 and eth1 - which made it pretty hard to get started!

Have you had any experience(s) in setting up such a system?

Any suggestions gratefully received.

Regards,

Geoff.
Back to top
Profile PM 
3 replies since April 24 2005,19:35 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]

 
reply to topic new topic new poll
Quick Reply: Be a NAT Router (like linksys)

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code