Showing posts with label apt-proxy. Show all posts
Showing posts with label apt-proxy. Show all posts

Monday, February 15, 2016

Debian Network Configuration


                                                Debian  Network Configuration

l  IP Setting (Static+DHCP)
l  DHCP
l  DNS (BIND9)
l  APT-PROXY

IP Setting (Static+DHCP)
l  IP Setting (Static)
                        Open Interfaces file and add the these lines.
                        #>vi   /etc/networking/interfacse
                                    auto lo
                                    interfaces lo inet loopback
                                    address 127.0.0.1
                                    netmask   255.0.0.0            
                                          
                                    ath0
                                    iface eth0 inet static
                                    address 192.168.1.12
                                    netmask  255.255.255.0
                                    getway    192.168.1.1
                                    netmask  255.255.255.0

l  IP Setting (DHCP)
                                     ath0
                                     iface eth0 inet dhcp
                                        
                                                            DHCP
l  Install DHCP on the debain with the help of
                                    #>  apt-get install dhcp3-server

l  Open dhcp.conf file to define the range and domain name and etc.

                                    #>vi /etc/dhcp3/dhcp.conf

                                    ddns-update-style  none;
                       
                                    option domain-name “emergen.org” ;
                                    option domain-name-server 192.168.2.1;

                                    Increase default-lease-time & Max-lease-time
             
                                    subnet 192.168.2.0   netmask 255.255.255.0{
                                                range 192.168.2.1  192.168.2.100;
                                                option subnet-mask 255.255.255.0;
                                                option routers  192.168.2.1;
                                    }
                        
                        If you want to assign the static IP address to any special machine with the help of dhcp               
                        that define the mack address of that machine NIC.

                        host hostname {
                                hardware ethernet 00:2E:4B:5R:EE;
                                fixed-address  192.168.2.15;
                       }
                        when ever you are going to restart the DHCP or the system it's have same IP address that                         u assign.
                      
                                                DNS  (BIND9)
l  Primary DNS

l  Install DIND9
                                    #>  apt-get install bind9
l  Stop that service
                                    #> /etc/init.d/bind9 stop

l  For defining the forword and reverse zone open name.cof file

                                    #>vi /etc/bind/name.conf & define zone's

                        Don't delete the previous configuration just add these zone in name.conf file.
l  Forward Zone
                                    zone  “emergen.org”{
                                                type master;
                                                notify no;
                                    file “/etc/bind/emergen.org.db”;
                                    }
l  Reverse Zone
                                    Zone “2.168.192.in-addr.arpa”{
                                                type master;
                                                notify no;
                                                file “2.168.192.db”;
                                    } 
l  Now create the forward & reverse zone file open a file.
                                    #>vi /etc/bind/emergen.org.db






                                    And add this script

            $TTL   2d
            @   IN SOA  emergen.org.  root.emergen.org. (
                                                22     ;serial  
                                                3h     ;refresh
                                                1h     ;retry
                                                1w     ; expiry
                                                1d )   ; Minimum

                                    emergen.org.   IN  NS   dns1.emergen.org.

                                                            IN  A    192.168.3.1
                                    www               IN  A    192.168.3.1
                                    server               IN  A    192.168.3.1

                        ; If you want to define more host names that just add them
                                                mail           IN  A    192.168.3.1
                                                smtp           IN  A    192.168.3.1
                                                pop            IN  A    192.168.3.1


l  Now create reverse zone file
                                                #> vi /etc/bind/2.168.192.db

            And add these line
                        $TTL     2d
                        @ IN SOA  emergen.org. root.emergen.org.(
                                      2004111601            ; Serial
                                      8H                    ;  Refresh
                                      4H            ; Retry
                                      4W                            ;  Expire
                                      1D    )            ; Default TTL
                     
                                     IN NS   dns1.emergen.org.

                        1.3.168.192.in-addr.arpa.  IN PTR  www.emergen.org.

l  Start the BIND9 Service
                                     #> /etc/init.d/bind9 start

l  Test your BIND9 configuration
                                    #> ping www.emergen.org  or mail.emergen.org

l  Again install bind9 DNS package with the same configuration files on second machine just you have to add some extra lines.

                        Add Zones in name.conf

                                    zone "emergen.org"{
                                                       type  slave;
                                                       file "/etc/bind/emergen.org.db";
                                                    masters{
                                                         192.168.3.1;
                                                    };
                                    };
                                    zone "3.168.192.in-addr.arpa"{
                                                       type  slave;
                                                       file "/etc/bind/3.168.192.db";
                                         masters{
                                             192.168.3.1;
                                         };
                                     };

l  Create file for foreword zone.
                                    vi /etc/bind/emergen.org
                                   
                                     ------ same like previous file. 
                                    emergen.org.   IN  NS   dns1.emergen.org.
                                                            IN  NS   dns2.emergen.org. // Add this line after that one.                                                                                                  
                                     ------ same like previous file. 

l  Create file for reverse zone.
                                    vi /etc/bind/3.168.192.db

                                     ------ same like previous file. 
                                                 IN NS   dns1.emergen.org.
                                                 IN NS   dns2.emergen.org. // Add this line after that one.
                                     ------ same like previous file. 

