2 Eylül 2013 Pazartesi

snmp community name change


snmp community name change

Merhabalar,

Sistemciler olarak sıklıkla karşılaşacağımız sorunlardan biride public olarak gelen snmp community namelerin güvenlik açığı olarak bize bildirilmeleridir.

İşletim sistemine göre snmpd.conf dosya yolu:

  • Centos/Redhat ---------------/etc/snmp/snmpd.conf
  • Solaris 10 --------------------/etc/sma/snmp/snmpd.conf
  • Solaris 11 --------------------/etc/net-snmp/snmp/snmpd.conf


İşletim sistemine göre snmp servisi restart :


  • Centos/Redhat ---------------service snmpd restart
  • Solaris 10
  1. svcs -a | grep sma   # sma servisin aşağıdaki gibi mi yoluna bakılır
  2. svcadm restart svc:/application/management/sma:default
  • Solaris 11
  1.  svcs -a | grep snmp   # snmp servisin aşağıdaki gibi mi yoluna bakılır
  2. svcadm restart svc:/...






















27 Ağustos 2013 Salı

Centos/Redhat TCPdump

Centos/Redhat TCPdump

Merhabalar,

Centos/Redhat sunucular üzerinde ilave bir program yüklemeden istediğiniz network kartından geçen tüm trafiği kaydedip sonra bunu wireshark uygulamasında açabiliriz. Hatta bazı kurallar koyup işimize yaracak paketleri seçebiliriz. Bir fikir vermek adına webserver olarak hizmet vermekte olan centos sunucuda aşağıdaki komut ile eth1 portundan ve sadece 80 portuna yapılan paketleri output.pcap dosyasına kaydediyor.



tcpdump -n -i eth1 -s 0 -w output.pcap src or dst port 80


Dosyayı wiresharkda inceleyiniz

24 Ağustos 2013 Cumartesi

Android tcp dump wireshark

Merhaba Arkadaşlar,


Bugün ihtiyacım olan ve aramalarım sonucunda tesadüfen bulduğum bir uygulamayı tanıtacağım.

Android cihazlarda internet trafiğini incelemek istiyordum. Wifi üzerinden akan trafiği fiddler üzerinden proxy yapınca inceleyebiliyordum. Peki GSM üzerinden akan trafiği nasıl inceleyeceğiz?

Sorunun cevabı tPacketCapture ... Uygulamayı yazanlara çok teşekkür.
Ben 4.2.2 Xperia Z telefonumda denedim. Hemde root yetkisi istemiyor..



Kaydedilen dosyayı PCde Wireshark ile açıp detaylı inceliyoruz...

20 Ağustos 2013 Salı

Centos/redhat FW kuralları iptables





Merhabalar,

Centos üzerinde bir uygulama ile fw da bir porta izin vereceğiz. Ve bu kuralımızı kalıcı hale getireceğiz.


[root@syslog ~]# iptables -I INPUT -p tcp --dport 514 -j ACCEPT
[root@syslog ~]# iptables -I INPUT -p udp --dport 514 -j ACCEPT
[root@syslog ~]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ]
[root@syslog ~]# service iptables status
Table: filter
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination
1    ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0           udp dpt:514
2    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:514

Chain FORWARD (policy ACCEPT)
num  target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination

 

24 Temmuz 2013 Çarşamba

Sunucu adını değiştirme





Merhabalar,

Centos üzerinde sunucunun ismini (hostname) değiştirmek bilmeyenler için zordur. Aslında çok basit.Aşaığdaki dosyada localhost yazan yeri istediğimiz(türkçe karakter olmadan) isimle değiştiriyoruz. Ve sunucu yerniden başlatıyoruz.


vi /etc/sysconfig/network  #eski ismini değiştiriyoruz.

Ayrıca

vi /etc/hosts     #dosyasında eski adıyla ilgili alanları değiştiriyoruz.
127.0.0.1 <HOSTNAME.example.org> <HOSTNAME> localhost
::1 <HOSTNAME.example.org> <HOSTNAME> localhost
172.20.31.155 <HOSTNAME.example.org> <HOSTNAME> localhost

init 6  #shutdown -r now  ile aynı
:) 

 Peki Solaris de durum nedir?


Aşağıdaki dosyalarda tüm eski hostname adını değiştiriyoruz.


/etc/nodename
/etc/hostname.*interface
/etc/inet/hosts
/etc/inet/ipnodes



Ve son olarakda /var/carsh isimli klasörün adını değiştiriyoruz.
 

and rename directory under /var/crash

# cd /var/crash
# mv oldname newname

then reboot the server.





23 Temmuz 2013 Salı

snmp istek logunu kapatmak


snmp istek logunu kapatmak


Merhabalar,
Bazı sunucularda sunucu üzerine gelen her snmp isteklerini logladığınızı görürsünüz. Buda /var/log/messages dosyasının dolamasına hatta syslog kullanıyorsanız gereğinden fazla log attığını görürsünüz. Peki bu info mesajları nasıl kapatabiliriz sorunusu aradım. Çözüm basit. Bulduğum sayfanın orjinalinide ekliyorum.

