Skip to content

linuxte komut satırından gerçek ip adresinin ögrenilmesi

linuxte shell script yazarken veya komut satırın dayken gerçek ip adresi (extarnal ip) bilgisine ihtiyaç duyabilirsiniz. bunun için farklı yöntemler vardır. temel olarak internette, size sizin bağlantı kurduğunuz ip adresini geri gönderecek bir servisin olmasıdır. bu servisler http, telnet, ssh veya başka bir servis olabilir. bunlardan bir kaçına hızlıca göz atalım

çok fazla bilinen bir çok sitenin bu işler için hazırlanmış api leri v.b. mevcuttur.

CURL ve WGET ile

fcicek@ubuntu:~$ curl bot.whatismyipaddress.com
78.168.67.209
fcicek@ubuntu:~$ wget http://smart-ip.net/myip -O - -q ; echo
78.168.67.209

fcicek@ubuntu:~$ curl http://smart-ip.net/myip
78.168.67.209
fcicek@ubuntu:~$ curl -s "http://api.hostip.info/get_html.php" 
Country: TURKEY (TR)
City: Karaman
IP: 78.168.67.209

fcicek@ubuntu:~$ curl -s "http://api.hostip.info/get_html.php" | grep 'IP:' | awk '{print $2}'
78.168.67.209
fcicek@ubuntu:~$ curl -s checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/< .*$//'  
78.168.67.209
fcicek@ubuntu:~$ curl ident.me
78.168.67.209

EXEC

fcicek@ubuntu:~$ exec 3<> /dev/tcp/icanhazip.com/80 && # open connection
>   echo 'GET /' >&3 &&                   # send http 0.9 request
>   read -u 3 && echo $REPLY &&           # read response
>   exec 3>&-                             # close fd
78.168.67.209

LWP-REQUEST

fcicek@ubuntu:~$ lwp-request -o text checkip.dyndns.org | awk '{ print $NF }'
78.168.67.209

DIG

fcicek@ubuntu:~$ dig +short myip.opendns.com @resolver1.opendns.com
78.168.67.209

fcicek@ubuntu:~$ alias wanip='dig +short myip.opendns.com @resolver1.opendns.com'
fcicek@ubuntu:~$ wanip
78.168.67.209
fcicek@ubuntu:~$ dig @ns1.google.com -t txt o-o.myaddr.l.google.com +short
"78.168.67.209"
fcicek@ubuntu:~$ dig -4 @ns1-1.akamaitech.net -t a whoami.akamai.net +short
78.168.67.209

NETCAT

fcicek@ubuntu:~$ netcat icanhazip.com 80 < << $'GET / HTTP/1.1\nHost: icanhazip.com\n\n' | tail -n1
78.168.67.209

linux – ethernet arayüzünün mac adresi

linuxte ethernet arayüzü ve ip konusunda bilgi almak için ifconfig komutu kullanılabilir.

gelişmiş komut yorumlayıcısı ile nokta atışıda yapabilirsiniz.. aşağıda adım adım bu durum ve çıktısı incelenebilir…

fcicek@ubuntu:~$ ifconfig -a 
eth0      Link encap:Ethernet  HWaddr 00:0c:29:68:00:00  
          inet addr:192.168.126.128  Bcast:192.168.126.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe68:0000/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:387259 errors:0 dropped:0 overruns:0 frame:0
          TX packets:225351 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:506148504 (506.1 MB)  TX bytes:22528155 (22.5 MB)
fcicek@ubuntu:~$ ifconfig -a | grep eth0 
eth0      Link encap:Ethernet  HWaddr 00:0c:29:68:00:00  
fcicek@ubuntu:~$ ifconfig -a | grep eth0 | awk '{print $5}'
00:0c:29:68:00:00
fcicek@ubuntu:~$ ifconfig -a | grep fe80 | awk '{print$3}'
fe80::20c:29ff:fe68:0000/64

Leopardboard

leopardboard

The Leopardboard is a full featured, ultra low cost, small form factor system that includes the DM355 processor board and a VGA camera board to provide VGA resolution capture. Linux distros supported

http://designsomething.org/leopardboard/default.aspx

 

