thus98

• 11 December 2007 - port forwarding

เครื่องที่ทำ port forwarding ต้องมีแลนการ์ดอย่างน้อยสองใบ คือ ip จริง กับ ip ปลอม

ถ้าทำ port forwarding จาก router ใช้คำสั่งดังนี้ครับ
ip nat inside source static tcp 192.168.0.50 80 interface serial0 80

โดย 192.168.0.50 80 คือ ip ปลอม กับ พอร์ต ที่ต้องการให้ forward มา

serial0 80 คือ interface ฝั่ง WAN ที่ออกเน็ต

 

เปิด ipnat ให้ทำงานโดยเพิ่มในไฟล์ /etc/rc.conf ดังนี้
ipnat_enable="YES"
ipnat_rules="/etc/ipnat.rules"

แล้วเพิ่มกฎนี้เข้าไปใน /etc/ipnat.rules
rdr rl1 0.0.0.0/0 port 8081 -> 192.168.0.252 port 80 tcp

โดย rl1 คือการ์ดแลนใบที่ต้องการให้ forward มา อาจจะเป็น ip จริงฝั่งที่ต่อกับอินเตอร์เน็ต โดยพอร์ต 8081 คือหมายเลขพอร์ตที่เรียกเข้ามา
เช่น การ์ดแลนใบนี้(rl1)มี ip 202.222.123.5 ถ้าเรียกผ่าน potocol http ก็เรียกโดย
http://202.222.123.5:8081มันก็จะ forward ไปที่ 192.168.0.252 พอร์ต 80

ตัวอย่าง
rdr rl1 0.0.0.0/0 port 8081 -> 192.168.0.252 port 80 tcp
rdr rl1 0.0.0.0/0 port 22 -> 192.168.0.3 port 22 tcp
rdr rl1 0.0.0.0/0 port 80 -> 192.168.0.4 port 80 tcp
rdr rl1 0.0.0.0/0 port 25 -> 192.168.0.4 port 25 tcp

Comments (0) :: Post A Comment! :: Permanent Link

• 11 December 2007 - Set IP_Address

