زکات علم

زَکاةُ العِلمِ أن تُعَلِّمَهُ عِبادَ اللّه‏ِ امام باقر (ع)
زکات علم

مطالبی در زمینه کامپیوتر و علاقه مندی های شخصی من مطالب این وبلاگ غالبا مطالبی ست که در جای جای اینترنت کتاب یا دانشته های شخصی خودم می باشد که به عنوان مرجعی برای رجوع دوباره در اینجا جمع آوری شده اند .
ehsunitd.ir personal website

پیوندها

۶ مطلب با موضوع «linux :: شل (کار با دستورات)» ثبت شده است

Linux Static IP
## Configure eth0
#
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
 
DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT=yes
HWADDR=A4:BA:DB:37:F1:04
TYPE=Ethernet
BOOTPROTO=static
NAME="System eth0"
UUID=5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03
IPADDR=192.168.1.44
NETMASK=255.255.255.0
  • ehsan gholami

How To Get Hardware Information On Linux Using dmidecode Command

by RAMESH NATARAJAN on NOVEMBER 10, 2008

[Mother Board]

dmidecode command reads the system DMI table to display hardware and BIOS information of the server. Apart from getting current configuration of the system, you can also get information about maximum supported configuration of the system using dmidecode. For example, dmidecode gives both the current RAM on the system and the maximum RAM supported by the system.

This article provides an overview of the dmidecode and few practical examples on how to use dmidecode command.

  • ehsan gholami

This article explains how to add iptables firewall rules using the “iptables -A” (append) command.

“-A” is for append. If it makes it easier for you to remember “-A” as add-rule (instead of append-rule), it is OK. But, keep in mind that “-A” adds the rule at the end of the chain.

Again, it is very important to remember that -A adds the rule at the end.

Typically the last rule will be to drop all packets. If you already have a rule to drop all packets, and if you try to use “-A” from the command-line to create new rule, you will end-up adding the new rule after the current “drop all packets” rule, which will make your new rule pretty much useless.

Once you’ve mastered the iptables, and when you are implementing it on production, you should use a shell script, where you use -A command to add all the rules. In that shell script, your last line should always be “drop all packets” rule. When you want to add any new rules, modify that shell script and add your new rules above the “drop all packets” rule.

Syntax:

iptables -A chain firewall-rule
  • -A chain – Specify the chain where the rule should be appended. For example, use INPUT chain for incoming packets, and OUTPUT for outgoing packets.
  • firewall-rule – Various parameters makes up the firewall rule.

If you don’t know what chain means, you better read about iptables fundamentals first.

  • ehsan gholami
 

توضیح

نام دستور

قرار دادن کاربر در وضعیت پیکربندی vlan

Vlan database

تعریف پارامترهای لازم vtp در وضعیت  vlan configuration mode

Vtp {domain domain-name|password password|pruning|v2-mode|{server|client|transparent}}

جهت نامگذاری و ایجاد یک vlan

Vlan vlan-id{name vlan-name}

جهت ایجاد ارتباط trunk بین سوئیچها

Switchport mode {access|dynamic{auto|desireable|trunk}}

جهت عبور پکتهای vlan های خاص از ارتباط trunk

Switchport trunk {{allowed vlan vlan-list}|native vlan vlan-id}|pruning vlan vlan-list}}

جهت تعریف اینترفیسهای موجود در سوئیچ بصورت ارتباط access

Switchport access vlan vlan-id

مشاهده وضعیت trunk

Show interfaces [interface-id|vlan vlan-id][switchport|trunk]

مشاهده اطلاعاتی در مورد vlan

Show vlan {brief|id vlan-id|name vlan-name|summary}

نمایش اطلاعاتی در مورد vlan

Show vlan [vlan]

مشاهده اطلاعاتی در مورد vtp و وضعیت پیکربندی آن

Show vtp status

مشاهده اطلاعاتی در مورد پیکربندی stp درون یک vlan خاص

Show spainig-tree vlan vlan-id