Leopardboard 368
DM368 Highlights

  • High-Performance Digital Media System-on-Chip (DMSoC)
  • 432-MHz ARM926EJ-S Clock Rate
  • Two Video Image Co-processors (HDVICP, MJCP) Engines
  • Supports a Range of Encode, Decode and Video Quality Operations
  • Video Processing Subsystem
    • HW Face Detect Engine
    • Resize Engine from 1/16x to 8x
    • 16-Bit Parallel AFE (Analog Front-End) Interface Up to 120 MHz
    • 4:2:2 (8-/16-bit) Interface
    • 8-/16-bit YCC and Up to 24-Bit RGB888 Digital Output
    • 3 DACs for HD Analog Video Output
    • Hardware On-Screen Display (OSD)
  • Capable of 1080p 30fps H.264 video processing
  • Peripherals include EMAC, USB 2.0 OTG, DDR2/NAND, 5 SPIs, 2 UARTs, 2 MMC/SD/SDIO, Key Scan
  • 8 Different Boot Modes and Configurable Power-Saving Modes
  • Pin-to-pin and software compatible with DM365
  • Extended temperature (-40 °C – 85 °C) available
  • 3.3-V and 1.8-V I/O, 1.35-V Core
  • 338-Pin Ball Grid Array at 65nm Process Technology

Leopardboard 368 Capabilities

  • Including all Leopardboard 365 capabilities
  • 1080p video encoding & decoding

 

Leopardboard 365
DM365 Highlights

  • ARM926EJ-S Core: 216, 270, 300MHz
  • Enhanced Videp Processing Subsystem with Face Detection module
  • Video Processing Subsystem (VPSS)
  • HD Video Codecs: H.264, MPEG4, MJPEG, WMV9/VC1, MPEG2
  • Audio Codecs: MP3, WMA, AAC, Audio Echo Canceler (AEC)

Leopardboard 365 Capabilities

  • 10/100 Ethernet Port
  • USB 2.0 (can be used to power the board or as expansion)
  • JTAG and Serial ports for debugging
  • SD memory card support (also supports SDIO)
  • Stereo audio In/Out
  • Expansion connector for customer add-on feature
  • Composite TV/Component HD TV Output
  • LCD/DVI Interface
  • All camera boards for Leopard board can be used with Leopardboard 365
  • Face detection module is available
  • Royalty-free open source 2A functions

 

Leopardboard 355
DM355 Highlights

  • High-performance Digital Media System on Chip
  • ARM926EJ-S core
  • Video Processing Subsystem (VPSS)
  • DM355 combines high performance MPEG4 HD (720p) codecs and JPEG codecs up to 50M pixels per second, high quality, and low power consumption at a very low price point.
  • Seamless interface to most additional external devices required for a complete digital camera implementation

Leopardboard 355 Capabilities

  • 10/100 Ethernet Port
  • USB 2.0 (can be used to power the board or as expansion)
  • JTAG and Serial ports for debugging
  • SD memory card support (also supports SDIO)
  • Stereo audio In/Out
  • Expansion connector for customer add-on feature
  • Composite TV Output
  • LCD/DVI Interface
  • Support 720p at 30pfs
  • VGA Camera board (included)
  • Support wide range of video resolutions from VGA, 1.3M, 2M, 3M to 5 Mega-pixel CMOS Sensors (High resolution camera boards available seperately)
  • Royalty-free open source 2A functions

apache üzerinde birden fazla alan adı

örnekte site1.com ve site2.com alan adlarna sahip iki sitenin sunucumuz üzerinden yayın yapabilmesi için en basit konfigürasyonun nasıl yapılacağına bakacağız.

apache için öncelikle vhost_alias modülünü aktif edelim.

a2enmod vhost_alias

sitelerin barındırılacağı alanı disk üzerinde belirlememiz bu dizinleri oluşturarak gerekli yetkilendirmeyi yapmamız gerekiyor. alan adlarına ait dosyalar /var/www/sitex.com/public_html olarak barındıracağımızı düşünerek

sudo mkdir -p /var/www/site1.com/public_html
sudo mkdir -p /var/www/site2.com/public_html

sudo chown -R $USER:$USER /var/www/site1.com/public_html
sudo chown -R $USER:$USER /var/www/site2.com/public_html

sudo chmod -R 755 /var/www

gerekli dizinleri ve kullanıcı izinlerini vermiş olduk. şimdi test aşamasında kullanılmak üzere birer adet index.html dosyası oluşturalım. bu en kolay kısmı 🙂

nano /var/www/site1.com/public_html/index.html

  
    site1
  
  
    

site1.com sitemiz başarılı şekilde çalışmaktadır.

nano /var/www/site2.com/public_html/index.html

  
    site2
  
  
    

site2.com sitemiz başarılı şekilde çalışmaktadır.

gerekli index.html dosyasına oluşturduğumuza göre esas konfigürasyona gelebiliriz.

apachenin sites-available altındaki örnek default konfigürasyonuda sitemiz adına uygun olarak kopyalayalım.

sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/site1.com.conf

şimdi konfigürasyon dosyamız üzerinde gerekli değişikleri yapalım.

sudo nano /etc/apache2/sites-available/site1.com.conf

