meta data for this page
  •  

Különbségek

A kiválasztott változat és az aktuális verzió közötti különbségek a következők.

Összehasonlító nézet linkje

Előző változat mindkét oldalonElőző változat
Következő változat
Előző változat
linux:network [2020/01/14 16:17] adminlinux:network [2024/03/21 16:49] (aktuális) admin
Sor 1: Sor 1:
 ====== Hálózati okosságok ====== ====== Hálózati okosságok ======
 +
 +==== File letöltő BASH-sel ====
 +
 +<file>
 +#!/bin/bash
 +# Usage: ./download_file 'https://www.baeldung.com/java-weekly-495' 'java_weekly_495.html'
 +raw_download() {
 +    wPROTO="${1%://*}"
 +    af="${1#*://}"
 +    wBASE="${af%%/*}"
 +    wSUB="${af#*/}"
 +
 +    HTTP_REQUEST="$({
 +        echo -en 'GET /'"${wSUB}"' HTTP/1.1\r\n'
 +        echo -en 'Host: '"${wBASE}"'\r\n'
 +        echo -en 'Connection: close\r\n\r\n'
 +    })"
 +
 +    if [[ "${wPROTO,,}" = 'https' ]] ; then
 +        echo "${HTTP_REQUEST}" | openssl s_client -quiet -connect ${wBASE}:443
 +    else
 +        exec {NFD}<>"/dev/tcp/${wBASE}/80"
 +        echo "${HTTP_REQUEST}" >&"${NFD}"
 +        while read -u "${NFD}" lz; do
 +            echo "${lz}"
 +        done
 +        exec {wFD}>&-
 +    fi
 +}
 +
 +main() {
 +    raw="$(raw_download "${1}" 2>errorlog.txt)"
 +    echo "${raw#*$'\r\n\r\n'}" > "${2}"
 +}
 +
 +main "${@}"
 +</file>
 +
 +==== Rsync ====
 +
 +To create a new directory at the destination and back up your files there, add a trailing slash (/) at the end of the destination path. If you add the trailing slash to the source, then the source directory will not be created at the destination. Rsync only transfers its content in that case.
 +Kulcs használat:
 +
 +  rsync e "ssh -i $HOME/.ssh/somekey"
 +
 +==== Firewalld ====
 +
 +[[https://linuxconfig.org/introduction-to-firewalld-and-firewall-cmd-command-on-linux]]
 +
 +==== Port tesztelés BASH-sel ====
 +
 +/dev/tcp/host/port: (If host is a valid hostname or Internet address, and port is an integer port number or service name, bash attempts to open a TCP connection to the corresponding socket.)
 +
 +/dev/udp/host/port: (If host is a valid hostname or Internet address, and port is an integer port number or service name, bash attempts to open a UDP connection to the corresponding socket.)
 +
 +So you could use something like this:
 +
 +  xenon-lornix:~> cat < /dev/tcp/127.0.0.1/22
 +  SSH-2.0-OpenSSH_6.2p2 Debian-6
 +  ^C pressed here
 +
 +Szkriptbe:
 +
 +  (echo > /dev/tcp/localhost/1500) >/dev/null 2>&1 && echo "It's up" || echo "It's down"
 +  timeout 1s bash -c "true <>/dev/tcp/localhost/443" >/dev/null 2>&1 && echo "It's up" || echo "It's down"
 +  while [[ -n $((echo > /dev/tcp/$TCPS/$TCPP) 2>&1 > /dev/null) ]]; do echo varunk; sleep 10; done
 +
 +nc-vel:
 +
 +  nc -zv hoszt port
 +
 +Windows PowerShell:
 +
 +  Test-NetConnection -ComputerName myserver.com -Port 443
 +==== NFS okosságok ====
 +
 +Portcheck ([[http://bluefinch-nl.blogspot.com/2014/04/mounting-nfs-shares-from-linux-server.html|link]])
  
 ==== SSH okosságok ==== ==== SSH okosságok ====
 +
 +[[linux:ssh-exit-codes.sh|SSH exit kódok]]
  
 === SSH-n másolás köztes állomáson át === === SSH-n másolás köztes állomáson át ===
Sor 56: Sor 135:
       expect eof"       expect eof"
 </file> </file>
 +
 +Az ssh parancs ne hajtsa végre a hibás RC kódú parancs utáni többi parancsot: set -e
  
 === SFTP leírások === === SFTP leírások ===
Sor 84: Sor 165:
   ftp> bin   ftp> bin
   ftp> put "| dd if=/dev/zero bs=32k count=10000 " /dev/null   ftp> put "| dd if=/dev/zero bs=32k count=10000 " /dev/null
 +
 +=== Hálózat felderítés ===
 +
 +  nmap -sP hoszt/hálózat
 +
 === Port scanning === === Port scanning ===
  
Sor 92: Sor 178:
 <file> <file>
 #!/bin/bash #!/bin/bash
-VLAN_SNIFF_TIME=5 
 SEARCH=${1-.} SEARCH=${1-.}
 +VLAN_SNIFF_TIME=10
 #ETH #ETH
 echo "Port#Address#Speed#State#VLANs#Slaves" | awk -F'#' '{printf "%-25s | %-17s | %10s | %-10s | %-13s | %-15s\n",$1,$2,$3,$4,$5,$6}' echo "Port#Address#Speed#State#VLANs#Slaves" | awk -F'#' '{printf "%-25s | %-17s | %10s | %-10s | %-13s | %-15s\n",$1,$2,$3,$4,$5,$6}'
Sor 101: Sor 187:
         SPEED=$(ethtool $ETH 2>/dev/null | awk -F': ' '/Speed/{print $2}' | sed 's/^[0-9]*/& /')         SPEED=$(ethtool $ETH 2>/dev/null | awk -F': ' '/Speed/{print $2}' | sed 's/^[0-9]*/& /')
         MAC=$(ip addr | grep -A1 "[^@]$ETH:"  | grep -o '\([0-9abcdef]\{2\}:\)\{5\}[0-9abcdef]\{2\}' | awk '{print $1}' | grep -v 'ff:ff:ff:ff:ff:ff')         MAC=$(ip addr | grep -A1 "[^@]$ETH:"  | grep -o '\([0-9abcdef]\{2\}:\)\{5\}[0-9abcdef]\{2\}' | awk '{print $1}' | grep -v 'ff:ff:ff:ff:ff:ff')
-        VLANS=$(timeout $VLAN_SNIFF_TIME tcpdump -c 1000 -nni $ETH -e vlan 2>/dev/null | grep -o 'vlan [0-9]*' | sort | uniq | awk '/vlan/{print $2}' | tr '\n' ' ')+        VLANS=$(timeout ${VLAN_SNIFF_TIMEtcpdump -c 1000 -nni $ETH -e vlan 2>/dev/null | grep -o 'vlan [0-9]*' | sort | uniq | awk '/vlan/{print $2}' | tr '\n' ' ')
         SLAVES=""         SLAVES=""
-        if [[ $(grep -c "Slave.*$ETH" /proc/net/bonding/* 2>/dev/null) -gt 0 ]]; then +        for BOND in `ls /proc/net/bonding/* 2>/dev/null`; do 
-                MAC=$(grep -A5 "Slave.*$ETH" /proc/net/bonding/* 2>/dev/null | tail -n1 | awk '{print $4}') +            if [[ $(grep -c "Slave.*$ETH" $BOND) -gt 0 ]]; then 
-        fi+                MAC=$(grep -A5 "Slave.*$ETH" $BOND | tail -n1 | grep -oP '(?<=addr: ).*$') 
 +            fi 
 +        done
         if [[ $ETH =~ ^bond ]]; then         if [[ $ETH =~ ^bond ]]; then
-                SLAVES=$(awk '/^Slave Interface/{print $3}' /proc/net/bonding/$ETH 2>/dev/null | tr '\n' ' ')+                SLAVES=$(awk '/^Slave Interface/{print $3}' /proc/net/bonding/$ETH | tr '\n' ' ')
         fi         fi
         echo "$ETH#$MAC#$SPEED#$STATE#$VLANS#$SLAVES" | awk -F'#' '{printf "%-25s | %-17s | %10s | %-10s | %-13s | %-15s\n",$1,$2,$3,$4,$5,$6}'         echo "$ETH#$MAC#$SPEED#$STATE#$VLANS#$SLAVES" | awk -F'#' '{printf "%-25s | %-17s | %10s | %-10s | %-13s | %-15s\n",$1,$2,$3,$4,$5,$6}'
Sor 133: Sor 221:
 === VLAN tag-ek az interfész csomagjain === === VLAN tag-ek az interfész csomagjain ===
  
-  tcpdump -c 1000 -nni bond0 -e vlan | grep -o 'vlan [0-9]*' | sort | uniq+  tcpdump -c 1000 -nni bond0 -e vlan | grep -o 'vlan [0-9]*' | sed 's/^.*$/Found & tagged pockets/' | sort | uniq
  
 [[http://www.yolinux.com/TUTORIALS/LinuxTutorialNetworking.html#MULTICAST]] [[http://www.yolinux.com/TUTORIALS/LinuxTutorialNetworking.html#MULTICAST]]
 +
 +[[https://www.aelius.com/njh/subnet_sheet.html|Subnet Mask Cheat Sheet]]