vi /etc/sysconfig/snmpd.options   

 #aşağıda yazana benzer bir ifade bulacaksınız.sadece başındaki -LS0-4d kısmını benzetin. burda 0 ile 4 arasındakileri logla diyor.

 ... OPTIONS="-LS0-4d -Lf /var/log/snmpd.log -p /var/run/snmpd.pid -a" ...
Son olarak
service snmpd restart

 

 

(RHEL) HOWTO stop snmpd spamming /var/log/messages

Jump to: navigation, search

Contents

Introduction

The default installation of net-snmp package comes with a default configuration which cause snmpd to log at debug level within /var/log/messages. When using monitoring systems which make snmp requests every 5 minutes, it spams totally /var/log/messages with messages like:
Command: content of /var/log/messages
# tail /var/log/messages
...
Jan 23 11:10:30 sv0143 snmpd[3968]: Received SNMP packet(s) from UDP: [192.168.0.2]:54579
Jan 23 11:10:30 sv0143 snmpd[3968]: Connection from UDP: [192.168.0.3]:50596
Jan 23 11:10:30 sv0143 snmpd[3968]: Received SNMP packet(s) from UDP: [192.168.0.3]:50596
Jan 23 11:10:30 sv0143 snmpd[3968]: Connection from UDP: [192.168.0.3]:50596
Jan 23 11:10:30 sv0143 snmpd[3968]: last message repeated 8 times
This annoying behavior can be corrected by reconfiguring the snmpd daemon to log within its own files and to log on only errors to /var/log/messages.

Reconfigure snmpd

To change the way snmpd is logging, it needs to be reconfigured as follow. As root, open the file /etc/sysconfig/snmpd.options using vi:
Command: editing /etc/sysconfig/snmpd.options
# vi /etc/sysconfig/snmpd.options
Add the following line:
Config File: /etc/sysconfig/snmpd.options
...
OPTIONS="-LS0-4d -Lf /var/log/snmpd.log -p /var/run/snmpd.pid -a" 
...
Which means:
  • -LS0-4d : logging only log levels from 0 to 4 to syslog. Those levels are described below:
    • 0 or ! for LOG_EMERG,
    • 1 or a for LOG_ALERT,
    • 2 or c for LOG_CRIT,
    • 3 or e for LOG_ERR,
    • 4 or w for LOG_WARNING,
    • 5 or n for LOG_NOTICE,
    • 6 or i for LOG_INFO,
    • 7 or d for LOG_DEBUG.
  • -Lf /var/log/snmpd.log: logging everything to /var/log/snmpd.log
Then restart the snmpd service using:
Command: restarting snmpd
# service snmpd restart

Enhance log rotation

To be sure that the new log file is rotated as wanted, check the file "/etc/logrotate.d/snmpd":
Command: editing /etc/sysconfig/snmpd.options
# vi /etc/logrotate.d/snmpd
In this case, the rotate 52 and compress will be added in the default configuration file to save an history of 52 weeks of compressed logs.
Config File: /etc/logrotate.d/snmpd
  /var/log/snmpd.log {
    rotate 52
    compress
    notifempty
    missingok
    postrotate
      /bin/kill -HUP `cat /var/run/snmpd.pid 2> /dev/null` 2> /dev/null || true
    endscript
  }
Note Note: Adding rotate 52 and compress to /etc/logrotate.d/snmpd is needed only if it was not defined globally in /etc/logrotate.conf

External Links

9 Temmuz 2013 Salı

Redhat OS yum icin centos deposu ekleme ve proxy üzerinden internete çıkarma

Centos deposu oluşturuyoruz:

vi /etc/yum.repos.d/centos.repo

[centos]
name=CentOS $releasever - $basearch
baseurl=http://ftp.heanet.ie/pub/centos/5/os/$basearch/
enabled=1
gpgcheck=0


cat /etc/redhat-release

6 ise

[centos]
name=CentOS $releasever - $basearch
baseurl=http://ftp.heanet.ie/pub/centos/6/os/$basearch/
enabled=1
gpgcheck=0



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

Yum için Proxy Ayarı:


vi /etc/yum.conf

[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=5
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=16&ref=http://bugs.centos.org/bug_report_page.php?category=yum
distroverpkg=centos-release
proxy=http://192.168.15.196:8080

#  This is the default, if you make this bigger yum won't see if the metadata
# is newer on the remote and so you'll "gain" the bandwidth of not having to
# download the new metadata and "pay" for it by yum not having correct
# information.
#  It is esp. important, to have correct metadata, for distributions like
# Fedora which don't keep old packages around. If you don't like this checking
# interupting your command line usage, it's much better to have something
# manually check the metadata once an hour (yum-updatesd will do this).
# metadata_expire=90m

# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d