=== LAN IP Address=====
ifconfig xl0 192.168.1.1 netmask 255.255.255.0 up
ifconfig  xl0 192.168.2.2 netmask 255.255.255.255. alias   /* ip alias ให้กำหนด ip เดียว
/////////////////////////////////////////////////////
/etc/rc.conf
ifconfig_xl0="inet 192.168.1.1 netmask 255.255.255.0"
ifconfig_xl0_alias0="inet 192.168.2.2 netmask 255.255.255.255"
Comments (0) :: Post A Comment! :: Permanent Link

• 11 December 2007 - vsftp

#pw groupadd -g 75 -n ftp
#pw useradd -u 75 -g ftp -c “FTP Service” -d /home/ftp -m -s /sbin/nologin -n ftp
#cd /usr/ports/ftp/vsftpd
#make install clean
#cd /home
#chown root ftp
#chgrp wheel ftp
#chmod og-w ftp
#vi /usr/local/etc/vsftpd.chroot_list แล้วเพิ่มชื่อ user ที่ต้องการทำ chroot
- แก้ไขไฟล์ /usr/local/etc/vsftpd.conf ดังนี้
- anonymous_enable=YES
- local_enable=YES
- write_enable=YES
- chroot_list_enable=YES
- chroot_list_file=/usr/local/etc/vsftpd.chroot_list
- secure_chroot_dir=/home/ftp
- แก้ไขไฟล์ /etc/inetd.conf
- ftp stream tcp …………. /usr/local/libexec/vsftpd vsftpd
- #killall inetd
#inetd –Ww

 

-------------------------------------------------------------------

 # อาจจะต้อง add group ftp ก่อง
 
#pw useradd -u 75 -g ftp -c “FTP Service” -d /home/ftp -m -s /sbin/nologin -n ftp
#cd /usr/ports/ftp/vsftpd
#make install clean

#cd /home
#chown root:wheel ftp
#chmod og-w ftp

- แก้ไขไฟล์ /usr/local/etc/vsftpd.conf ดังนี้
- anonymous_enable=YES
- local_enable=YES
- write_enable=YES
- chroot_list_enable=YES
- chroot_list_file=/usr/local/etc/vsftpd.chroot_list
- secure_chroot_dir=/home/ftp     -->>>   anonymous path

 #vi /usr/local/etc/vsftpd.chroot_list แล้วเพิ่มชื่อ user ที่ต้องการทำ chroot

- แก้ไขไฟล์ /etc/inetd.conf
- ftp stream tcp …………. /usr/local/libexec/vsftpd vsftpd

#killall inetd
#inetd –Ww  
 ***   ที่ /etc/rc.conf       ใส่  inetd_enable="YES"  เพื่อ auto start service

Comments (0) :: Post A Comment! :: Permanent Link

• 11 December 2007 - ProFTP

- cd /usr/port/ftp/proftpd/
- make
- make install
- vi /usr/local/etc/rcd/proftpd.sh
    DefaultRoot ~
- vi /etc/rc.conf
    proftpd_enable="YES"
- /usr/local/etc/rc.d/proftpd.sh start
- /usr/local/etc/rc.d/proftpd.sh status ( ถ้า show status มาเป็น " Proftpd is not running" ให้ทำดังนี้)

 - vi /usr/local/etc/proftpd.conf
 - ใส่ ScoreboardFile /var/run/proftpd.scoreboard
 - ออกมาสร้าง file--> touch /var/run/proftpd.scoreboard
 - แล้วลอง start และลองดู status ใหม่
 -
adduser สำหรับให้ ftp

Comments (0) :: Post A Comment! :: Permanent Link

• 11 December 2007 - FIREWALL

options IPFIREWALL
options IPFIREWALL_FORWARD
options IPFIREWALL_DEFAULT_TO_ACCEPT
options IPFIREWALL_VERBOSE
options IPFIREWALL_VERBOSE_LIMIT=120
options IPDIVERT
options DUMMYNET

 

เพิ่มกฎ

ipfw add 100 allow ip from any to any via lo0
ipfw add 200 deny ip from any to 127.0.0.0/8
ipfw add 300 deny ip from 127.0.0.0/8 to any
ipfw add 301 deny tcp from any to any 445
ipfw add 302 deny tcp from any to any 135
ipfw add 303 deny tcp from any to any 6881
ipfw add 304 deny tcp from any to any 27015
ipfw add 305 deny tcp from any to any 1026
ipfw add 306 deny tcp from any to any 1434
ipfw add 307 deny tcp from any to any 139
ipfw add 308 deny tcp from any to any 137
ipfw add 65000 allow ip from any to any
ipfw add 65535 allow ip from any to any

 

 

Comments (0) :: Post A Comment! :: Permanent Link

• 11 December 2007 - Crontab

เราสามารถใช้คำสั่ง crontab เพื่อสั่งงานให้ server ทำงานตามวันเวลาที่เราต้องการได้ดังนี้

สร้างไฟล์ เช่น
# pico kitti.cron
0 5 * * * cp /home/kitti/data1.txt /home/kitti/data2.txt

อธิบาย:
0 คือ นาทีที่ 0 ซึ่งค่าเป็นไปได้คือ (0-59)
5 คือ ตีห้า ซึ่งค่าเป็นไปได้คือ (0-23)
* คือ ทุกวัน ซึ่งค่าเป็นไปได้คือ (1-31)
* คือ ทุกเดือน ซึ่งค่าเป็นไปได้คือ (1-12)
* คือ ทุกวันของสัปดาห์ ซึ่งค่าเป็นไปได้คือ (0-6)

แล้ว save
# crontab kitti.cron
เป็นการสั่งให้ crontab ทำงานตามวันเวลาดังกล่าว

# crontab -l (แอลเล็ก)
เป็นการขอดูว่าเราสั่งงานอะไรไว้บ้าง


แล้วคุณก็จะสั่งงาน Server ได้ดั่งใจครับ

Comments (0) :: Post A Comment! :: Permanent Link

About Me


«  January 2009  »
MonTueWedThuFriSatSun
 1234
567891011
12131415161718
19202122232425
262728293031 

Recent Posts

• port forwarding
• Set IP_Address
• vsftp
• ProFTP
• FIREWALL

Links

• Home
• View my profile
• Archives
• Friends
• Email Me
• My Blog's RSS

Friends

Page 1 of 1
Last Page | Next Page



Power By : BlogKa.com - Free Blog Hosting