# n00b setup

## plafle

I'm looking for an HOWTO for gentoo that would explain me

1. How to run and setup some kind of ssh/inetd daemon (I emerged xinetd but I can't find any conf file...) ?

2. How to setup my gentoo box to adsl-start at boot time and each time it gets disconnected ?

3. How to setup my gentoo box as the gateway of my network and what scripts to use to configure iptables ?

Thank you gurus  :Cool: 

----------

## garo

1)

```
emerge openssh

rcupdate add sshd
```

----------

## Pindrop

2) Not sure about how to restart it every time it disconnects, but I made this startup script for my ADSL. 

```
nano -w /etc/init.d/adsl
```

```
#!/sbin/runscript

start() {

    ebegin "Starting ADSL"

    /usr/sbin/adsl-start

    eend $? "Connection Failed"

}

stop() {

    ebegin "Stopping ADSL"

    kill $(cat /var/run/ppp0.pid)

    kill $(cat /var/run/pppoe.conf-adsl.pid)

    kill $(cat /var/run/pppoe.conf-adsl.pid.pppd)

    kill $(cat /var/run/pppoe.conf-adsl.pid.pppoe)

    eend $? "Failed to stop ADSL"

}

```

Chmod it so you can execute it.

```
chmod +x /etc/init.d/adsl
```

Add it to default runlevel

```
rc-update add adsl default
```

----------

## rizzo

Pindrop that is a tasty script.  I had just put adsl-start in my rc.local, but I like your script.

Thanks.

----------

## plafle

Thanks garo.

Thanks pindrop

The problem with this script is that it is loaded before my network interfaces... I had to add dependencies and it took your script this way

```

#!/sbin/runscript 

depend() {

   need net.eth0 net.eth1 netmount

}

start() { 

    ebegin "Starting ADSL" 

    /usr/sbin/adsl-start 

    eend $? "Connection Failed" 

} 

stop() { 

    ebegin "Stopping ADSL" 

    kill $(cat /var/run/ppp0.pid) 

    kill $(cat /var/run/pppoe.conf-adsl.pid) 

    kill $(cat /var/run/pppoe.conf-adsl.pid.pppd) 

    kill $(cat /var/run/pppoe.conf-adsl.pid.pppoe) 

    eend $? "Failed to stop ADSL" 

} 

```

I'm not sure wether net.eth0 and netmount are absolutely necessary (my modem is blugged in on eth1) but it worked for me and I find it clean.

I'll look further to find "auto-reconnect" scripts,or I'll write them myself...

Can some of you help me (or drive me on an easy for n00bs Howto) on setting up Masquerading/iptable ?

----------

## lowgitek

I got some ideias from your script and did some other 2 that have also a good use here it goes. 

Firewall (using the firestarter ebuild)

```

#!/sbin/runscript

depend() {

   need net.eth0 adsl

   }

   start() {

       ebegin "Starting Firewall"

           /usr/bin/firestarter -a -u  --sm-disable

       eend $? "Starting Firewall Failed"

            }

   stop() {

       ebegin "Stopping Firewall"

          /usr/bin/firestarter -d -u  --sm-disable                                     eend $? "Failed to stop Firewall"

          } 

   halt() {

         ebegin "Haltting All Traffic"

            /usr/bin/firestarter -h -u  --sm-disable                                     eend $? "Halt Traffic Failed"

              } 

```

Dyndns (usind ddclient)

```

#!/sbin/runscript

depend() {

   need net adsl firewall

   } 

start() {

    ebegin "Setting DynDNS"

        [ -f /etc/ddclient.conf ] || exit 0

        # Start daemons.

        /usr/sbin/ddclient -daemon 300

    eend $? "Setting DynDNS Failled!"

            }

stop() {

    ebegin "Stop ddclient"

        kill `ps -aef | awk '/[ \/]perl.*ddclient/ { print $2}'`

    eend $? ""

    }

status() {

    ebegin "Show status"

       pids=`ps -aef | awk '/[ \/]perl.*ddclient/ { print $2}'`

        if test "$pids"

           then        

                   for p in $pids

                   do

                           echo "$program (pid $p) is running"

                   done

           else

                   echo "$program is stopped"

           fi   

    eend $? "Failed to Show Stauts!"

    }

```

Comments are welcome. 

Cheers, 

Elton Machado.

----------

## plafle

Your scripts look good  :Smile: 

But I'm not planning to install any X app on this box. So will I be able to configure and use firestarter on my console-based Gentoo ? I can't see any doc/faq about this on the firestarter homepage...

----------

## madchaz

shorewall is also pretty good. as nice howtoos on there site and it's in portage. 

I'm also looking for a script that can test if the connection works (probably using ping) and stop/start the connection if it dies. reboot the machine if needed as well. I may write one when I don't need to be in bed so bad, lol

----------