olması gereken minimum konfigürasyon aşagıdaki şekilde yapabiliriz.


    ServerAdmin admin@site1.com
    ServerName site1.com
    ServerAlias www.site1.com
    DocumentRoot /var/www/site1.com/public_html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

şimdi aynı işlemi diğer alanımız içinde yapalım…

sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/site2.com.conf

sudo nano /etc/apache2/sites-available/site2.com.conf

    ServerAdmin admin@site2.com
    ServerName site2.com
    ServerAlias www.site2.com
    DocumentRoot /var/www/site2.com/public_html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

şimdi sıra konfigürasyonlarımı aktif etmeye geldi.

sudo a2ensite site1.com.conf
sudo a2ensite site2.com.conf

eğer konfigürasyonumuzda hata yoksa komutları uyguladığımızda

Enabling site site1.com.
To activate the new configuration, you need to run:
  service apache2 reload

şeklinde bir bilgilendirme mesajı alacağız. yönergeyi uygulayarak apache suncumuzu yeniden başlatıyoruz.

sudo service apache2 restart

apache sunucumuzda hata vermez ise yapamız gereken bir tek nokta kaldı. oda hosts dosyasının güncellenmesi. bu işlem sonucunda /etc/apache2/sites-enabled dizini altına konfigürasyon dosyaları kopyalanmış olacaktır.

ferhat@cicek:/etc/apache2/sites-enabled# ls
000-default.conf  site1.com.conf  site2.com.conf
sudo nano /etc/hosts

hosts dosyasının içine alan adlarımıza ait gerekli satırları ekleyerek işlemimizi tamamlıyoruz.

127.0.0.1   localhost
127.0.1.1   ubuntu
127.0.0.1    site1.com
127.0.0.1   site2.com

yukarıda bahsedilen durumun en temek yöntemlerden biri olduğu tekrarlamakta fayda var. farklı modüller ve yapılarla bu işlem uygulanabilir…

Ayrılanlar için

Yollarımız burada ayrılıyor
Artık birbirimize iki yabancıyız
Her ne kadar acı olsa, ne kadar güç olsa
Her şeyi evet her şeyi unutmalıyız

Her kederin tesellisi bulunur, üzülme
İnsan ne kadar sevse unutabilir
Mevsimler, gelir geçer, yıllar geçer
Sen de unutursun bir gün gelir

Hiç yaşamamışçasına, hiç sevmemişçesine
Unutursun o günlerimizi, gecelerimizi
O günlerce gecelerce sevişmelerimizi

Her şeyi evet her şeyi unutabilirsin
Hatta bütün yazdıklarımı satır satır
Kalırsa, içinde bir derin sızı kalır

apache web server üzerinde kullanıcı dizin yapısını aktifleştirmek

Linux üzerinde Apache kullanıyor ve Linux üzerindeki kullanıcılarınıza bir alan açmak istiyorsanız bu işlem için en kolay yöntem userdir eklentisini aktifleştirmek olacaktır. Bunun ne kadar güvenli ve yönetilebilir olduğu tartışılır ancak en kolay yöntem olduğu kesin.

Gerekli modüllerin ve araçların yüklü olduğundan emin olunmalıdır. Aşağıdaki örnek debian tabanlı bir dağıtım da uygulanmıştır. Dağıtımlara göre dizin yapısı vb fark edebilir.

A2enmod ile userdir modülünü aktifleştirelim.

sudo a2enmod userdir

Modül aktifleştirdikten sonra Apache konfigürasyon dosyaları altında userdir modülü ile ilgili konfigürasyon dosyaları oluşturulmuştur. Bu konfigürasyon dosyası içinde gerekli düzenlemeleri yapılması gerekmektedir.

sudo nano /etc/apache2/mods-enabled/userdir.conf

Temel konfigürasyon dosyası aşağıdaki gibidir. Kullanıcıya açılan dizin ve erişim yetkisi ayarları doğru şekilde ayarlanmalıdır. Yoksa başımıza olmadık işler açabilir.


        UserDir public_html
        UserDir disabled root
 
        
		AllowOverride All
		Options MultiViews Indexes SymLinksIfOwnerMatch
		
			# Apache < = 2.2:
		        Order allow,deny
		        Allow from all
 
		        # Apache >= 2.4:
		        #Require all granted
		
		
			# Apache < = 2.2:
		        Order deny,allow
		        Deny from all
 
			# Apache >= 2.4:
			#Require all denied
		
        


Statik bir alan verecekseniz bu kadar yeterlidir. statik alanmı kaldı diyebilirsiniz. kullanıcıların php kullanmalarını istiyorsanız apachenin php modül konfigürasyon dosyasında gerekli düzenlemeyi yapmanız gerekecektir.