ستفاده از سوئیچ های سیسکو در سازمان های مختلف امری عادی شده است و معمولا سازمان های بزرگ ترجیح می دهند با تهیه سوئیچ های لایه دو و سه شبکه های کامپیوتری خود را ساختار یافته نموده و لایه بندی را در آن رعایت کنند. در این نوشتار به مبحث VLANمی پردازم.

VLAN چیست ؟
VLAN همانطور که از نام آن پیداست   شبکه LAN مجازی است که Broadcast Domain اصلی سوئیچ را که بصورت یک VLAN وجود دارد (VLAN1)  را به چندین Broadcast Domain دیگر می شکند. به دلیل اینکه سوئیچ ها قادر به برقراری ارتباط وLearn کردن از هم هستند لذا چندین پورت از سوئیچ دیگر می تواند عضو VLAN سوئیچ ما باشد بدون اینکه Broadcast را به سوئیچ ها یا VLAN های دیگر منتقل کند. معمولا VLAN برای شبکه های بزرگ با ترافیک بالا کاربرد دارد. قبل از اینکه به نحوه تنظیم VLAN بپردازم نکاتی را که باید قبل از این تنظیمات بدانید در چند بیان می کنم.
-    VLAN در واقع یک Broadcast Domain می باشد که توسط سوئیچ ایجاد می شود.
-    برای  تنظیم VLAN مدیر شبکه ابتدا باید VLAN را ایجاد کند و سپس پورت های سوئیچ را به آن مرتبط سازد.
-    همه سوئیچ های سیسکو دارای یک VLAN بصورت پیش فرض هستند.
-    در هر VLAN پورتی به نام Trunk تعریف می شود که قادر است ترافیک هاVLAN را به خارج یا داخل هدایت کند. این پورت از پروتکل ISL یا ۸۰۲٫۱۱q برای این کار استفاده می کند. با کلامی دیگر این پورت بین چندین VLAN مشترک است و ترافیک کلیه آن ها را به سوئیچ یا روتر انتقال می دهد

  • ehsan gholami

How do I change hostname under Linux operating system?

You need to use the hostname command. It is used to either set or display the current host or domain name of the system. The hostname is used by many of the networking programs (such as sendmail, Apache servers) to identify the machine.

Display Hostname

Type the following command:

hostname

Sample ouputs:

server.nixcraft.net.in

Step # 1: Change Hostname

You need to update two files:

  1. Linux Distribution specific file. Edit appropriate file as per your distribution as follows.
  2. /etc/hosts

Redhat / CentOS / Fedora: Change Hostname

Edit /etc/sysconfig/network, enter:

vi /etc/sysconfig/network

Set HOSTNAME=newhost.example.com, enter:

HOSTNAME=server2.nixcraft.com

Save and close the file. Type the following command:

hostname server2.nixcraft.com
hostname

Now, proceed to step # 2.

Debian / Ubuntu: Change Hostname

Edit, /etc/hostname file, enter:

vi /etc/hostname

Delete old name and add new name:

server2.nixcraft.com

Save and close the file. Type the following command:

hostname server2.nixcraft.com
hostname

Now, proceed to step # 2.

Slackware: Change Hostname

Edit /etc/HOSTNAME, enter:

vi /etc/HOSTNAME

Delete old name and add new one:

server2.nixcraft.com

Save and close the file. Type the following command:

hostname server2.nixcraft.com
hostname

Now, proceed to step # 2.

Suse / OpenSuse: Change Hostname

Edit /etc/HOSTNAME, enter:
Delete old name and add new one:

server2.nixcraft.com

Save and close the file. Type the following command:

hostname server2.nixcraft.com
hostname

Now, proceed to step # 2.

Step #2: Update /etc/hosts

Now, you need to edit /etc/hosts file, enteR:

vi /etc/hosts

Change all old hostname with newer one.

  • ehsan gholami

Linux is the free, open-source alternative to Microsoft Windows and Mac OS X. The operating system itself can be chopped down entirely to a raw text console, or it can utilize a desktop environment such as Gnome or KDE. This guide will explain how to assign an IP address on a Linux system through the use of a text console. This guide assumes that you know a little bit about Linux, and you know how networks, IP addresses, and DNS servers work.