l  Now restart the bind9 service
                                    /etc/init.d/bind restart


                
                         And add  one more line in the dhcp.conf file
                                     ------ same like previous file. 
                                                option domain-name-servers 192.168.3.1; // this IP address of your                                                                                                                         second DNS machine.
                                     ------ same like previous file. 

l  For testing you need a three machines one for primary DNS and second for secondry DNS and one use as a client. Now test your DNS server form the client console it
                         resolving or not.
                                    #>nslookup emergen.org or 192.168.3.1

l  If you found no error after executing this commad than stop one DNS server
                                    #>/etc/init.d/bind stop

                        And than again execute
                                    #>nslookup emergen.org or 192.168.3.1

l  Now if u didn't find any error it means that configuration is goes fine





                                                            APT-PROXY
l  Install Apt-proxy
                        #> apt-get install apt-proxy

l  Add mirrors in apt-proxy-v2.conf. we can find the mirrors on the web with the help  of google.com and define the IP, PORT and cache-dir where u want to store download packages.

                        #>  vi /etc/apt-proxy/apt-proxy-v2.conf   
                                    address 192.168.1.12
                                    port = 9999;
                                    cache-dir= “/var/cache/apt-proxy”
                                    and Define the mirror's.


l  some time's your firewall is not allow to go direct on the internet without username or password or you request is unable to find the proxy setting bcouse u did't define than if you want to define the http proxy than type
                                    export http_proxy=”192.168.1.1”
                                    I.E_ 192.168.1.1 this is the address of ur firewall machine.

l  On the Client side open source.list file add some mirrors but with your apt-proxy server address.

                        deb http://192.168.1.12:8080/kubuntu/ dapper main restricted
                        Add resources like this and run

l  #>apt-get update
                        to download the new available updates & stores in local cache.




Saturday, March 3, 2012


APT-PROXY Configuration
Apt-proxy is caching proxy can be easily install on ubuntu/debain. It will build up a partial debian mirror, and caches the packages in your hard drive it will behaves full http proxy server. In the case of missing packages the apt-proxy will fetch the missing package from internet and that will save your installation time and bandwidth, it's also clean the unused files based on user defined attributes in configuration file. apt-proxy is also accessible through ftp:// protocol.


Install proxy on your proxy server from any of debain/ubuntu mirror.

Install Apt-proxy 
        $> apt-get install apt-proxy


Open the apt-proxy configuration file which contains the default apt-proxy settings, Add mirrors in apt-proxy-v2.conf define the IP, PORT and cache-dir where you want to store download packages.


  $>  vi /etc/apt-proxy/apt-proxy-v2.conf    



      address 192.168.1.12
        port = 9999;
        cache-dir= “/var/cache/apt-proxy”
        timeout = 30
        passive_ftp = on


        [ubuntu]
        ; Ubuntu archive
        backends =
        http://archive.ubuntu.com/ubuntu
        http://de.archive.ubuntu.com/ubuntu
        [ubuntu-security]
        ; Ubuntu security updates
        backends = http://security.ubuntu.com/ubuntu
        [debian]        ; Backend servers, in order of preference
        backends =
        http://ftp.us.debian.org/debian
        http://ftp.de.debian.org/debian
        http://ftp2.de.debian.org/debian
        ftp://ftp.uk.debian.org/debian
        [debian-non-US]
        ; Debian debian-non-US archive
        backends =
        http://ftp.us.debian.org/debian-non-US
        http://ftp.th.debian.org/debian-non-US
        ftp://ftp.us.debian.org/debian
        [security]
        ; Debian security archive
        backends =
        http://security.debian.org/debian-security
        http://ftp2.de.debian.org/debian-security
        [openoffice]
        ; OpenOffice.org packages
        backends =
        http://ftp.freenet.de/pub/debian-openoffice
        http://ftp.sh.cvut.cz/MIRRORS/OpenOffice.deb
        http://borft.student.utwente.nl/debian
        [apt-proxy]
        ; Apt-proxy new versions
        backends = http://apt-proxy.sourceforge.net/apt-proxy


Initializing apt-proxy
You’re apt-proxy is ready to use, to start/restart you’re apt-proxy server run


$> /etc/init.d/apt-proxy [start|restart]


Export HTTP_PROXY
If you are using http proxy to connect though internet you need to define the proxy setting in your server. To define the proxy settings you  run


$> export http_proxy=http://username:password@myproxyserver:port/
$> export ftp_proxy=http://username:password@myproxyserver:port/


You need to export http proxy setting each time your server restarted to fix the add above lines in /etc/bash.bashrc file.


Client Setting
Edit source.list (/etc/apt/source.list) to use your proxy server instead of using internet.
Replace the existing mirrors


deb http://archive.ubuntu.com/ubuntu dapper main restricted
deb http://security.ubuntu.com/ubuntu dapper-security main restricted universe
archive.ubuntu.com will be replace with your server address and port it would become 
deb http://myProxyServerIp:port/ubuntu dapper main restricted
deb http://myProxyServerIp:port /ubuntu-security dapper-security main restricted universe


$>apt-get update

Enjoy your local proxy server.

AWS EC2 - SSH locked with UFW

Need to update the instance's user data: 1. Stop the instance 2. Right click (windows) or ctrl + click (Mac) on the instance to open a c...