ip kontrol etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
ip kontrol etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster

5 Haziran 2017 Pazartesi

Perl ile bir IP adresinin IPV4 uyumluluğunun kontrolü

Perl ile yazdığınız script içinde alttaki basit SUB ile bu kontrolü yapmanız mümkün.



sub checkIPformat {

    my ($ip) = @_;
    my $ipformat = 0;

    if($ip=~ m/^(\d\d?\d?)\.(\d\d?\d?)\.(\d\d?\d?)\.(\d\d?\d?)/ && ( $1 <= 255 && $2 <= 255 && $3 <= 255 && $4 <= 255 )) {  
        $ipformat=1; #1 is ok
    }
    return $ipformat;
}



24 Ekim 2016 Pazartesi

Java ile bir ip adres formatı kontrolü, IPV4

Selam,

Girilen bir ip adresinin doğru formatta ve IPV4 olduğunu tespit etmek için alttaki basit java class ı kullanılabilir.



package Fundementals;
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.UnknownHostException;
public class ipWorks {
public ipWorks(){
}
public boolean checkIP(String ip){
    boolean isIPv4;
      try {
        final InetAddress inet = InetAddress.getByName(ip);
        isIPv4 = inet.getHostAddress().equals(ip) && inet instanceof Inet4Address;
            } catch (final UnknownHostException e) {
               isIPv4 = false;
            }
    return isIPv4;
}
}