Switch to Root

  1. 1
    If you are not already logged in as 'root' (the Linux counterpart of 'Administrator'), open a console program and type 'su' (without quote) and press enter.

  2. 2
    Note: *Ubuntu Linux distributions usually have the root password the same as the account created when the operating system was installed.

  3. 3
    Enter your root password when prompted, and press enter.

Debian / Ubuntu / Kubuntu

  1. 1
    Make a backup of your /etc/network/interfaces file by typing the following in the console: 'cp /etc/network/interfaces /etc/network/interfaces.backup'

  2. 2
    Type 'vi /etc/network/interfaces' and press enter. Press 'i' to enter into insert (editing) mode.

  3. 3
    Scroll down until you find your network interface card in the file (usually named eth0 for an ethernet connection, or wlan0 or wifi0 for a wifi connection).

  4. 4
    Change 'iface eth0 inet dhcp' to 'iface eth0 inet static'

  5. 5
    Add the following lines, substituting the IP address numbers with your desired configuration:


    address 192.168.0.10
    netmask 255.255.255.0
    network 192.168.0.0
    broadcast 192.168.0.255
    gateway 192.168.0.1
    dns-nameservers 216.10.119.241


  6. 6
    Save and exit from the file by pressing Escape (to enter vi command mode), then ":wq" and Enter

  7. 7
    Type 'ifdown eth0' and press enter.

  8. 8
    Type 'ifup eth0' and press enter.

Red Hat or Slackware

  1. 1
    The easiest method in Red Hat or Slackware is to type 'netconfig' in older versions or 'ifconfig/netstat' in new versions in a console as the root user. A text-based menu will guide you through its configuration settings.

  2. 2
    Write command in console nano /etc/sysconfig/network-scripts/ifcfg-eth0 Use tab to move between fields. Use the spacebar to uncheck or check checkboxes.

  3. 3
    When you have input the desired settings, close settings window.

  4. 4
    To make these settings take effect, type 'service network restart' in the console and press enter (this step is not necessary under Slackware, where the changes are immediate).

Note: There are numerous distributions based on Red Hat Linux (Fedora Core, CentOS, White Box, et cetera); many of them are likely to avail one the same method.

Any Linux system with kernel version 2.4 or newer

This method is slightly more difficult, it involves using the console, but it should work on all modern linux distributions. The tool used is called "ip" and is usually located in the "/sbin/" directory.

  1. 1
    First you need to determine the name of the network interface to be used. To list all network interfaces available run "/sbin/ip link". This should print a list of interface names, mac addresses and other info.

  2. 2
    Next you assign the IP address using the "addr" subcommand, like this: "/sbin/ip addr add 192.168.0.10/24 dev [INTERFACE_NAME]".

  3. 3
    The default gateway is added with the "route" subcommand, like this: "/sbin/ip route add default via [GATEWAY_ADDRESS]".

  4. 4
    The last thing is bringing the interface up with the "link" subcommand: "/sbin/ip link set [INTERFACE_NAME] up".

Assuming all given data was correct, network should be up and running. Unfortunately all these settings will be lost after a system restart, so if you want to restore them after startup, append all the above console commands to "/etc/rc.local" - a shell script which is run when the system is initialized.

Dynamic IP address (DHCP)

Dynamic addresses are obtained automatically and usually do not require any attention from the user. However there are several specific cases:

  1. 1
    If the network has not been available all the time while the system was starting, the internet connection may stay disabled even after fixing the network problems. To revive it instantly, run dhclient as root. This will set the dynamic address.

  2. 2
    The previous situation may happen if the network is accessed by separate hardware that starts at the same time as your machine. In some cases Linux boots faster than the network router and finds no network at startup. Find dhclient.conf (for instance, /etc/dhcp3/dhclient.cof for Debian) and add/correct the line reboot nn;, where nn is the delay for which the system must wait after booting, for the router to start.

  • ehsan gholami