sudo nano /etc/apache2/mods-available/php5.conf

güvenlik gereği kullanıcı dizinlerinde server-side uygulamalar engellenmiş durumdadır. yapılması gereken “php_admin_value engine Off” satırını pasif ederek sunucu yeni konfigürasyonu ile başlatmaktır.


    
	SetHandler application/x-httpd-php
    
    
	SetHandler application/x-httpd-php-source
    
    # To re-enable php in user directories comment the following lines
    # (from  to .) Do NOT set it to On as it
    # prevents .htaccess files from disabling it.
    
        
    #        php_admin_value engine Off
        
    


sunucumuzu yeniden başlattıktan sonra mevcut kullanıcılar için public_html dizinini oluşturmayı unutmayalım..

sudo service apache2 restart
mkdir /home/$USER/public_html

webmin yönetici şifresi resetlemek

bir hata yaptınız ubuntu üzerine webmin yüklediniz ve yönetici şifresi ile sorun yaşıyorsanız aşağıdaki şekilde yönetici şifrenizi resetleyebilirsiniz.

farklı bir dağıtım kullanıyorsanız dizin yapılarında ufak farklılıklar olabilir…

# /usr/share/webmin/changepass.pl /etc/webmin root "yeni şifreniz"

Sonrasında

https://localhost:10000/

Adresinden yeni sifrenizle erişebilirsiniz

huawei cihazlarda default konfigürasyon

huawei cihazlarda cli da “display this” komutu ile bulunduğunuz dizindeki mevcut konfigürasyonu görebilirsiniz. ancak default olarak yapılandırılmış konfigürasyon mevcuttur. bunu görmek için display this” komutuna include-default parametresi ilave edilerek kullanılabilir.

aşağıdaki örnekte bir interfacedeki default konfigürasyon görülmektedir.

[ferhatcicek-Ethernet0/0/1]display this include-default 
#
interface Ethernet0/0/1
 portswitch
 undo shutdown
 enable snmp trap updown
 undo set flow-stat interval
 undo qinq vlan-translation enable
 undo mac-address learning disable
 port priority 0
 port link-type hybrid
 port hybrid pvid vlan 1
 port hybrid untagged vlan 1
 qinq protocol 8100
 undo loopback-detect enable
 stp enable
 undo stp config-digest-snoop
 undo stp no-agreement-check
 undo stp root-protection
 undo stp loop-protection
 stp transmit-limit 147
 stp point-to-point auto
 stp compliance auto
 stp instance 0 port priority 128
 undo port mux-vlan enable
 undo mac-vlan enable
 undo ip-subnet-vlan enable
 undo rmon-statistics
 undo smart-link flush receive
 undo smart-link vll-notify enable
 undo ntdp enable
 undo ndp enable
 bpdu enable
 undo portal local-server enable
 undo dot1x enable
 dot1x max-user 256
 dot1x port-control auto
 dot1x port-method mac
 undo dot1x reauthenticate
 undo authentication critical eapol-success
 authentication max-reauth-req 20
 undo mac-authen
 mac-authen max-user 256
 mac-authen reauthenticate
 undo authentication open
 undo port-auto-sleep enable
 undo port-security enable
 undo qinq vlan-translation miss-drop
 undo port discard tagged-packet
 mac-learning priority 0
 undo mac-address flapping trigger error-down
 undo mac-address flapping trigger quit-vlan
 jumboframe enable 9216
 undo set flow-statistics include-interframe
 trap-threshold input-rate 100 resume-rate 100
 trap-threshold output-rate 100 resume-rate 100
 log-threshold input-rate 100 resume-rate 100
 log-threshold output-rate 100 resume-rate 100
 trap-threshold error-statistics 3 interval 10
 carrier up-hold-time 2000
 carrier down-hold-time 0
 undo port link-flap protection enable
 qos wrr
 qos queue 0 wrr weight 1
 qos queue 1 wrr weight 1
 qos queue 2 wrr weight 1
 qos queue 3 wrr weight 1
 qos queue 4 wrr weight 1
 qos queue 5 wrr weight 1
 qos queue 6 wrr weight 1
 qos queue 7 wrr weight 1
 trust 8021p outer
 undo dei enable
 qos phb marking enable
 undo arp anti-attack rate-limit enable
 undo arp-miss anti-attack rate-limit enable
 undo arp anti-attack check user-bind enable
 undo ip source check user-bind enable
 unicast-suppression 100
 multicast-suppression 100
 broadcast-suppression 100
 storm-control interval 5
 port type nni
 undo nd snooping enable
 undo nd snooping trusted
 undo dhcpv6 remote-id insert enable
 undo dhcpv6 remote-id rebuild enable

Back To Top