Friday, June 3, 2011

Make a Simple Router on Debian

1. First step..
Charging based on the following assumptions;
eth0 connected to an ADSL Modem or WiFi with IP-Address 192.168.137.1
eth1 connected to local network / internet client
setting eth0 with IP-address 192.168.137.2 and the IP address for the local 10.11.12.1,  
subnet mask to 255.255.255.0

# nano /etc/network/interfaces
     auto eth0
     iface eth0 inet static
     address 192.168.137.2
     netmask 255.255.255.0
     gateway 192.168.137.1

     auto eth1
     iface eth1 inet static
     address 10.11.12.1
     netmask 255.255.255.0

2. seconds step, install bind for DNS servers.
      # apt-get install bind9
     
    **after finished installing do this setting
       # nano /etc/bind/named.conf.local

      // add entries for other zone below here

       zone "Pasca.net" IN {
       type master;
       file "db.domain";
       };
       zone "12.11.10.in-addr.arpa" IN {
      type master;
      file "db.ip";
      };

*then create a file db.domain and db.ip, position location files in /var/cache/bind/
      #nano /var/cache/bind/db.domain
        - this is configuration for db.domain
        ; Pasca.net 
        $TTL 604800
       @ IN SOA ns1.Pasca.net. root.Pasca.net. (
       2006020201 ; Serial
       604800 ; Refresh
       86400 ; Retry
       2419200 ; Expire
       604800); Negative Cache TTL
       ;
       @ IN NS ns1
       IN MX 10 mail
       IN A 10.11.12.1
       ns1 IN A 10.11.12.1
       mail IN A 10.11.12.250 ; We have our mail server somewhere else.
       www IN A 10.11.12.1
       client1 IN A 10.11.12.2 ; We connect to client1 very often.

    #nano /var/cache/bind/db.ip
    - this is configuration for db.ip
        ; Pasca.net 
        $TTL 604800
       @ IN SOA ns1.Pasca.net. root.Pasca.net. (
       2006020201 ; Serial
       604800 ; Refresh
       86400 ; Retry
       2419200 ; Expire
       604800); Negative Cache TTL
       ;
      @ IN NS ns1
       IN MX 10 mail
       ns1 IN PTR 10.11.12.1
       1 IN PTR ns1
       1 IN PTR ns1.Pasca.net

3.The Third step, Setting file resolv.conf, position location files in /etc/resolv.conf
   #nano /etc/resolv.conf
      nameserver 10.11.12.1
      domain Pasca.net
      domain www.Pasca.net

   **after that restart bind
     #/etc/init.d/bind9 restart

4. The fourth step , Now it's time to edit Routing Settings:
     #nano /etc/sysctl.conf
     #Enable packet forwarding
     net.ipv4.ip_forward = 1

    **this is rule for IP-tables.
       #iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
 
    **or just save it in rc.local to run autostart-up
        #nano /etc/rc.local
        iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
       
   **restart your network configuration
       #/etc/init.d/networking restart

then finish was an example to make a simple router on debian..
for the client to this router, setting IP address 10.11.12.2-10.11.12.254
 

good luck friend ...

No comments:

Post a Comment