[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: How to edit /etc/init.d/network?



Paul Nathan Puri wrote:
> 
> So that my computer will apply the ipchains commands, the ipforward
> command in echo, the ifconfig, etc... at boot?

I'm definitely not a networking guru, but I'll take a shot at it.

First of all, if you haven't already, take a look at the recently
updated IP Masq HOWTO found at the link below. It explains most
everything you need to know including what's needed for 2.2.X vs 2.0.X
kernels.

http://www.tor.shaw.wave.ca/~ambrose/ipmasq-HOWTO.html#toc3

As a simple example, here's my /etc/init.d/network for the gateway
machine on a 2 computer home network. I'm using the plip device
(parallel port cable) instead of network cards, but it's the same idea.
I'm using kernel 2.2.3 now.

--------------------------------------------------------------------
#! /bin/sh

ifconfig lo 127.0.0.1
route add -net 127.0.0.0 netmask 255.0.0.0 dev lo

ifconfig plip0 192.168.1.1 pointopoint 192.168.1.2 up
route add -net 192.168.1.0 netmask 255.255.255.0 dev plip0

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

ipchains -P forward DENY
ipchains -A forward -s 192.168.1.0/24 -j MASQ

# these were used with kernels 2.0.XX instead of ipchains
# ipfwadm -F -p deny
# ipfwadm -F -a m -S 192.168.1.0/24 -D 0.0.0.0/0
---------------------------------------------------------------------

You also have to set the default route on the machine(s) that will be
using the gateway machine to access the Internet or whatever. Here's how
I have the /etc/init.d/network file set up on my other machine:

-------------------------------------------------------------------
#! /bin/sh

ifconfig lo 127.0.0.1
route add -net 127.0.0.0 netmask 255.0.0.0 dev lo

ifconfig plip0 192.168.1.2 pointopoint 192.168.1.1 up
route add -net 192.168.1.0 netmask 255.255.255.0 dev plip0

route add default gw 192.168.1.1
--------------------------------------------------------------------

Tom

-- 
Try Debian GNU/Linux - it's free, it's open source, and it rocks
http://www.debian.org


Reply to: