لینوکس و شبکه

لینوکس و شبکه
طبقه بندی موضوعی
آخرین مطالب
  • ۹۹/۱۱/۱۳
    java

۱۳ مطلب در اسفند ۱۳۹۷ ثبت شده است

۲۶
اسفند

  • modprobe rt2800usb #Load module in kernel
  • modprobe -r rt2800usb #remove module from kernel
  • or  [rmmod rt2800usb] #remove module from kernel
  •  lsmod | grep rt2800 #check is load


Permanent load modules:

vim /etc/modules-load.d/rt2800usb.conf

  • rt2800usb #add this line
Check if systemd service loaded the module:

  • systemctl status systemd-modules-load.service

The output should look like this:


systemd-modules-load.service - Load Kernel Modules
  Loaded: loaded (/usr/lib/systemd/system/systemd-modules-load.service; static)
  Active: active (exited) since Wed, 03 Apr 2013 22:50:57 +0000; 46s ago
        Docs: man:systemd-modules-load.service(8)
              man:modules-load.d(5)
 Process: 260 ExecStart=/usr/lib/systemd/systemd-modules-load (code=exited, status=0/SUCCESS)

  if status=1/FAILURE

 journalctl -b

URL

  • behrooz mohamadi nsasab
۲۱
اسفند

SELinux stands for Security-Enhanced Linux. It is a way to improve the server security.


cat /etc/selinux/config 
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=enforcing
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

Show state:

  • $ sestatus       #show state
  • $ getenforce   #show state]

change[not permanent]:

  • $ setenforce [enforcing] or [permissive]      

Change Permanently:

vim /etc/selinux/config
SELINUX=enforcing


  • behrooz mohamadi nsasab
۲۰
اسفند

    DISM /Online /Enable-Feature /FeatureName:NetFx3 /All /LimitAccess /Source:d:\sources\sxs
    • d:\                  [the drive that the Windows Server ISO has mounted]
    • /All                [enable all parent features of the specified feature]
    • /LimitAccess [prevent DISM from contacting Windows Update/WSUS]
    • /Source          [specify the location of the files that are needed to restore the feature]

    • behrooz mohamadi nsasab
    ۲۰
    اسفند

    • yum install curlftpfs             [# if error: yum install fuse ]
    • $ftphost = [FTP host]
    • $mount = [Mounted to folder]
    • $user = [FTP username]
    • $pass = [FTP password]
    • curlftpfs $ftphost $mount -o user=$user:$pass,allow_other     [# Mount the CurlFtpFS]
    • fusermount -u $mount      [# Unmount the CurlFtpFS]
                            • behrooz mohamadi nsasab
                            ۱۹
                            اسفند

                            [CENTOS7]-[DEBIAN9]:

                            SHOW:

                            • $ hostname
                            • $ hostname -s #displayed the computer short name
                            • $ hostname -f #displays the computer FQDN in the network
                            • $ cat /etc/hostname
                            • Add new hostname in /etc/hosts

                            CHANGE:

                            • hostnamectl set-hostname NAME
                            • hostnamectl #Show change config



                            • behrooz mohamadi nsasab
                            ۱۴
                            اسفند

                             

                             

                            Show address:

                            ip: show commands:

                            • ip help                                    ---> #Display ip commands and arguments
                            • ip -4 a                                     ---> #Only show TCP/IP IPv4
                            • ip -6 a                                     ---> #Only show TCP/IP IPv6
                            • ip a list eth0                           ---> #Only show eth0 interface
                            • ip a show dev eth0                 ---> #Only show eth0 interface
                            • ip a show eth0                        ---> #Only show eth0 interface

                            addr: Display IP Addresses and property information(abbreviation of address)

                            • ip addr                                    ---> #Show information for all addresses
                            • ip addr help                            ---> #Display address commands and arguments
                            • ip addr show dev eth0            ---> #Display information only for device

                            link: Manage and display the state of all network interfaces

                            • ip link help                             ---> #Display link commands and arguments
                            • ip link ls up                            ---> #Only show running interfaces
                            • ip link show dev eth0             ---> #Display information only for device eth0
                            • ip link                                     ---> #Show information for all interfaces
                            • ip -s link                                 ---> #Display interface statistics
                            • ip -s -s link ls eth0                  ---> #get information about a particular network interface
                            • ip link set eth0 up                   ---> #Bring eth0 online
                            • ip link set eth0 down              ---> #Bring eth0 offline
                            • ip link set eth0 promisc on     ---> #Enable promiscuous mode for eth0
                             

                            Add or Delete Address:

                            • ip a add {ip_addr/mask} dev {interface}                             ---> #The syntax is as follows to add an IPv4/IPv6 address
                            • ip a del {ipv6_addr_OR_ipv4_addr} dev {interface}          ---> The syntax is as follows to remove an IPv4/IPv6 address:
                            • ip addr add 192.168.1.1/24 dev eth0                                   ---> #Add address 192.168.1.1 with netmask 24 to device eth0
                            • ip a add 192.168.1.200/255.255.255.0 dev eth0                   ---> To assign 192.168.1.200/255.255.255.0 to eth0
                            • ip a add 192.168.1.200/24 dev eth0                                     ---> To assign 192.168.1.200/255.255.255.0 to eth0
                            • ip addr del 192.168.1.1/24 dev eth0                                     ---> #Remove address 192.168.1.1/24 from device eth0
                            • ip a del 192.168.1.200/24 dev eth0                                       ---> To delete 192.168.1.200/24 from eth0

                             


                            neigh

                            neigh : ARP, Show neighbour objects; also known as the ARP table for IPv4

                            • ip neigh                                                                                    ---> #Display neighbour objects(Show neighbour objects; also known as the ARP table for IPv4)
                            • ip neigh help                                                                           ---> #Display neighbour commands and arguments
                            • ip neighbour                                                                            ---> #View the MAC address of the devices connected in your LAN
                            • ip neigh show dev eth0                                                            ---> #Show the ARP cache for device eth0
                            • ip neigh add 192.168.1.1 lladdr 1:2:3:4:5:6 dev eth0              ---> #Add address 192.168.1.1 with MAC 1:2:3:4:5:6 to eth0
                            • ip neigh del 192.168.1.1 dev eth0                                            ---> #Invalidate the entry for 192.168.1.1 on eth0
                            • ip neigh replace 192.168.1.1 lladdr 1:2:3:4:5:6 dev eth0         ---> #Replace the entry for address 192.168.1.1 to use MAC 1:2:3:4:5:6 on eth0
                            • ip n show                                                                                  ---> #Display neighbour/arp cache
                            • ip neigh show                                                                            ---> #Display neighbour/arp cache

                            Sample outputs (note: masked out some data with alphabets):

                            74.xx.yy.zz dev eth1 lladdr 00:30:48:yy:zz:ww REACHABLE

                            10.10.29.66 dev eth0 lladdr 00:30:48:c6:0a:d8 REACHABLE

                            74.ww.yyy.xxx dev eth1 lladdr 00:1a:30:yy:zz:ww REACHABLE

                            10.10.29.68 dev eth0 lladdr 00:30:48:33:bc:32 REACHABLE

                            74.fff.uu.cc dev eth1 lladdr 00:30:48:yy:zz:ww STALE

                            74.rr.ww.fff dev eth1 lladdr 00:30:48:yy:zz:ww DELAY

                            10.10.29.65 dev eth0 lladdr 00:1a:30:38:a8:00 REACHABLE

                            10.10.29.74 dev eth0 lladdr 00:30:48:8e:31:ac REACHABLE

                             

                            The last field show the the state of the “neighbour unreachability detection” machine for this entry:

                            STALE – The neighbour is valid, but is probably already unreachable, so the kernel will try to check it at the first transmission.

                            DELAY – A packet has been sent to the stale neighbour and the kernel is waiting for confirmation.

                            REACHABLE – The neighbour is valid and apparently reachable.

                             

                            Add a new ARP entry:

                            • ip neigh add {IP-HERE} lladdr {MAC/LLADDRESS} dev {DEVICE} nud {STATE}     ---> #syntax is
                            • ip neigh add 192.168.1.5 lladdr 00:1a:30:38:a8:00 dev eth0 nud perm         ---> #add a permanent ARP entry for the neighbour 192.168.1.5 on the device eth0:

                            neighbour state (nud):

                            permanent The neighbour entry is valid forever and can be only be removed administratively

                            noarp The neighbour entry is valid. No attempts to validate this entry will be made but it can be removed when its lifetime expires.

                            stale The neighbour entry is valid but suspicious. This option to ip neigh does not change the neighbour state if it was valid and the address is not changed by this command.

                            reachable The neighbour entry is valid until the reachability timeout expires.

                            Delete a ARP entry:

                            • ip neigh del {IPAddress} dev {DEVICE}               ---> #Syntax
                            • ip neigh del 192.168.1.5 dev eth1                            ---> #invalidate or delete an ARP entry for the neighbour 192.168.1.5 on the device eth0

                            Change ARP state:

                             

                            • ip neigh chg 192.168.1.100 dev eth1 nud reachable ---> #TO REACHABLE FOR THE NEIGHBOUR 192.168.1.100 ON THE DEVICE ETH1:


                             


                            Route

                            Route:Display and alter the routing table

                            • ip route                                                                      ---> #List all of the route entries in the kernel[routing tables]
                            • ip route show                                                            ---> #check the routing table information of the system
                            • ip route add default via 192.168.1.1 dev eth0          ---> #Add a default route (for all addresses) via the local gateway 192.168.1.1 that can be reached on device eth0
                            • ip route add 192.168.1.0/24 via 192.168.1.1            ---> #Add a route to 192.168.1.0/24 via the gateway at 192.168.1.1
                            • ip route add 192.168.1.0/24 dev eth0                       ---> #Add a route to 192.168.1.0/24 that can be reached on device eth0
                            • ip route del default via 192.168.1.1                          ---> #delete default gateway                                     
                            • ip route delete 192.168.1.0/24 via 192.168.1.1        ---> #Delete the route for 192.168.1.0/24 via the gateway at 192.168.1.1
                            • ip route replace 192.168.1.0/24 dev eth0                  ---> #Replace the defined route for 192.168.1.0/24 to use device eth0
                            • ip route get 192.168.1.5                                            ---> #Display the route taken for IP 192.168.1.5
                            • ip r                                                                             ---> #display the contents of the routing tables
                            • ip r list                                                                       ---> #display the contents of the routing tables
                            • ip route list                                                                ---> #display the contents of the routing tables
                            • ip r list 192.168.1.0/24                                              ---> #Display routing for 192.168.1.0/24

                            output:192.168.1.0/24 dev eth1  proto kernel  scope link  src 192.168.1.10

                             

                            Add a new route:

                            • ip route add {NETWORK/MASK} via {GATEWAYIP}               ---> #The syntax is
                            • ip route add {NETWORK/MASK} dev {DEVICE}                      ---> #The syntax is
                            • ip route add default {NETWORK/MASK} dev {DEVICE}          ---> #The syntax is
                            • ip route add default {NETWORK/MASK} via {GATEWAYIP}   ---> #The syntax is
                            • ip route add 192.168.1.0/24 via 192.168.1.254                               ---> #Add a plain route to network 192.168.1.0/24 via gateway 192.168.1.254
                            • ip route add 192.168.1.0/24 dev eth0                                              ---> #To route all traffic via 192.168.1.254 gateway connected via eth0 network interface

                            Delete a route:

                            • ip route del default                                                                           ---> #The syntax is[as follows to delete default gateway]
                            • ip route del 192.168.1.0/24 dev eth0                                                ---> #In this example, delete the route created in previous subsection:

                             


                            Disable [or] flush:

                            This flush or f command flushes neighbour/arp tables, by specifying some condition.

                            • ip -s -s n f {IPAddress}                   ---> #The syntax is
                            • ip -s -s n f 192.168.1.5                    ---> #In this example, flush neighbour/arp table
                            • ip -s -s n flush 192.168.1.5             ---> #In this example, flush neighbour/arp table
                            • ip -4 addr flush label "ppp*"           ---> #disable IP address on all the ppp (Point-to-Point) interfaces
                            • ip -4 addr flush label "eth*"            ---> #Here is another example for all the Ethernet interfaces
                            • ip -s -s a f to 192.168.2.0/24           --->  #Delete all the IP addresses from the private network (For example) 192.168.2.0/24

                            output:

                            2: eth0    inet 192.168.2.201/24 scope global secondary eth0

                            2: eth0    inet 192.168.2.200/24 scope global eth0

                            *** Round 1, deleting 2 addresses ***

                            *** Flush is complete after 1 round ***

                             


                            Txqueuelen

                            set the length of the transmit queue of the device using  ip command as follows:

                            • ip link set txqueuelen {NUMBER} dev {DEVICE}    --->   # Syntax
                            • ip link set txqueuelen 10000 dev eth0                           ---> #change the default txqueuelen from 1000 to 10000 for the eth0
                            • ip a list eth0

                             


                            MTU

                            For gigabit networks, set maximum transmission units (MTU) sizes (JumboFrames) for better network performance. The syntax is:
                            • ip link set mtu {NUMBER} dev {DEVICE}          ---> #Syntax
                            • ip link set eth0 mtu 9000                                         ---> #Set the MTU on eth0 to 9000
                            • ip link set mtu 9000 dev eth0                                   ---> #To change the MTU of the device eth0 to 9000
                            • ip a list eth0

                            Sample outputs:

                            2: eth0:  mtu 9000 qdisc pfifo_fast state UP qlen 1000

                                link/ether 00:08:9b:c4:30:30 brd ff:ff:ff:ff:ff:ff

                                inet 192.168.1.10/24 brd 192.168.1.255 scope global eth1

                                inet6 fe80::208:9bff:fec4:3030/64 scope link 

                                   valid_lft forever preferred_lft forever


                             


                            Broadcast:

                            Notice:By default, the ip command does not set any broadcast address unless explicitly requested

                            • ip addr add brd {ADDDRESS-HERE} dev {interface}          ---> #ADDING THE BROADCAST ADDRESS ON THE INTERFACE
                            • ip addr add broadcast {ADDDRESS-HERE} dev {interface} ---> #ADDING THE BROADCAST ADDRESS ON THE INTERFACE
                            • ip addr add broadcast 172.20.10.255 dev eth0                           ---> #add 172.20.10.255 as broadcast on eth0
                             

                            Multicast

                             

                            maddr: Manage and display multicast IP addresses

                            • ip maddr                                   ---> #Display multicast information for all devices
                            • ip maddr show dev eth0           ---> #Display multicast information for device eth0


                             

                            OLD and NEW Commands:

                            • arp -a                                                      -----> ip neigh
                            • arp -v                                                      -----> ip -s neigh
                            • arp -s 192.168.1.1 1:2:3:4:5:6                -----> ip neigh add 192.168.1.1 lladdr 1:2:3:4:5:6 dev eth1
                            • arp -i eth1 -d 192.168.1.1                       -----> ip neigh del 192.168.1.1 dev eth1
                            • ifconfig -a                                               -----> ip addr
                            • ifconfig eth0 down                                 -----> ip link set eth0 down
                            • ifconfig eth0 up                                      -----> ip link set eth0 up
                            • ifconfig eth0 192.168.1.1                       -----> ip addr add 192.168.1.1/24 dev eth0
                            • ifconfig eth0 netmask 255.255.255.0     -----> ip addr add 192.168.1.1/24 dev eth0
                            • ifconfig eth0 mtu 9000                           -----> ip link set eth0 mtu 9000
                            • ifconfig eth0:0 192.168.1.2                    -----> ip addr add 192.168.1.2/24 dev eth0
                            • netstat -g                                                 -----> ip maddr
                            • route                                                        -----> ip route
                            • route add -net 192.168.1.0 netmask 255.255.255.0 dev eth0              -----> ip route add 192.168.1.0/24 dev eth0
                            • route add default gw 192.168.1.1                                                        -----> ip route add default via 192.168.1.1
                             

                            Abbreviation:

                            Object Abbreviated form Purpose
                            • link(l)                               ----> Network device.
                            • address(a [or] addr)         ----> Protocol (IP or IPv6) address on a device.
                            • addrlabel(addrl)               ----> Label configuration for protocol address selection.
                            • neighbour(n [or] neigh)   ----> ARP or NDISC cache entry.
                            • route(r)                             ----> Routing table entry.
                            • rule(ru)                             ----> Rule in routing policy database.
                            • maddress(m [or] maddr)  ----> Multicast address.
                            • mroute(mr)                       ----> Multicast routing cache entry.
                            • tunnel(t)                            ----> Tunnel over IP.
                            • xfrm(x)                              ----> Framework for IPsec protocol.


                            URL1

                            • behrooz mohamadi nsasab
                            ۱۳
                            اسفند

                            1-show gateway(s):

                             

                            • route
                            • route -n
                            • ip route show
                            • ip route list

                             

                            Add route:

                             

                            • route add default gw {IP-ADDRESS(router IP)} {INTERFACE-NAME}
                            • route add default gw 192.168.1.254 eth0                            #Route all traffic via 192.168.1.254 gateway connected via eth0 network interface:
                            • ip route add 192.168.1.0/24 dev eth0                                        #to route all traffic via 192.168.1.254 gateway connected via eth0 network interface:
                            • ip route add 192.168.1.0/24 via 192.168.1.254                         #to route all traffic via 192.168.1.254 gateway connected via eth0 network interface:

                            Delete rout

                            • ip route del default via 192.168.122.1 dev eth0
                             

                            GUI(set configuration from ui)

                             

                            • redhat-config-network                            #if your are using Red Hat/CentOS/Fedora core Linux type this
                            • network-admin #If you are using other Linux distribution use this
                            • behrooz mohamadi nsasab
                            ۱۱
                            اسفند

                            سوکت‌های فعلی سرور که به هیچ فایلی از هارد وصل نشده است - پردازه‌های موجود در رم که ممکن است ویروس باشند

                            lsof +L1

                            • behrooz mohamadi nsasab
                            ۱۱
                            اسفند

                            نمایش همه ستون‌ها بجز ستون شماره یکم و ستون شماره دوم

                            cat FIle | awk '{$1=$2="";print$0}'

                            • behrooz mohamadi nsasab
                            ۰۴
                            اسفند

                            هر برنامه را که در این مسیر قرار بدهید در حین بالا آمدن آن کاربر به اجرا در خواهد آمد:

                            C:/users/AppData/Roaming/Microsoft/Windows/StartMenu/Programs/Startup


                            • behrooz mohamadi nsasab
                            ۰۴
                            اسفند

                            • نمایش اطلاعات سروری که در آن برنامه VirtualBox در حال اجرا می‌باشد

                            vboxmanage list hostinfo

                            • نمایش لیست وی ام های موجود در سرور

                            vboxmanage list vms

                            • نمایش لیست وی ام های موجود در سرور با اطلاعات کامل

                            vboxmanage list vms --long

                            • نمایش لیست وی ام های روشن در سرور

                            vboxmanage list runningvms 

                            • نمایش لیست وی ام های روشن در سرور با اطلاعات کامل

                            vboxmanage list runningvms --long

                            • نمایش تمامی اطلاعات یک وی ام برحسب نام یا uuid

                            vboxmanage showvminfo {UUID}

                            • روشن کردن یک وی ام در حالت headless

                            vboxheadless --startvm {UUID}

                            • توقف در وضعیت یا pause  یک وی ام

                            vboxmanage controlvm {UUID} savestate

                            • خاموش کردن یک وی ام

                            vboxmanage controlvm {UUID} acpipowerbutton

                            • behrooz mohamadi nsasab
                            ۰۴
                            اسفند

                            1. sudo mkdir -p  /media/repo1 /media/repo2  /media/repo3 /opt/DVD
                            2. sudo chown -R USERNAME:USERNAME /opt
                            3. sudo chmod -R 755 /opt
                            4. Copy All DVDs in Directory: /opt/DVD
                            5. sudo vim /etc/fstab:
                              1. /opt/dvd/debian-9.5.0-i386-DVD-1.iso /media/repo1 iso9660 defaults 0 0
                              2. /opt/dvd/debian-9.5.0-i386-DVD-2.iso /media/repo1 iso9660 defaults 0 0
                              3. /opt/dvd/debian-9.5.0-i386-DVD-3.iso /media/repo1 iso9660 defaults 0 0
                            6. sudo vim /etc/apt/sources.lists:
                              1. deb [trusted=yes] file:///media/repo1 stretch main contrib
                              2. deb [trusted=yes] file:///media/repo2 stretch main contrib
                              3. deb [trusted=yes] file:///media/repo3 stretch main contrib
                            • behrooz mohamadi nsasab
                            ۰۱
                            اسفند

                            tar:

                            archive: tar -cvf File.tar /directory

                            Extract: tar xf FileName.tar


                            Tar.gz:

                            Archive: tar czvf name.tar.gz files

                            Extract: tar xzvf name.tar.gz


                            tar.bz2:

                            Archive: tar -cvjSf folder.tar.bz2 folder

                            Extract: tar xjf File.tar.bz2 


                            bz2:

                            Archive: bzip2 -z filename

                            [or] Archive: bzip2  filename

                            Extract: bunzip2 FileName.bunzip2

                            [or] Extract: bzip2 -d filename.bz2


                            rar:

                            archive: 

                            Extract: unrar e FileName.rar

                             

                            gz:

                            Archive: gzip file

                            Extract: gzip -d file.gz

                            Extract: gunzip FileName.gz


                            zip:

                            archive: zip file.zip file

                            archive: zip -r Folder.zip folder

                            Extract: unzip File.zip


                            7zip:

                            Archive: 7z a File.7z File

                            Extract: 7z e File.7z

                            • behrooz mohamadi nsasab