Set Static IP Address

  1. ค้นหา ip address สังเกตุคำว่า “inet addr:158.108.xx.yy”
    $ ifconfig eth0
    eth0      Link encap:Ethernet  HWaddr 00:08:a1:91:08:a4  
              inet addr:158.108.xx.yy  Bcast:158.108.213.127  Mask:255.255.255.128
              inet6 addr: fe80::208:a1ff:fe91:8a4/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:130315 errors:0 dropped:0 overruns:0 frame:0
              TX packets:71707 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:40944583 (40.9 MB)  TX bytes:10263714 (10.2 MB)
              Interrupt:17 Base address:0x9000
  2. ค้นหา subnet mask และ gateway
    $ route -n
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    158.108.213.0   0.0.0.0         255.255.255.128 U     0      0        0 eth0
    169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 eth0
    0.0.0.0         158.108.213.1   0.0.0.0         UG    100    0        0 eth0
  3. เปิดไฟล์ /etc/sysconfig/network
    NETWORKING=yes
    HOSTNAME=linux.klainfo.com
    ONBOOT=yes
    
  4. เปิดไฟล์ /etc/sysconfig/network-scripts/ifcfg-eth0
    DEVICE=eth0
    ONBOOT=yes
    BOOTPROTO=static
    IPADDR=158.108.xx.yy
    NETMASK=255.255.255.128
    GATEWAY=158.108.213.1
    
  5. restart and test
    $ service network restart; nslookup www.google.co.jp
    

DNS

  1. Install
    $ yum install bind bind-chroot
  2. vi /var/named/chroot/etc/named.conf
    acl ku {158.108.0.0/16;};
    
    options {
    	directory "/var/named";
    	dump-file "/var/named/data/cache_dump.db";
    	statistics-file "/var/named/data/named_stats.txt";
    	listen-on port 53 {127.0.0.1;};
    	allow-query {127.0.0.1;};
    };
    
    zone "yourhost.net"{
    	type master;
    	file "yourhost.net.for";
    }; 
    
    zone "xx.108.158.in-addr.arpa"{
    	type master;
    	file "yourhost.net.rev";
    };
    
    include "/etc/rndc.key";
    
    1. xx คือเลขของชุด IP 158.108.xx.yy
  3. vi /var/named/chroot/var/named/yourhost.net.for
    $TTL 86400
    $origin yourhost.net.
    @ IN SOA yourhost.net. root.yourhost.net. (
    	2005081101	;serial
    	3H		;refresh
    	15M		;retry
    	1W		;expiry
    	1D)		;minimum 
    
    	IN NS		yourhost.net.
    	IN MX 10	yourhost.net.
    
    ns	IN A		158.108.xx.yy
    www	IN CNAME	ns
    www2	IN CNAME	ns
    
  4. vi /var/named/chroot/var/named/yourhost.net.rev
    $TTL 86400
    @ IN SOA yourhost.net. root.yourhost.net. (
    	2005081001	;serial (d.adams)
    	3H		;refresh
    	15M		;retry
    	1W		;expiry
    	1D)		;minimum
    	IN NS		yourhost.net.
    yy	IN PTR ns.yourhost.net.
    yy	IN PTR www.yourhost.net.
    yy	IN PTR www2.yourhost.net.
    
    1. yy คือเลขชุด IP ตัวสุดท้ายของ 158.108.xx.yy
  5. Restart and test
    $ service named restart
    $ chkconfig --level 3 named on
  6. vi /etc/resolve.conf
    domain yourhost.net
    search yourhost.net
    nameserver 127.0.0.1
    
  7. ทดสอบ
    $ nslookup www.yourhost.net           # forward lookup
    $ nslookup 158.108.xx.yy              # reverse lookup
    
  8. กรณีเกิดปัญหา ให้
    tail /var/log/message
    
  9. ถ้า Restart แล้วสามารถ nslookup ได้เหมือนเดิม ถือว่าผ่านครับ

Apache

Install

$ yum install httpd
Mostly use following this command
$ service httpd (start|stop|restart|status)
Run Level 3 when booting
$ chkconfig --level 3 httpd on

Configuration file /etc/httpd/conf/httpd.conf

  1. Set Document Root
    DocumentRoot "/var/www/html"
    

Set general user homepage

  1. Comment #340
    #UserDir disable
    
  2. Uncomment #347
    UserDir public_html
    
  3. Uncomment #355-#366
  4. restart service
    $ service httpd restart
    
  5. create .html and run
    $ lynx http://localhost/~%username
    
  6. set permission
    $ chmod 701 /home/$username
    $ chmod 705 /home/%username/public_html
    $ chmod 604 -R /home/%username/public_html/*
    

Access Configuration

Example

<Directory /home/webman/htdocs/>
   Options Indexes Includes ExecCGI
   AllowOverride None
   order allow,deny
   allow from all
</Directory>

Options

  1. All Allow all
  2. ExecCGI Allow to use CGI
  3. Includes Allow to use SSI (Server Side Include)
  4. Indexes Allow to show all files in directory
  5. None Deny all options

AllowOverride

This directive uses for allow directory overriding

  1. All allow to override
  2. None deny to override

Order

To set allow and deny sequence

  1. deny,allow check deny before allow
  2. allow,deny check allow before deny
Example

order allow,deny
deny from all
allow from .cpe.ku.ac.th
allow from 158.108.
The server allow any host which is in .cpe.ku.ac.th domain and has IP address leading 158.108.

But without that allowed host, another host is denied.

Example

order deny,allow
deny from .cpe.ku.ac.th
deny from 158.108.
allow from all
The server deny any host which is in .cpe.ku.ac.th domain and has IP address leading 158.108.

But without that denied host, another host is allowed.

Document Access Configuration (โชว์แผ่นกอเอี๊ย)

  1. แก้ไขไฟล์
    $ vi /etc/httpd/conf/httd.conf
    หาบรรทัดที่มีคำว่า AllowOverride None
    ให้แก้เป็น
    AllowOverride All
    
  2. example code of .htaccess
    AuthUserFile /var/www/html/private/passwords
    AuthGroupFile /dev/null
    AuthName “Welcome"
    AuthType Basic
    <Limit GET>
    require valid-user
    </Limit>
    
  3. some useful command
    $ htpasswd -c <password file name> <user>      # create password file
    $ htpasswd -c <password file name> <user>      # add user
    

Related Content

 
centos_networking.txt · Last modified: 2010/02/02 01:25 (external edit) · [Old revisions]
Recent changes RSS feed Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki