<?xml version="1.0" encoding="UTF-8" standalone="no"?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0"><channel><title>e-maknyus</title><description></description><managingEditor>noreply@blogger.com (tamvan &amp;amp; verani)</managingEditor><pubDate>Sat, 7 Sep 2024 12:52:28 -0700</pubDate><generator>Blogger http://www.blogger.com</generator><openSearch:totalResults xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/">360</openSearch:totalResults><openSearch:startIndex xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/">1</openSearch:startIndex><openSearch:itemsPerPage xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/">25</openSearch:itemsPerPage><link>http://emaknyus.blogspot.com/</link><language>en-us</language><itunes:explicit>no</itunes:explicit><itunes:keywords>streaming,audio,radio,digital,music,flash,aacplus,mp4</itunes:keywords><itunes:summary>opensource community</itunes:summary><itunes:subtitle>Emaknyus opensource community</itunes:subtitle><itunes:category text="Technology"><itunes:category text="Software How-To"/></itunes:category><itunes:owner><itunes:email>emaknyus@gmail.com</itunes:email></itunes:owner><item><title>Lecture #21 - Asynchronous Transfer Mode (ATM)</title><link>http://emaknyus.blogspot.com/2011/09/lecture-21-asynchronous-transfer-mode.html</link><category>adsl</category><category>atm</category><category>lecture</category><pubDate>Fri, 16 Sep 2011 14:22:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3787219161379371544.post-2462111922635220966</guid><description>&lt;br /&gt;
&lt;div class="slide"&gt;
&lt;strong&gt;ATM&lt;/strong&gt;&amp;nbsp;is a major traffic carrier used by telecommunication companies. ATM is also the core networking technology used to aggregate and connect ADSL tail circuits to ISPs. ATM provides for virtual circuits and can guarantee Quality of Service (QoS).&lt;br /&gt;
Some of the key concepts involved in ATM include:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;The basic unit of transmission is the&amp;nbsp;&lt;strong&gt;cell&lt;/strong&gt;. A cell is 53 bytes in length - 5 bytes of&amp;nbsp;&lt;strong&gt;header&lt;/strong&gt;&amp;nbsp;and 48 bytes of&amp;nbsp;&lt;strong&gt;payload&lt;/strong&gt;. These small, fixed-format cells can be&amp;nbsp;&lt;strong&gt;switched&lt;/strong&gt;&amp;nbsp;very quickly.&lt;/li&gt;
&lt;li&gt;ATM networks are based on connection-oriented&amp;nbsp;&lt;strong&gt;cell relay&lt;/strong&gt;&amp;nbsp;- cells are multiplexed onto higher bitrate channels, but there is no timing relationship between individual cells within a particular connection. Cells may be dropped but are never delivered out&amp;nbsp;of&amp;nbsp;order.&lt;/li&gt;
&lt;li&gt;The telecommunications industry uses ATM as a basis for providing converged services, allowing for the seamless integration of voice (telephony), audio, video-on-demand, video conferencing, video broadcast and data, on the one network.&lt;/li&gt;
&lt;li&gt;ATM is&amp;nbsp;&lt;strong&gt;complex.&lt;/strong&gt;&amp;nbsp;Even the telcos admit it has many unsolved problems.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class="slide"&gt;
&lt;h2&gt;
ATM Background&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Designed in early 1990s, when both bandwidth and networking equipment was relatively expensive, and voice and data convergence was a hot topic in the industry.&lt;/li&gt;
&lt;li&gt;A technology evolved more from the telecommunications industry than the computer/data industry.&lt;/li&gt;
&lt;li&gt;Designed for high-performance mixed network traffic (voice, data, video, and future media applications).&lt;/li&gt;
&lt;li&gt;Designed for bursty traffic.&lt;/li&gt;
&lt;li&gt;Designed to replace all existing analog and digital communication backbone systems.&lt;/li&gt;
&lt;li&gt;A relatively expensive networking technology, mainly used among tier 1 and tier 2 telcos.&lt;/li&gt;
&lt;li&gt;Gigabit Ethernet (a much cheaper technology) has replaced ATM on many networks. ATM is Less popular now.&lt;/li&gt;
&lt;li&gt;Gigabit Ethernet is a natural upgrade path for Fast Ethernet.&lt;/li&gt;
&lt;li&gt;ATM offers QoS, but QoS issues can simply be overcome by providing a bigger pipe?&lt;/li&gt;
&lt;/ul&gt;
"Arguably, ATM is unnecessary if bandwidth is cheap and plentiful, and there is no congestion in the network."&lt;br /&gt;
"Experience has also shown that over-provisioning bandwidth does not resolve all QoS issues. Hence Gigabit Ethernet is not expected to replace ATM at this time."&lt;br /&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div class="slide"&gt;
&lt;h2&gt;
ATM Features&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Cell based switching technique&lt;/li&gt;
&lt;li&gt;Fixed-size cells (53-Bytes) - small cells&lt;/li&gt;
&lt;li&gt;Asynchronous time-division multiplexing (Asyn TDM)&lt;/li&gt;
&lt;li&gt;Connection oriented&lt;/li&gt;
&lt;li&gt;Virtual Circuit (VPI VCI)&lt;/li&gt;
&lt;li&gt;QoS as part of the technology&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class="slide"&gt;
&lt;h2&gt;
ATM Speed&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Originally designed to work over Synchronous Optical Networking (SONET)&lt;/li&gt;
&lt;li&gt;Expresses in OC (Optical Carrier) levels.&lt;/li&gt;
&lt;li&gt;OC-3: 155 Mbps (3 x 51.84 Mbps)&lt;/li&gt;
&lt;li&gt;OC-12: 622 Mbps&lt;/li&gt;
&lt;li&gt;OC-192: upto 10Gbps bit rate&lt;/li&gt;
&lt;li&gt;In early 1990s, 155 Mbps was considered very fast.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class="slide"&gt;
&lt;h2&gt;
ATM - Circuit Switching or Packet Switching&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;ATM is a packet switching technology where fixed size small packets are switched efficiently.&lt;/li&gt;
&lt;li&gt;ATM uses virtual circuits - provides a reliable dedicated path during the whole session of transmission, offering the advantage of circuit switching, i.e. reliable connection, and can guarantee a specific QoS.&lt;/li&gt;
&lt;li&gt;ATDM - how ATM does multiplexing.&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;img alt="atm_adsl" height="332" src="http://ironbark.bendigo.latrobe.edu.au/subjects/DC/lectures/21/atm_atdm.png" width="636" /&gt;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div class="slide"&gt;
&lt;h2&gt;
Advantages&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Fast switching of small cells&lt;/li&gt;
&lt;li&gt;Better utilisation than circuit switching&lt;/li&gt;
&lt;li&gt;No fragmentation problem&lt;/li&gt;
&lt;li&gt;Reduce jitter (variance in delays)&lt;/li&gt;
&lt;li&gt;Easier to allocate bandwidths and delays to VCs&lt;/li&gt;
&lt;li&gt;Easier to implement priorities to traffic&lt;/li&gt;
&lt;li&gt;Enables traffic management and congestion control&lt;/li&gt;
&lt;li&gt;Suitable for time-critical information such as voice or video&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
Disadvantages&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Extra overhead as IP datagrams are segmented into small cells&lt;/li&gt;
&lt;li&gt;Expensive technology&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class="slide"&gt;
&lt;h2&gt;
ATM Virtual Channels&lt;/h2&gt;
ATM is connection-oriented and switching is based on the idea of a&amp;nbsp;&lt;strong&gt;virtual channel&lt;/strong&gt;&amp;nbsp;or VC. A virtual channel is set up between a pair of hosts connected to a network of switches:&lt;br /&gt;
&lt;blockquote&gt;
&lt;img alt="ATM Virtual Channel" height="237" src="http://ironbark.bendigo.latrobe.edu.au/subjects/DC/lectures/21/atm-virtual-channel.png" width="493" /&gt;&lt;/blockquote&gt;
The existence of a VC is based on entries in&amp;nbsp;&lt;strong&gt;routing tables&lt;/strong&gt;&amp;nbsp;in each of the switches (which are really&amp;nbsp;&lt;strong&gt;routers&lt;/strong&gt;), set up at VC&amp;nbsp;&lt;strong&gt;establishment&lt;/strong&gt;&amp;nbsp;time. Each switch compares its table entries to a field in the cell header to decide where the cell is to be sent.&lt;/div&gt;
&lt;div class="slide"&gt;
&lt;h2&gt;
Permanent and Switched Virtual Circuits&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Permanent Virtual Circuit (PVC): dedicated virtual circuit established for continuous use, and no need for repeated call setup and clearing. Usually preconfigured by a service provider. PVC is similar to a leased line.&lt;/li&gt;
&lt;li&gt;Switched Virtual Circuit (SVC): setup on a per-call basis and disconnected when the call is terminated. SVC is dynamically established on demand and is torn down when transmission is finished. SVC is similar to a normal PSTN phone line.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
ATM - connection-oriented protocol&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Connection-oriented establishes a session, then delivers a stream of data in the same order as it was sent.&lt;/li&gt;
&lt;li&gt;Can be a circuit switched connection, or a virtual circuit switched connection in a packet switched network like ATM.&lt;/li&gt;
&lt;li&gt;Connection-oriented protocols are not necessarily reliable protocols. ATM is an example of a connection-oriented, unreliable protocol.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class="slide"&gt;
&lt;h2&gt;
ATM Virtual Channel Setup&lt;/h2&gt;
All cells relating to a connection (call, circuit) follow the same path through the network. During call setup, a separate&amp;nbsp;&lt;strong&gt;Protocol Connection Identifier&lt;/strong&gt;&amp;nbsp;is assigned to the connection on each link through the network.&lt;br /&gt;
The numeric value of the PCI identifier has only local significance at each link, and changes from one link to another as cells relating to a particular call (or connection) pass through the network.&lt;br /&gt;
Associated with each incoming link/port at a switch is a routing table that contains, for each incoming PCI, the corresponding outgoing link/port and the new PCI to be used.&lt;br /&gt;
The PCI is made up of two components: the&amp;nbsp;&lt;strong&gt;Virtual Path Identifier&lt;/strong&gt;&amp;nbsp;(VPI) and the&amp;nbsp;&lt;strong&gt;Virtual Channel Identifier&lt;/strong&gt;&amp;nbsp;(VCI). Routing can be on the basis of the value of either, or both, of these subfields.&lt;br /&gt;
The VPI can be used where multiple connections are set up between the same pair of hosts. The VCI field is used where connections are not between the same pair of hosts.&lt;/div&gt;
&lt;div class="slide"&gt;
&lt;h2&gt;
ATM VPI/VCI&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Transmission Path (TP): Physical connection, usually fibers.&lt;/li&gt;
&lt;li&gt;Virtual Path (VP): Connection between two ATM switches. VPI identifies the cell's next VP to pass through.&lt;/li&gt;
&lt;li&gt;VC: Virtual Channel/Circuit (VC): VC must first established before any data transfer. VCI identifies the cell's next VC inside the VP.&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;img alt="atm_adsl" height="192" src="http://ironbark.bendigo.latrobe.edu.au/subjects/DC/lectures/21/atm_vpi_vci.png" width="687" /&gt;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div class="slide"&gt;
&lt;h2&gt;
ATM and ADSL&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;DSL is an access method for an ATM network, allowing a DSL tail to connect to many ISPs through a wholesale ATM network (e.g. Telstra wholesale).&lt;/li&gt;
&lt;li&gt;ADSL uses ATM as an intermediate layer between the physical layer and a layer 2 protocol like PPP.&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;img alt="atm_adsl" height="346" src="http://ironbark.bendigo.latrobe.edu.au/subjects/DC/lectures/21/atm_adsl.png" width="700" /&gt;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div class="slide"&gt;
&lt;h2&gt;
High Level View of an ADSL / ATM Network&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;ADSL access tails connecting to DSLAMs (Digital Subscriber Line Access Multiplexer).&lt;/li&gt;
&lt;li&gt;DSLAMs connecting to a Tier 1 telco's ATM backbone network.&lt;/li&gt;
&lt;li&gt;Tier 1 telco aggregates all the ADSL tails and distributes the traffic to the smaller providers.&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;img alt="atm_adsl" height="326" src="http://ironbark.bendigo.latrobe.edu.au/subjects/DC/lectures/21/atm_vpvc.png" width="609" /&gt;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div class="slide"&gt;
&lt;h2&gt;
ATM Switching&lt;/h2&gt;
ATM routes a cell using both the VPI and the VCI.&lt;br /&gt;
&lt;blockquote&gt;
&lt;img alt="atm_adsl" height="277" src="http://ironbark.bendigo.latrobe.edu.au/subjects/DC/lectures/21/atm_switching.png" width="653" /&gt;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div class="slide"&gt;
&lt;h2&gt;
ATM Switches&lt;/h2&gt;
ATM switches are typically built of a network of&amp;nbsp;&lt;strong&gt;Banyan&lt;/strong&gt;&amp;nbsp;switches.&lt;br /&gt;
Each element of the switch can either pass a cell straight through&amp;nbsp;&lt;strong&gt;or&lt;/strong&gt;&amp;nbsp;cross the path over. This decision is made directly by the corresponding bit in the cell's destination address (VPI/VCI bits). The first bit controls the first switch, the second bit controls the second switch etc.&lt;br /&gt;
&lt;blockquote&gt;
&lt;img alt="Banyan Switch" height="308" src="http://ironbark.bendigo.latrobe.edu.au/subjects/DC/lectures/21/banyan.gif" width="416" /&gt;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div class="slide"&gt;
All ATM switches have two common goals:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Switch all cells with as low a discard rate as possible, preferably nil.&lt;/li&gt;
&lt;li&gt;Never (ever) re-order the cells on a virtual connection.&lt;/li&gt;
&lt;/ul&gt;
A problem occurs when two cells arrive at a given time, both destined for the same output. The general solution is:&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Pre-sort the cells before feeding them into the Banyan switch (this avoids switching contention) and&lt;/li&gt;
&lt;li&gt;Provide a queue on each outgoing line (this avoids "output" contention).&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;div class="slide"&gt;
&lt;h2&gt;
ATM Architecture&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;ATM Switches: reads and updates the cell header information and switches the information cell towards its destination.&lt;/li&gt;
&lt;li&gt;ATM Endpoints: contains the ATM network interface adaptor to enable data entering or leaving the ATM network to interface to the external world. Examples of these end points include workstations, LAN switches, video codecs and many more items.&lt;/li&gt;
&lt;li&gt;NNI: Network-to-network interface (between two switches, inside an ATM network).&lt;/li&gt;
&lt;li&gt;UNI: User-to-network interface (between a user access device and a switch, on the edge of an ATM network).&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;img alt="atm_architecture" height="295" src="http://ironbark.bendigo.latrobe.edu.au/subjects/DC/lectures/21/atm_architecture.png" width="633" /&gt;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div class="slide"&gt;
&lt;h2&gt;
ATM Cell Format&lt;/h2&gt;
&lt;blockquote&gt;
&lt;img alt="ATM Cell Format" height="399" src="http://ironbark.bendigo.latrobe.edu.au/subjects/DC/lectures/21/atm_cell_format.png" width="673" /&gt;&lt;/blockquote&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;b&gt;GFC&lt;/b&gt;&lt;/dt&gt;
&lt;dd&gt;Generic Flow Control, only present in cells passing over the User-Network Interface (UNI). On Network-Network Interfaces (NNI), this is part of the VPI field. GFC provides local function, such as identifying multiple stations that share a single ATM interface. Typically not used and is set to default (binary 0000).&lt;/dd&gt;
&lt;dt&gt;&lt;b&gt;VPI, VCI&lt;/b&gt;&lt;/dt&gt;
&lt;dd&gt;See previous slide.&lt;/dd&gt;
&lt;dt&gt;&lt;b&gt;PTI&lt;/b&gt;&lt;/dt&gt;
&lt;dd&gt;Payload Type Identifier. MSB (1st bit) indicates data type - (0 = user data, 1 = control data). 2nd bit indicates congestion (0 = no congestion, 1 = congestion). 3rd bit indicates if the cell is the last of the frame (0 = No, 1 = Yes).&lt;/dd&gt;
&lt;dt&gt;&lt;b&gt;CLP&lt;/b&gt;&lt;/dt&gt;
&lt;dd&gt;Cell loss priority. 1 = discard the cell under extreme congestions.&lt;/dd&gt;
&lt;dt&gt;&lt;b&gt;HEC&lt;/b&gt;&lt;/dt&gt;
&lt;dd&gt;Header Error Correction, or checksum.&lt;/dd&gt;&lt;/dl&gt;
&lt;/div&gt;
&lt;div class="slide"&gt;
&lt;h2&gt;
The HEC field&lt;/h2&gt;
Calculates checksum only on the first 4 bytes of the header. HEC can detect and correct a single bit error in these bytes.&lt;br /&gt;
The HEC field is an 8-bit CRC checksum of the first 4 bytes (octets) of the header. In fact, it consists of the remainder after the 32 bits have been divided by the magic number&amp;nbsp;&lt;code&gt;&lt;b&gt;100000111&lt;/b&gt;&lt;/code&gt;, to which is added the constant&amp;nbsp;&lt;code&gt;&lt;b&gt;01010101&lt;/b&gt;&lt;/code&gt;, to make the checksum more resilient where headers contain mostly zeroes.&lt;br /&gt;
The checksum covers the header only for speed of computation, and because for many telco applications incorrect data is not catastrophic...&lt;br /&gt;
The HEC algorithm is effective where most errors are&amp;nbsp;&lt;strong&gt;single bit&lt;/strong&gt;, which is usually the case for optical fibre.&lt;br /&gt;
The HEC comes in handy when multiple cells are supplied to a switch port in strict succession. The protocol provides no way to determine cell boundaries (eg. no FLAG or SOH fields). As bits arrive, the software maintains a 40-bit shift register. If the last 8 bits form a valid HEC checksum of the first 32, then this may be a valid cell boundary. If not, load one more bit and try again until a match is found.&lt;/div&gt;
&lt;div class="slide"&gt;
&lt;h2&gt;
ATM Traffic Control and QoS&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;ATM supports a set of QoS parameters and classes for all ATM services.&lt;/li&gt;
&lt;li&gt;ATM minimises network complexity while maximising utilisation.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
CBR - Constant bit rate&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;a Peak Cell Rate (PCR) is specified, which is constant.&lt;/li&gt;
&lt;li&gt;for connections that require a static amount of bandwidth that is continuously available during the connection time.&lt;/li&gt;
&lt;li&gt;for applications such as telephone, video conferencing, interactive Audio, TV.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
VBR - Variable bit rate&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;nrt-VBR (non-real time) and rt-VBR (real time).&lt;/li&gt;
&lt;li&gt;an average cell rate is specified, which can peak at a certain level for a maximum interval before being problematic.&lt;/li&gt;
&lt;li&gt;for bursty traffic, VoIP, interactive compressed voice/video.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
ABR - Available bit rate&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;a minimum guaranteed rate is specified.&lt;/li&gt;
&lt;li&gt;provides rate-based flow control.&lt;/li&gt;
&lt;li&gt;depending on the state of congestion in the network, rate controlled by source.&lt;/li&gt;
&lt;li&gt;used for data traffic such as file transfer and email.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
UBR Unspecified bit rate:&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;traffic is allocated to all remaining transmission capacity.&lt;/li&gt;
&lt;li&gt;for non-real time applications. Delay and delay variations can be tolerated.&lt;/li&gt;
&lt;li&gt;most TCP/IP applications.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class="slide"&gt;
&lt;h2&gt;
ATM Reference Model&lt;/h2&gt;
&lt;blockquote&gt;
&lt;img alt="atm_model" height="471" src="http://ironbark.bendigo.latrobe.edu.au/subjects/DC/lectures/21/atm_reference_model.png" width="656" /&gt;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div class="slide"&gt;
&lt;h2&gt;
ATM Layer&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Defines cell layout&lt;/li&gt;
&lt;li&gt;Defines ATM header&lt;/li&gt;
&lt;li&gt;Establishment and release VC&lt;/li&gt;
&lt;li&gt;Switching&lt;/li&gt;
&lt;li&gt;Multiplexing&lt;/li&gt;
&lt;li&gt;Congestion control&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;img alt="atm_layer" height="140" src="http://ironbark.bendigo.latrobe.edu.au/subjects/DC/lectures/21/atm_layer.png" width="542" /&gt;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div class="slide"&gt;
&lt;h2&gt;
ATM Adaptation Layers (AAL)&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;ATM was designed to replace ALL existing digital and analog telecommunication systems.&lt;/li&gt;
&lt;li&gt;Therefore ATM must be able to accept ANY type of services from upper layers.&lt;/li&gt;
&lt;li&gt;AAL is responsible for fragmenting them into small fixed size ATM cells.&lt;/li&gt;
&lt;li&gt;And to reassembles cells.&lt;/li&gt;
&lt;li&gt;5 adaptation layers have been defined.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
AAL1 to AAL5&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;AAL1 is used for CBR services such as video and voice from upper layer. Require synchronisation of source and destination.&lt;/li&gt;
&lt;li&gt;AAL2 is used for VBR services such as compressed video, voice, and fax. Bursty in nature.&lt;/li&gt;
&lt;li&gt;AAL3/4 support connection-oriented and connectionless data services, replaced by AAL5.&lt;/li&gt;
&lt;li&gt;AAL5 is for data. Also known as the Simple and Efficient Adaptation Layer (SEAL).&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class="slide"&gt;
&lt;h2&gt;
More on ATM AAL&lt;/h2&gt;
&lt;h3&gt;
ATM is all things to all people&lt;/h3&gt;
ATM was designed to replace all existing digital and analog telecommunication systems. In order to do this, the underlying lightweight packet stream had to be adapted to provide a number of different types of service. This was achieved by placing an&amp;nbsp;&lt;strong&gt;adaption layer&lt;/strong&gt;&amp;nbsp;on top of the lightweight packet stream. The adaption layer hides the underlying packet stream and presents an appropriate interface to the higher layer(s). Various adaption layers have been defined, as follows:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;AAL1 defines a Constant Bit Rate (CBR) stream between the ends of the ATM virtual circuit (VC). AAL1 emulates a traditional phone call. AAL1 steals one byte from the payload field to extend the cell header.&lt;/li&gt;
&lt;li&gt;AAL2 as for AAL1, except the bit rate can vary. Nevertheless, the ends of the VC still have a fixed timing relationship. This is appropriate for transfer of compressed video. AAL2 steals 3 bytes from the payload field for administration.&lt;/li&gt;
&lt;li&gt;AAL3/4 originally specified as two distinct adaption layers, this is now a complex specification for a connectionless data service over ATM. Higher layer data packets (up to 64 Kbytes) have 4 bytes each of header and trailer information added, then are diced into ATM cells from which 4 bytes of payload are stolen for admin purposes.&lt;/li&gt;
&lt;li&gt;AAL5 (designed to replace AAL3/4) accepts data packets of up to 64 Kbytes, adds 8 trailer bytes, then dices this up to fit in ATM cells (without any further headers).&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class="slide"&gt;
&lt;h2&gt;
ATM AAL5 and Encapsulation of Internet Data&lt;/h2&gt;
To send Internet Protocol (IP) datagrams over an ATM service, using AAL5, the data undergoes a complicated encapsulation process:&lt;br /&gt;
&lt;blockquote&gt;
&lt;img alt="AAL5 Encapsulation" height="" src="http://ironbark.bendigo.latrobe.edu.au/subjects/DC/lectures/21/aal5-ip-encapsulation.png" width="" /&gt;&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;Since AAL5 has no&amp;nbsp;&lt;strong&gt;Type&lt;/strong&gt;&amp;nbsp;field, the IP Datagram is first encapsulated in an 802.2 LLC frame, using connectionless SNAP.&lt;/li&gt;
&lt;li&gt;The 802.2 LLC frame is placed in an&amp;nbsp;&lt;strong&gt;AAL5 Convergence sub-layer&amp;nbsp;&lt;/strong&gt;frame. It is padded to make the AAL5 frame a multiple of 48 bytes long.&lt;/li&gt;
&lt;li&gt;The AAL5 Convergence Layer frame is chopped into 48 byte packets by the&amp;nbsp;&lt;strong&gt;AAL5 Segmentation and Reassembly Sub-layer&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;The resulting pieces become the contents of ATM cells.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class="slide"&gt;
Here's a closer look at the AAL5&amp;nbsp;&lt;strong&gt;Convergence sub-layer&lt;/strong&gt;&amp;nbsp;(CS) Protocol Data Unit (PDU):&lt;br /&gt;
&lt;blockquote&gt;
&lt;img alt="AAL5 Protocol Data Unit" height="" src="http://ironbark.bendigo.latrobe.edu.au/subjects/DC/lectures/21/atm-aal5-cs-format.png" width="" /&gt;&lt;/blockquote&gt;
&lt;dl compact=""&gt;
&lt;dt&gt;&lt;b&gt;UU&lt;/b&gt;&lt;/dt&gt;
&lt;dd&gt;User-to-User field is not used in AAL5 but is available for higher layer protocols for eg. sequence information.&lt;/dd&gt;
&lt;dt&gt;&lt;b&gt;RFU&lt;/b&gt;&lt;/dt&gt;
&lt;dd&gt;Reserved for future use.&lt;/dd&gt;
&lt;dt&gt;&lt;b&gt;Length&lt;/b&gt;&lt;/dt&gt;
&lt;dd&gt;The actual length of the data. The payload field is padded to make the total CS PDU a multiple of 48 bytes.&lt;/dd&gt;
&lt;dt&gt;&lt;b&gt;CRC&lt;/b&gt;&lt;/dt&gt;
&lt;dd&gt;A standard 32-bit CRC checksum over the entire CS PDU.&lt;/dd&gt;&lt;/dl&gt;
&lt;/div&gt;
&lt;div class="slide"&gt;
&lt;h2&gt;
LANs over ATM&lt;/h2&gt;
Where ATM is to be used to form a LAN, fundamental differences between ATM and IP becomes troublesome:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;IP is connectionless and has provision for broadcasting built in. Everything is carried by IP.&lt;/li&gt;
&lt;li&gt;ATM is connection oriented (broadcasting is difficult).&lt;/li&gt;
&lt;li&gt;ATM and IP addressing are incompatible.&lt;/li&gt;
&lt;/ul&gt;
A number of different approaches have been proposed to solve these problems:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;CLIP - Classical IP over ATM&lt;/li&gt;
&lt;li&gt;LANE - LAN Emulation&lt;/li&gt;
&lt;li&gt;NHRP - Next Hop Resolution Protocol&lt;/li&gt;
&lt;li&gt;MPOA - Multi-Protocol over ATM&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class="slide"&gt;
&lt;h3&gt;
CLIP - Classical IP over ATM&lt;/h3&gt;
This is an&amp;nbsp;&lt;a href="http://www.ietf.org/"&gt;IETF&lt;/a&gt;&amp;nbsp;specification whereby IP treats ATM as another subnetwork to which routers and hosts are attached. In the CLIP model, multiple Logical IP subnetworks (LIS) are overlaid on top of the ATM network. Machines within a LIS can communicate directly using ATM Virtual Channel Connections (VCCs). Machines in different LISs can communicate only through routers, even though direct connections using VCCs may be possible.&lt;/div&gt;
&lt;div class="slide"&gt;
&lt;h3&gt;
LANE - LAN Emulation&lt;/h3&gt;
This is an&amp;nbsp;&lt;a href="http://www.atmforum.com/"&gt;ATM Forum&lt;/a&gt;&amp;nbsp;(now the&amp;nbsp;&lt;a href="http://www.broadband-forum.org/"&gt;Broadband Forum&lt;/a&gt;) competitor to CLIP. It is essentially similar, except that where CLIP handles only IP, LANE handles other network level protocols as well.&lt;br /&gt;
ATM LAN Emulation (LANE) looks like the following:&lt;br /&gt;
&lt;blockquote&gt;
&lt;img alt="LAN Emulation" height="185" src="http://ironbark.bendigo.latrobe.edu.au/subjects/DC/lectures/21/l24fig3.gif" width="232" /&gt;&lt;/blockquote&gt;
A virtual circuit can be set up between two hosts connected to the ATM network. However, as in conventional LANs (eg. 802.3/Ethernet), communication is based on first knowing the MAC-level address of the destination.&lt;br /&gt;
&lt;dl compact=""&gt;
&lt;dt&gt;&lt;b&gt;LES&lt;/b&gt;&lt;/dt&gt;
&lt;dd&gt;The LAN Emulation Server supplies network layer to MAC (in this case, ATM) address mappings on request.&lt;/dd&gt;
&lt;dt&gt;&lt;b&gt;BUS&lt;/b&gt;&lt;/dt&gt;
&lt;dd&gt;ATM does not support broadcast. The "Broadcast and Unknown Server" accepts higher layer broadcast messages and sends them to all hosts participating in the LANE, one at a time.&lt;/dd&gt;&lt;/dl&gt;
&lt;/div&gt;
&lt;div class="slide"&gt;
&lt;h3&gt;
NHRP - Next Hop Resolution Protocol&lt;/h3&gt;
In CLIP LANs, machines in different LISs can communicate only through routers, even though direct connections using VCCs may be possible. LANE appears to be similar.&lt;br /&gt;
NHRP uses "Next Hop" clients to initiate connections to "Next Hop" servers. Together, these act to discover an ATM destination address corresponding to an IP address. The originating client then establishes an ATM connection directly to the destination host. Intermediate routers act as both NHRP servers and NHRP clients during call set-up.&lt;br /&gt;
&lt;strong&gt;NHRP and CLIP compared&lt;/strong&gt;&lt;br /&gt;
&lt;blockquote&gt;
&lt;img alt="CLIP versus NHRP" height="290" src="http://ironbark.bendigo.latrobe.edu.au/subjects/DC/lectures/21/l13fig11.gif" width="380" /&gt;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div class="slide"&gt;
&lt;h3&gt;
MPOA - Multi-Protocol over ATM&lt;/h3&gt;
MPOA was designed by the&amp;nbsp;&lt;a href="http://ironbark.bendigo.latrobe.edu.au/subjects/DC/lectures/21/#atmf"&gt;ATM Forum&lt;/a&gt;&amp;nbsp;to provide an internetworking service over ATM. Basically, MPOA integrates LANE and NHRP. MPOA uses LANE to establish layer 2 connections (ie. within the same LIS) and NHRP to establish layer 3 connections (to another LIS).&lt;br /&gt;
Short lived connections between a host in one LIS and another host in a different LIS are passed router to router, as for CLIP. ATM virtual circuits are established for longer lived connections.&lt;br /&gt;
It is rumoured that this constant setting up and tearing down of ATM virtual circuits stresses the ATM switches. As a result, MPOA does not scale well in a system with many hosts.&lt;/div&gt;
&lt;div class="slide"&gt;
&lt;h2&gt;
IP Switching&lt;/h2&gt;
A variation on Classical IP over ATM originally introduced by a company called "Ipsilon" (and now various others), who have announced a combination IP router and ATM switch which combines the best of both approaches.&lt;br /&gt;
This technique relies on the fact that where Classical IP over ATM is in use, the first cell of an encapsulated datagram will contain (in addition to the 802.2 SNAP headers) the entire IP and TCP (or UDP) headers, presuming minimum length headers.&lt;br /&gt;
This allows the ATM switch to make a&amp;nbsp;&lt;strong&gt;routing&lt;/strong&gt;&amp;nbsp;decision (on the basis of the IP destination address) and a&amp;nbsp;&lt;strong&gt;stream&lt;/strong&gt;&amp;nbsp;decision (on the basis of the TCP header) on the basis of the contents of the first cell.&lt;br /&gt;
If the ATM switch is also a&amp;nbsp;&lt;strong&gt;router&lt;/strong&gt;&amp;nbsp;(ie. connected to more than one LIS), it can immediately begin sending the cells of a datagram to its destination, instead of waiting for the entire datagram to be accumulated, then forwarded. Thus, datagrams are effectively forwarded through the device at switch speeds, instead of the (usually) slower router speed.&lt;/div&gt;
&lt;div class="slide"&gt;
&lt;h2&gt;
Multi-Protocol Label Switching (MPLS)&lt;/h2&gt;
The big problem with all the previous approaches is the duplicated network infrastructures (IP and ATM) with their incompatible addressing models and routing techniques.&lt;br /&gt;
MPLS routers are intended to integrate layer 2 switching functions with layer 3 addressing. When a layer 3 packet enters an MPLS network, the Label Edge Router (LER) prepends a MPLS label onto the incoming packet, before forwarding it to the next hop Label Switch Router (LSR). The MPLS label is based on the destination IP address and identifies the virtual circuit to be used between adjacent LSRs. When delivered by ATM, the label becomes equivalent to the ATM Virtual Circuit Identifier. The established path, unlike ATM though, is unidirectional.&lt;br /&gt;
Like ATM, MPLS is connection-oriented and a path needs to be established through the MPLS network before communication can occur. This is achieved using a Label Distribution Protocol (LDP). Quality of Service (QoS) can also be achieved by using an LDP that supports traffic engineering. Examples are the Constraint-based Label Distribution Protocol (CR-LDP) or the Resource Reservation Protocol - Traffic Engineering (RSVP-TE).&lt;br /&gt;
MPLS is an&amp;nbsp;&lt;a href="http://ironbark.bendigo.latrobe.edu.au/subjects/DC/lectures/21/#ietf"&gt;IETF&lt;/a&gt;&amp;nbsp;initiative and is defined in&amp;nbsp;&lt;a href="http://www.faqs.org/rfcs/rfc3031.html"&gt;RFC3031&lt;/a&gt;. For more information on MPLS, refer to&amp;nbsp;&lt;a href="http://ironbark.bendigo.latrobe.edu.au/subjects/INW/lectures/23/"&gt;this lecture&lt;/a&gt;&amp;nbsp;in our companion subject,&amp;nbsp;&lt;a href="http://ironbark.bendigo.latrobe.edu.au/subjects/INW/"&gt;Internetworking&lt;/a&gt;.&lt;/div&gt;
&lt;div class="slide"&gt;
&lt;h2&gt;
Three (Four?) Letter Acronyms (TLAs)&lt;/h2&gt;
CLIP - Classical IP over ATM&lt;br /&gt;LANE - LAN Emulation&lt;br /&gt;NHRP - Next Hop Resolution Protocol&lt;br /&gt;MPOA - Multi-Protocol Over ATM&lt;br /&gt;MPLS - Multi-Protocol Label Switching&lt;br /&gt;VCC - ATM Virtual Channel Connection&lt;br /&gt;LDP - Label Distribution Protocol LIS - Logical IP subnetwork&lt;br /&gt;LER - Label Edge Router&lt;br /&gt;LSR - Label Switch Router&lt;br /&gt;QoS - Quality of Service&lt;br /&gt;&lt;a href="" name="ietf"&gt;&lt;/a&gt;IETF - Internet Engineering Task Force&lt;br /&gt;&lt;a href="" name="atmf"&gt;&lt;/a&gt;ATM Forum - The telco's answer to IETF&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://ironbark.bendigo.latrobe.edu.au/subjects/DC/lectures/21/"&gt;http://ironbark.bendigo.latrobe.edu.au/subjects/DC/lectures/21/&lt;/a&gt;&lt;/div&gt;
</description><author>emaknyus@gmail.com (tamvan &amp;amp; verani)</author></item><item><title>ADSL Information</title><link>http://emaknyus.blogspot.com/2011/09/adsl-information.html</link><category>adsl</category><category>experience</category><pubDate>Fri, 16 Sep 2011 14:21:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3787219161379371544.post-3101267348268390798</guid><description>~ &lt;span style="color: red;"&gt;New!&lt;/span&gt; 
			  &lt;a href="http://www.kitz.co.uk/adsl/adslchecker.php"&gt;Broadband Availability Checker&lt;/a&gt; - &lt;span class="kitzplainsmall"&gt;&lt;a href="http://www.kitz.co.uk/adsl/adslchecker.php"&gt;Checks adsl line and exchange status&lt;/a&gt;. &lt;/span&gt;
              &amp;nbsp;
            
            
              ~ &lt;a href="http://www.kitz.co.uk/adsl/max_speed_calc.php"&gt;Max Speed Calculator&lt;/a&gt; - Indication of your maximum speed.
              &amp;nbsp;
            
            
              ~ &lt;a href="http://www.kitz.co.uk/adsl/frogstats.php"&gt;How to get your line stats from your router &lt;/a&gt;
              &amp;nbsp;
            
            
              ~ &lt;a href="http://www.kitz.co.uk/adsl/linestats.htm"&gt;How to understand your line stats&lt;/a&gt; 
              &amp;nbsp;
            
            
              
			   ~ &lt;a href="http://www.kitz.co.uk/adsl/DUN.htm"&gt;Connecting&lt;/a&gt; and &lt;a href="http://www.kitz.co.uk/adsl/splitter_install.htm"&gt;adsl filters&lt;/a&gt;.
              &amp;nbsp;
            
            
              
			  	~ &lt;a href="http://www.kitz.co.uk/adsl/networking.htm"&gt;Networking&lt;/a&gt; and &lt;a href="http://www.kitz.co.uk/adsl/router.htm"&gt;setting up a router&lt;/a&gt;
              &amp;nbsp;
            

            
              
			  	~ &lt;a href="http://www.kitz.co.uk/adsl/equip.htm"&gt;How adsl works&lt;/a&gt;.
              &amp;nbsp;
            

            
              
			  	~ &lt;a href="http://www.kitz.co.uk/adsl/adsltype.htm"&gt;Different types of adsl - IPStream, Datastream + LLU &lt;/a&gt;
              &amp;nbsp;
            
            
              ~ &lt;a href="http://www.kitz.co.uk/adsl/maxdsl.htm"&gt;DSL Max &lt;/a&gt; &amp;amp; &lt;a href="http://www.kitz.co.uk/adsl/interleaving.htm"&gt;Interleaving&lt;/a&gt;
              &amp;nbsp;
            
            
              ~ &lt;a href="http://www.kitz.co.uk/adsl/maxdsl2.htm"&gt;How DSLMax works&lt;/a&gt; &amp;amp; &lt;a href="http://www.kitz.co.uk/adsl/IPprofile.htm"&gt;your bRAS IP Profile information&lt;/a&gt; 
              &amp;nbsp;
            
            
              ~ &lt;a href="http://www.kitz.co.uk/adsl/troubleshooting.htm"&gt;Troubleshooting&lt;/a&gt; and adsl &lt;a href="http://www.kitz.co.uk/adsl/connectionprobs.htm"&gt;connection problems&lt;/a&gt; 
              &amp;nbsp;
            
            
              ~ Common Faults - &lt;a href="http://www.kitz.co.uk/adsl/lowSNR.htm"&gt;Low SNR&lt;/a&gt; and &lt;a href="http://www.kitz.co.uk/adsl/rein.htm"&gt;REIN faults&lt;/a&gt; 
              &amp;nbsp;
            
            
              ~ &lt;a href="http://www.kitz.co.uk/adsl/linestats.htm"&gt;Understanding SNR and attenuation&lt;/a&gt; 
              &amp;nbsp;
            
            
              ~ &lt;a href="http://www.kitz.co.uk/adsl/slowspeeds.htm"&gt;Slow speed problems&lt;/a&gt;
              &amp;nbsp;
            
            
              ~ &lt;a href="http://www.kitz.co.uk/adsl/MTU.htm"&gt;MTU Problems&lt;/a&gt; and &lt;a href="http://www.kitz.co.uk/adsl/tweak2.htm"&gt;MTU tweaking&lt;/a&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
http://www.kitz.co.uk/adsl/index.htm</description><author>emaknyus@gmail.com (tamvan &amp;amp; verani)</author></item><item><title>What is Clonezilla?</title><link>http://emaknyus.blogspot.com/2011/09/what-is-clonezilla.html</link><category>clone</category><pubDate>Fri, 16 Sep 2011 14:09:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3787219161379371544.post-3153386553674557016</guid><description>&lt;span class="Apple-style-span" style="font-family: 'Bitstream Vera Sans', Arial, Helvetica, 'Luxi Sans', Verdana, sans-serif; line-height: 24px;"&gt;You're probably familiar with the popular proprietary commercial package&amp;nbsp;&lt;a href="http://www.ghost.com/" target="_blank"&gt;Norton Ghost®&lt;/a&gt;. The problem with these kind of software packages is that it takes a lot of time to massively clone systems to many computers. You've probably also heard of Symantec's solution to this problem,&lt;a href="http://www.norton.com/" target="_blank"&gt;Symantec Ghost Corporate Edition®&lt;/a&gt;&amp;nbsp;with multicasting. Well, now there is an OpenSource clone system (OCS) solution called Clonezilla with unicasting and multicasting!&lt;br /&gt;Clonezilla, based on&amp;nbsp;&lt;a href="http://drbl.sf.net/"&gt;DRBL&lt;/a&gt;,&amp;nbsp;&lt;a href="http://partclone.org/"&gt;Partclone&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="http://udpcast.linux.lu/" target="_blank"&gt;udpcast&lt;/a&gt;, allows you to do bare metal backup and recovery. Two types of Clonezilla are available,&lt;a href="http://www.clonezilla.org/clonezilla-live.php"&gt;Clonezilla live&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="http://www.clonezilla.org/clonezilla-SE.php"&gt;Clonezilla SE (server edition)&lt;/a&gt;. Clonezilla live is suitable for single machine backup and restore. While Clonezilla SE is for massive deployment, it can clone many (40 plus!) computers simultaneously. Clonezilla saves and restores only used blocks in the harddisk. This increases the clone efficiency. At the NCHC's Classroom C, Clonezilla SE was used to clone 41 computers simultaneously. It took only about 10 minutes to clone a 5.6 GBytes system image to all 41 computers via multicasting!&lt;/span&gt;</description><author>emaknyus@gmail.com (tamvan &amp;amp; verani)</author></item><item><title>Perbedaan redirect to proxy memakai dst-nat dan mark-routing</title><link>http://emaknyus.blogspot.com/2011/09/perbedaan-redirect-to-proxy-memakai-dst.html</link><category>dstnat</category><category>mikrotik</category><category>squid</category><pubDate>Fri, 16 Sep 2011 09:56:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3787219161379371544.post-8765101677617932519</guid><description>&lt;span class="Apple-style-span" style="background-color: white; color: #555555; font-family: Arial, Tahoma, Verdana; font-size: 12px; line-height: 20px;"&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style="padding-bottom: 15px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
Mungkin selama ini anda tidak pernah menyadari traffic sebuah server yang mengirimkan data atas permintaan ip klien jika menggunakan dst-nat to proxy itu server akan mengirim ke ip proxy bukan langsung ke ip klien yang telah melakukan permintaan tadi&lt;/div&gt;
&lt;div style="padding-bottom: 15px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
Jadi kita akan mengalami kesulitan jika ingin membuat rule bypass/limit untuk ip server (port 80) yang dari luar yang telah masuk ke ip proxy&lt;/div&gt;
&lt;div style="padding-bottom: 15px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="padding-bottom: 15px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;/div&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
&lt;div style="padding-bottom: 15px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
Contohnya ip klien 192.168.100.124 mengirim permintaan ke ip server 119.2.24.66:80 (server4.asixfiles.com) jika memakai dst-nat maka permintaan 119.2.24.66:80 ini akan di mapping ke ip proxy (contohnya 192.168.1.10:8080) sesuai NAT redirect pada mikrotik :&lt;/div&gt;
&lt;div class="syntaxhighlighter  " id="highlighter_232360" style="background-attachment: initial !important; background-clip: initial !important; background-color: rgb(255, 255, 255) !important; background-image: none !important; background-origin: initial !important; border-bottom-color: rgb(224, 224, 224) !important; border-bottom-style: solid !important; border-bottom-width: 1px !important; border-color: initial !important; border-left-color: rgb(224, 224, 224) !important; border-left-style: solid !important; border-left-width: 1px !important; border-right-color: rgb(224, 224, 224) !important; border-right-style: solid !important; border-right-width: 1px !important; border-style: initial !important; border-top-color: rgb(224, 224, 224) !important; border-top-style: solid !important; border-top-width: 1px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 1em !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 1em !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: relative !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: 623px;"&gt;
&lt;div class="lines" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;
&lt;div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-color: rgb(255, 255, 255) !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;
&lt;table style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-collapse: collapse !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;&lt;tbody style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;
&lt;tr style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;&lt;td class="number" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: top !important; width: 3em !important;"&gt;&lt;code style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0.3em !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: right !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;"&gt;1&lt;/code&gt;&lt;/td&gt;&lt;td class="content" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-color: rgb(204, 204, 204) !important; border-left-style: solid !important; border-left-width: 3px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: top !important; width: auto !important;"&gt;&lt;code class="plain" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;/ip firewall nat&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class="line alt2" style="background-attachment: initial !important; background-clip: initial !important; background-color: rgb(248, 248, 248) !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;
&lt;table style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-collapse: collapse !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;&lt;tbody style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;
&lt;tr style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;&lt;td class="number" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: top !important; width: 3em !important;"&gt;&lt;code style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0.3em !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: right !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;"&gt;2&lt;/code&gt;&lt;/td&gt;&lt;td class="content" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-color: rgb(204, 204, 204) !important; border-left-style: solid !important; border-left-width: 3px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: top !important; width: auto !important;"&gt;&lt;code class="plain" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;add action=dst-nat chain=dstnat comment="" disabled=no dst-port=80 protocol=\&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-color: rgb(255, 255, 255) !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;
&lt;table style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-collapse: collapse !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;&lt;tbody style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;
&lt;tr style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;&lt;td class="number" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: top !important; width: 3em !important;"&gt;&lt;code style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0.3em !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: right !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;"&gt;3&lt;/code&gt;&lt;/td&gt;&lt;td class="content" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-color: rgb(204, 204, 204) !important; border-left-style: solid !important; border-left-width: 3px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: top !important; width: auto !important;"&gt;&lt;code class="spaces" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class="plain" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;tcp src-address=192.168.100.0/24 to-addresses=192.168.1.10 to-ports=8080&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style="padding-bottom: 15px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
Secara otomatis ip server 119.2.24.66:80 (server4.asixfiles.com) mengirimkan data kepada ip proxynya bukan ke klien langsung karena yang melakukan permintaan adalah ip proxy bukan ip klien dan ip klien baru menerima data dari ip server melalui ip proxynya&lt;/div&gt;
&lt;div class="wp-caption alignnone" id="attachment_516" style="background-attachment: initial; background-clip: initial; background-color: whitesmoke; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-color: rgb(228, 228, 228); border-bottom-left-radius: 3px 3px; border-bottom-right-radius: 3px 3px; border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(228, 228, 228); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(228, 228, 228); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(228, 228, 228); border-top-left-radius: 3px 3px; border-top-right-radius: 3px 3px; border-top-style: solid; border-top-width: 1px; padding-bottom: 7px; padding-left: 2px; padding-right: 2px; padding-top: 7px; text-align: center; width: 610px;"&gt;
&lt;a href="http://reges007.files.wordpress.com/2011/05/dstnat.png" style="color: #008dcf; text-decoration: none;"&gt;&lt;img alt="" class="size-full wp-image-516" height="264" src="http://reges007.files.wordpress.com/2011/05/dstnat.png?w=600&amp;amp;h=264" style="border-bottom-style: none; border-color: initial; border-color: initial; border-color: initial; border-left-style: none; border-right-style: none; border-style: initial; border-top-style: none; border-width: initial; border-width: initial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; max-width: 100%; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="dstnat" width="600" /&gt;&lt;/a&gt;&lt;div class="wp-caption-text" style="font-size: 11px; line-height: 12px; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 5px !important;"&gt;
dstnat&lt;/div&gt;
&lt;/div&gt;
&lt;div style="padding-bottom: 15px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
Jadi kesimpulannya kita tidak bisa memisahkan ip server ini karena telah masuk ke ip proxy, seandainya kita mau melakukan bypass/limitter server tertentu yang dari port 80 akan mengalami kesulitan.&lt;/div&gt;
&lt;div style="padding-bottom: 15px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
Dan disinilah kelebihan jika memakai redirect to proxy memakai mark-routing, sebab ip klien bukan lagi di mapping melainkan dikirim langsung ke ip server melalui GATEWAY. jadi systemnya adalah original id’s seolah-olah tidak memakai proxy/mapping untuk permintaan dari ip klien.&lt;br /&gt;&lt;span id="more-511"&gt;&lt;/span&gt;&lt;br /&gt;Contohnya ip klien melakukan permintaan ke server dan langsung dikirim oleh router melalui GATEWAY dan GATEWAY ini meneruskan ip klien tadi ke ip server baru ip server mengirimkan data atas permintaan ip klien.&lt;br /&gt;Jadi kita mempunyai 2 GATEWAY dalam satu router dong?&lt;br /&gt;Benar.. kita punya 2 GATEWAY satu untuk ke internet dan satu lagi ke proxy sebagai transparent proxynya dan itu dilakukan melalui mark-routing di mikrotik.&lt;/div&gt;
&lt;div style="padding-bottom: 15px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
contoh mark-routingnya:&lt;/div&gt;
&lt;div class="syntaxhighlighter  " id="highlighter_818072" style="background-attachment: initial !important; background-clip: initial !important; background-color: rgb(255, 255, 255) !important; background-image: none !important; background-origin: initial !important; border-bottom-color: rgb(224, 224, 224) !important; border-bottom-style: solid !important; border-bottom-width: 1px !important; border-color: initial !important; border-left-color: rgb(224, 224, 224) !important; border-left-style: solid !important; border-left-width: 1px !important; border-right-color: rgb(224, 224, 224) !important; border-right-style: solid !important; border-right-width: 1px !important; border-style: initial !important; border-top-color: rgb(224, 224, 224) !important; border-top-style: solid !important; border-top-width: 1px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 1em !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 1em !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: relative !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: 623px;"&gt;
&lt;div class="lines" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;
&lt;div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-color: rgb(255, 255, 255) !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;
&lt;table style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-collapse: collapse !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;&lt;tbody style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;
&lt;tr style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;&lt;td class="number" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: top !important; width: 3em !important;"&gt;&lt;code style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0.3em !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: right !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;"&gt;1&lt;/code&gt;&lt;/td&gt;&lt;td class="content" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-color: rgb(204, 204, 204) !important; border-left-style: solid !important; border-left-width: 3px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: top !important; width: auto !important;"&gt;&lt;code class="plain" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;/ip firewall mangle&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class="line alt2" style="background-attachment: initial !important; background-clip: initial !important; background-color: rgb(248, 248, 248) !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;
&lt;table style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-collapse: collapse !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;&lt;tbody style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;
&lt;tr style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;&lt;td class="number" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: top !important; width: 3em !important;"&gt;&lt;code style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0.3em !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: right !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;"&gt;2&lt;/code&gt;&lt;/td&gt;&lt;td class="content" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-color: rgb(204, 204, 204) !important; border-left-style: solid !important; border-left-width: 3px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: top !important; width: auto !important;"&gt;&lt;code class="plain" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;add action=mark-routing chain=prerouting comment="To Proxy (Expert ONLY!)" \&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-color: rgb(255, 255, 255) !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;
&lt;table style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-collapse: collapse !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;&lt;tbody style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;
&lt;tr style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;&lt;td class="number" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: top !important; width: 3em !important;"&gt;&lt;code style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0.3em !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: right !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;"&gt;3&lt;/code&gt;&lt;/td&gt;&lt;td class="content" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-color: rgb(204, 204, 204) !important; border-left-style: solid !important; border-left-width: 3px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: top !important; width: auto !important;"&gt;&lt;code class="spaces" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class="plain" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;disabled=no dst-port=80 new-routing-mark=proxy passthrough=yes protocol=\&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class="line alt2" style="background-attachment: initial !important; background-clip: initial !important; background-color: rgb(248, 248, 248) !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;
&lt;table style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-collapse: collapse !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;&lt;tbody style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;
&lt;tr style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;&lt;td class="number" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: top !important; width: 3em !important;"&gt;&lt;code style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0.3em !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: right !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;"&gt;4&lt;/code&gt;&lt;/td&gt;&lt;td class="content" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-color: rgb(204, 204, 204) !important; border-left-style: solid !important; border-left-width: 3px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: top !important; width: auto !important;"&gt;&lt;code class="spaces" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class="plain" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;tcp src-address=192.168.100.0/24&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style="padding-bottom: 15px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
dan untuk route-nya&lt;/div&gt;
&lt;div class="syntaxhighlighter  " id="highlighter_340860" style="background-attachment: initial !important; background-clip: initial !important; background-color: rgb(255, 255, 255) !important; background-image: none !important; background-origin: initial !important; border-bottom-color: rgb(224, 224, 224) !important; border-bottom-style: solid !important; border-bottom-width: 1px !important; border-color: initial !important; border-left-color: rgb(224, 224, 224) !important; border-left-style: solid !important; border-left-width: 1px !important; border-right-color: rgb(224, 224, 224) !important; border-right-style: solid !important; border-right-width: 1px !important; border-style: initial !important; border-top-color: rgb(224, 224, 224) !important; border-top-style: solid !important; border-top-width: 1px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 1em !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 1em !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: relative !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: 623px;"&gt;
&lt;div class="lines" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;
&lt;div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-color: rgb(255, 255, 255) !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;
&lt;table style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-collapse: collapse !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;&lt;tbody style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;
&lt;tr style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;&lt;td class="number" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: top !important; width: 3em !important;"&gt;&lt;code style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0.3em !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: right !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;"&gt;1&lt;/code&gt;&lt;/td&gt;&lt;td class="content" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-color: rgb(204, 204, 204) !important; border-left-style: solid !important; border-left-width: 3px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: top !important; width: auto !important;"&gt;&lt;code class="plain" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;/ip route&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class="line alt2" style="background-attachment: initial !important; background-clip: initial !important; background-color: rgb(248, 248, 248) !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;
&lt;table style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-collapse: collapse !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;&lt;tbody style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;
&lt;tr style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;&lt;td class="number" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: top !important; width: 3em !important;"&gt;&lt;code style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0.3em !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: right !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;"&gt;2&lt;/code&gt;&lt;/td&gt;&lt;td class="content" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-color: rgb(204, 204, 204) !important; border-left-style: solid !important; border-left-width: 3px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: top !important; width: auto !important;"&gt;&lt;code class="plain" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;add comment="" disabled=no distance=1 dst-address=0.0.0.0/0 gateway=192.168.1.10 \&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-color: rgb(255, 255, 255) !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;
&lt;table style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-collapse: collapse !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;&lt;tbody style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;
&lt;tr style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;&lt;td class="number" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: top !important; width: 3em !important;"&gt;&lt;code style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0.3em !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: right !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;"&gt;3&lt;/code&gt;&lt;/td&gt;&lt;td class="content" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-color: rgb(204, 204, 204) !important; border-left-style: solid !important; border-left-width: 3px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: top !important; width: auto !important;"&gt;&lt;code class="spaces" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class="plain" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;routing-mark=proxy scope=30 target-scope=10&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style="padding-bottom: 15px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
Dan hasilnya seperti pada gambar di bawah ini:&lt;/div&gt;
&lt;div class="wp-caption alignnone" id="attachment_528" style="background-attachment: initial; background-clip: initial; background-color: whitesmoke; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-color: rgb(228, 228, 228); border-bottom-left-radius: 3px 3px; border-bottom-right-radius: 3px 3px; border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(228, 228, 228); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(228, 228, 228); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(228, 228, 228); border-top-left-radius: 3px 3px; border-top-right-radius: 3px 3px; border-top-style: solid; border-top-width: 1px; padding-bottom: 7px; padding-left: 2px; padding-right: 2px; padding-top: 7px; text-align: center; width: 594px;"&gt;
&lt;a href="http://reges007.files.wordpress.com/2011/05/mark.png" style="color: #008dcf; text-decoration: none;"&gt;&lt;img alt="" class="size-full wp-image-528" height="256" src="http://reges007.files.wordpress.com/2011/05/mark.png?w=584&amp;amp;h=256" style="border-bottom-style: none; border-color: initial; border-color: initial; border-color: initial; border-left-style: none; border-right-style: none; border-style: initial; border-top-style: none; border-width: initial; border-width: initial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; max-width: 100%; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="mark" width="584" /&gt;&lt;/a&gt;&lt;div class="wp-caption-text" style="font-size: 11px; line-height: 12px; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 5px !important;"&gt;
mark-routing&lt;/div&gt;
&lt;/div&gt;
&lt;div style="padding-bottom: 15px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
Anda bisa melihat sendiri khan interface PROXY mengirimkan data langsung dari ip server ke ip klien&amp;nbsp;&lt;img alt=":D" class="wp-smiley" src="http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif?m=1306159899g" style="border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; float: none; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; max-width: 100%; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;&lt;/div&gt;
&lt;div style="padding-bottom: 15px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
Permasalahannya bukan sampai disini saja, anda harus mengubah server proxy anda menjadi sebuah GATEWAY biar bisa melakukan forward ke internet dan ke klien (LAN). Dan untuk mesin FreeBSD dan Linux anda harus melakukan beberapa hal seperti berikut:&lt;/div&gt;
&lt;div style="padding-bottom: 15px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;strong&gt;FreeBSD&lt;/strong&gt;&lt;br /&gt;tambahkan&amp;nbsp;&lt;strong&gt;gateway_enable=”YES”&lt;/strong&gt;&amp;nbsp;pada “/etc/rc.conf” artinya diubah sebagai gateway&lt;br /&gt;dan bikin autoexec untuk redirect to proxy pada “/etc/rc.local” (kalau tidak ada anda dapat create file baru) dan tambahan command berikut:&lt;br /&gt;&lt;strong&gt;ipfw add 100 fwd 192.168.1.10,8080 tcp from any to any 80 recv em0&lt;/strong&gt;&lt;br /&gt;atau bisa juga membuat bin/.sh pada “/usr/local/etc/rc.d/”&lt;br /&gt;jangan lupa sesuikan ip dan em0 sesuai network anda.&lt;br /&gt;terakhir recompile kernel FreeBSD anda dengan menambahkan&lt;br /&gt;“options IPFIREWALL_FORWARD”&lt;br /&gt;“options IPFIREWALL_DEFAULT_TO_ACCEPT” # ini opsi untuk jaga-jaga kalau macet saja biar tidak ada yg ke blokir karena server ini bukan untuk IP PUBLIK&lt;/div&gt;
&lt;div style="padding-bottom: 15px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;strong&gt;Linux&lt;/strong&gt;&lt;br /&gt;tentunya harus di install dulu paket ip-tables (silahkan google cara installnya sesuai distro anda)&lt;br /&gt;untuk enable forward edit/tambahkan value&amp;nbsp;&lt;strong&gt;net.ipv4.ip_forward = 1&lt;/strong&gt;&amp;nbsp;pada “/etc/sysctl.conf”&lt;br /&gt;masquerade menggunakan ip-tables via terminal&lt;/div&gt;
&lt;div class="syntaxhighlighter  " id="highlighter_375818" style="background-attachment: initial !important; background-clip: initial !important; background-color: rgb(255, 255, 255) !important; background-image: none !important; background-origin: initial !important; border-bottom-color: rgb(224, 224, 224) !important; border-bottom-style: solid !important; border-bottom-width: 1px !important; border-color: initial !important; border-left-color: rgb(224, 224, 224) !important; border-left-style: solid !important; border-left-width: 1px !important; border-right-color: rgb(224, 224, 224) !important; border-right-style: solid !important; border-right-width: 1px !important; border-style: initial !important; border-top-color: rgb(224, 224, 224) !important; border-top-style: solid !important; border-top-width: 1px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 1em !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 1em !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: relative !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: 623px;"&gt;
&lt;div class="lines" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;
&lt;div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-color: rgb(255, 255, 255) !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;
&lt;table style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-collapse: collapse !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;&lt;tbody style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;
&lt;tr style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;&lt;td class="number" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: top !important; width: 3em !important;"&gt;&lt;code style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0.3em !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: right !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;"&gt;1&lt;/code&gt;&lt;/td&gt;&lt;td class="content" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-color: rgb(204, 204, 204) !important; border-left-style: solid !important; border-left-width: 3px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: top !important; width: auto !important;"&gt;&lt;code class="plain" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style="padding-bottom: 15px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
redirect port menggunakan ip-tables&lt;/div&gt;
&lt;div class="syntaxhighlighter  " id="highlighter_464693" style="background-attachment: initial !important; background-clip: initial !important; background-color: rgb(255, 255, 255) !important; background-image: none !important; background-origin: initial !important; border-bottom-color: rgb(224, 224, 224) !important; border-bottom-style: solid !important; border-bottom-width: 1px !important; border-color: initial !important; border-left-color: rgb(224, 224, 224) !important; border-left-style: solid !important; border-left-width: 1px !important; border-right-color: rgb(224, 224, 224) !important; border-right-style: solid !important; border-right-width: 1px !important; border-style: initial !important; border-top-color: rgb(224, 224, 224) !important; border-top-style: solid !important; border-top-width: 1px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 1em !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 1em !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: relative !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: 623px;"&gt;
&lt;div class="lines" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;
&lt;div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-color: rgb(255, 255, 255) !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;
&lt;table style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-collapse: collapse !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;&lt;tbody style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;
&lt;tr style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;&lt;td class="number" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: top !important; width: 3em !important;"&gt;&lt;code style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0.3em !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: right !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;"&gt;1&lt;/code&gt;&lt;/td&gt;&lt;td class="content" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-color: rgb(204, 204, 204) !important; border-left-style: solid !important; border-left-width: 3px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: top !important; width: auto !important;"&gt;&lt;code class="plain" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; font-style: normal !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"&gt;iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style="padding-bottom: 15px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
eth0 dan port 8080 sesuaikan dengan network anda.&lt;br /&gt;lalu save dan restart ip-tablesnya&lt;br /&gt;service iptables save&lt;br /&gt;service iptables restart&lt;br /&gt;atau silahkan mencari referensi sendiri sesuai distro masing-masing&amp;nbsp;&lt;img alt=":)" class="wp-smiley" src="http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif?m=1306159899g" style="border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; float: none; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; max-width: 100%; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;&lt;/div&gt;
&lt;div style="padding-bottom: 15px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
Selamat mencoba!&lt;/div&gt;
&lt;div style="padding-bottom: 15px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
diantaranya yang sudah sukses mencoba di FMI&lt;br /&gt;&lt;a href="http://www.forummikrotik.com/general-networking/16234-gagal-memisahkan-iix-dan-internasional-dengan-connection-bytes-proxy-external.html" style="color: #008dcf; text-decoration: none;" target="_blank" title="Forummikrotik"&gt;Forummikrotik&lt;/a&gt;&lt;br /&gt;&lt;a href="http://wiki.warneter.net/mengatasi-traffic-limit-pada-ip-proxy.aspx" style="color: #008dcf; text-decoration: none;" target="_blank" title="wiki.warneter.net"&gt;wiki.warneter.net&lt;/a&gt;&lt;/div&gt;
&lt;div style="padding-bottom: 15px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
dan inilah cuplikan bw management yang simple gk pake ribet kalau di lihat juga gak bikin mumet&amp;nbsp;&lt;img alt=":D" class="wp-smiley" src="http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif?m=1306159899g" style="border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; float: none; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; max-width: 100%; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" /&gt;&lt;br /&gt;klik untuk memperbesar gambar&lt;/div&gt;
&lt;div style="padding-bottom: 15px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="padding-bottom: 15px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;a href="http://reges007.wordpress.com/2011/05/22/perbedaan-redirect-to-proxy-memakai-dst-nat-dan-mark-routing/"&gt;http://reges007.wordpress.com/2011/05/22/perbedaan-redirect-to-proxy-memakai-dst-nat-dan-mark-routing/&lt;/a&gt;&lt;/div&gt;
</description><author>emaknyus@gmail.com (tamvan &amp;amp; verani)</author></item><item><title>td 8117 exploit</title><link>http://emaknyus.blogspot.com/2011/09/td-8117-exploit.html</link><category>exploit</category><pubDate>Sat, 10 Sep 2011 01:16:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3787219161379371544.post-1490944813194080763</guid><description>&lt;br /&gt;
http://carnal0wnage.attackresearch.com/&lt;br /&gt;
http://www.exploit-db.com/exploits/10276/&lt;br /&gt;
http://www.securityfocus.com/archive/1/349085&lt;br /&gt;
&lt;a href="http://www.cvedetails.com/"&gt;http://www.cvedetails.com&lt;/a&gt;</description><author>emaknyus@gmail.com (tamvan &amp;amp; verani)</author></item><item><title>ultimate.sh</title><link>http://emaknyus.blogspot.com/2011/09/ultimatesh.html</link><category>bash</category><category>script</category><category>tc</category><category>u32</category><pubDate>Thu, 8 Sep 2011 16:52:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3787219161379371544.post-996328024934951839</guid><description>&lt;span class="Apple-style-span" style="color: black; font-family: 'Times New Roman'; font-size: small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"&gt;&lt;pre&gt;#!/bin/bash
# ultimate.sh for duron
# Based on Wonder Shaper v1.1a
echo "/usr/sbin/ultimate.sh:  "

# Please read the README before filling out these values.
# Set the following values to somewhat less than your actual download
# and upload speed in kilobits.  Also set the device that is to be shaped.

# Run a speed test from netspeed.stanford.edu with no shaping enabled.
# Multiply the reported rates in Kb/s by ~.95 and enter them here:
# Example: DNLINK=4.76M*.95 = 4522
#          UPLINK=444.26K*.95 = 422
# Run the stanford test again.  Note: stanford uses high ports.
# Tweak during heavy upload so that each affected class has a small backlog but
# as few dropped packets as possible.  Interactive must NEVER backlog!
# If heavy downloads affect uploads, tweak IMQ so there is a small backlog but
# as few dropped packets as possible.
# Watch the logs for "some class has too small rate" even with quantum set.
# Stanford is in class 30; egress rate 36% ceil 92%, ingress rate 57% ceil 92%
# Download w/HTB is plenty (5.2x), don't tweak.
# Upload w/UPLINK=470 -&amp;gt; range 416 - 420 = ~85% of uCEIL.  Try for 90% - 91%.&lt;/pre&gt;
&lt;pre&gt;&lt;a name='more'&gt;&lt;/a&gt;
dCEIL=9740	# Stanford max down with no shaping (best of 3 tests)
DNLINK=9350	# (.95*dCEIL, rounded down)
uCEIL=974	# Stanford max up (best of 3 tests).
UPLINK=952	# Tweak.  (was 470=.95*uCEIL, rounded up)
# Percentages, egress:
# sum(Ie + Ae + Be + Pe) _MUST_ = 100
Ie=7			# Interactive
Ae=50			# Accelerated
Be=36			# Bulk
Pe=7			# Penalized

# Percentages, ingress (IMQ):
# sum(Ii + Ai + Bi) _MUST_ = 100
Ii=5			# Interactive
Ai=38			# Accelerated
Bi=57			# Bulk

IFE=eth1		# Egress NIC; External Interface
IMQ=imq0		# Egress NIC - shape incoming

# Local IPs:
ATJ=`cat /etc/firewall/Duron`

# Remote IPs:
#ADE="216.196.97.0/24"	# adelphia.net
CHS=""	# chsoft.biz
DMF=""	# Diana's
NGUY="74.209.0.80/28"	# Newsguy
#HBED1="62.146.66.160/27" # H+BEDV (antivirus)
#HBED2="217.11.60.0/27"	# H+BEDV (antivirus)
#ISW1="207.178.128.0/24"	# iswest
#ISW2="216.166.71.0/24"	# iswest
#ISW3="216.196.105.0/24"	# iswest (giganews)
LHD1=""	# L. H. Dottie
LHD2=""	# L. H. Dottie
#NEWS=""	# news.chsoft.biz
NSAD="67.21.15.0/24"	# Adelphia dns servers
NSTW="66.75.164.0/24"	# Time Warner dns servers
#QUE1="63.231.95.0/24"	# quest
#QUE2="207.225.159.0/24"	# quest
SC=`cat /etc/firewall/SupportJ`	# Note that ports 5500 and 5900 have priority
#TERA="66.150.105.0/24"	# teranews
WALK=""	# Walker Foods
#YIC=""	# yesican.chsoft.biz

###### EXPLANATION
# See 'INGRESS' below for information about incoming packets.  All of this
# except for that refers to queueing outgoing packets.
#
# Most of what is sent goes out on a randomly selected high SOURCE port 
# ('sport') to a specific DESTINATION port ('dport').  For example, an http 
# request is sent with 'dport' = 80 and 'sport' = random.  Therefore, 'sport'
# specifications are rarely applicable.  The port number is located in the
# packet header and is specified thus:
# "u32 match ip dport PORT# 0xffff" or "u32 match ip sport PORT# 0xffff"
#
# Since shaping means quequeing OUTGOING packets, your IP Address(es) are 
# SOURCEs ('src') and the remote machine's IP Address(es) are DESTINATIONs 
# ('dst') - so, as with 'sport', 'src' specifications are rarely applicable. 
# The IP Address is located in the packet header and is specified thus:
# "u32 match ip src IP-ADDRESS" or "u32 match ip dst IP-ADDRESS"
#
# Read the HOWTO "All the filtering commands you will normally need" for
# protocol information (TCP, UDP, ICMP, GRE, IPSEC).  Also see the TOS and
# ICMP sections below.
######

# Sometimes you may notice low priority OUTGOING traffic slowing down important
# traffic. In that case, the following eLoPrio options may help you:

## * * * * Structure:
## {1} * * * * * IFE DEFINITIONS
## {2} * * * * * EGRESS on IFE (HERE --&amp;gt; INTERNET)
## {3} * * * * * IMQ INGRESS shaping on IFE (HERE &amp;lt;-- INTERNET)

###### {1} External Interface DEFINITIONS:
#			Ports:
# eLoPrioSPORT ('sport')
#	Set this to source ports that should have low priority.  If you have
#	an unimportant webserver on your traffic, set this to 80.
# These go into class 40
#   (some ports        ) 20   21    22 23 25   53  80   113   119  873 
#   (and what they are:) FTPd FTPc  SSH   SMTP DNS HTTP IDENT NNTP Rsync
# 9001 is tor Server, 9030 is tor Directory
# Search 6881 for torrent special handling (1:40)
# Matches FROM me:PORT 
eLoPrioSPORT="8 21 23 67 68 79 110 135 137 138 139 389 445 446 901 1026 1027 1028 1029 1234 5018"

# eHiPrioSPORT ('sport')
# These go into class 20.  SSH and scp are interactive (class 10).
# *** Make sure no eLoPrioSPORTs are duplicated here! ***
# Matches (apparently) nothing.
eHiPrioSPORT="113 119 123 443 563 873 5500 5900"

# eLoPrioDPORT ('dport')
#	Set this to destination ports that should have low priority. 
# The following are from my TARPIT list: 79 135 137 138 139 445 901
# Matches DIR=FROM? remote:PORT
# These go into class 40
eLoPrioDPORT="8 21 23 67 68 79 110 135 137 138 139 389 445 446 901 1026 1027 1028 1029 1234 5018"

# eHiPrioDPORT ('dport')
# *** Make sure no eLoPrioDPORTs are duplicated here! ***  ssh is interactive.
# Matches DIR=FROM? ?:PORT
# These go into class 20
eHiPrioDPORT="113 119 123 443 563 873 5500 5900"

#			IPs / Netmasks:
# Set this to hosts or netmasks in your network that should have low priority.
# Low priority OUTGOING traffic.  You can leave this blank if you want.
# Matches TO REMOTE
# These go into class 40
eLoPrioCIDR_Src=""
#eLoPrioCIDR_Src="$ATJ"

# See EXPLANATION above; these do not need to be here.
# Matches (apparently) nothing.
# These go into class 20
eHiPrioCIDR_Src="$CHS $LHD1 $NGUY $SC $WALK"

# Set this to hosts or netmasks on the internet that should have low priority.
# Matches FROM REMOTE
# These go into class 40
eLoPrioCIDR_Dst="221.0.0.0/8"

# high priority destination netmasks ('dst'):
# Matches DIR? REMOTE:IP
# These go into class 20
eHiPrioCIDR_Dst="$CHS $LHD1 $NGUY $SC $WALK"
###### End External Interface DEFINITIONS

if [ "$1" = "status" ]; then
	echo "Sent on $IFE:"
# 	tc -s filter show dev $IFE
	tc -d qdisc ls dev $IFE
	tc -s qdisc ls dev $IFE
	tc -s class ls dev $IFE
	echo "'rate #bit' means Bytes per Second"
	echo "Received on $IMQ:"
#	tc -s filter show dev $IMQ
	tc -d qdisc ls dev $IMQ
	tc -s qdisc ls dev $IMQ
	tc -s class ls dev $IMQ
	echo "'rate #bit' is meaningless.  Measure by Backlog and Dropped."
	exit
fi

# Clean existing setup, hiding errors
tc qdisc del dev $IFE root	2&amp;gt; /dev/null &amp;gt; /dev/null
tc qdisc del dev $IFE ingress	2&amp;gt; /dev/null &amp;gt; /dev/null
iptables -t mangle -D PREROUTING -i $IFE -j IMQ --todev 0	2&amp;gt;/dev/null &amp;gt; /dev/null
tc qdisc del dev $IMQ root	2&amp;gt; /dev/null &amp;gt; /dev/null
ip link set $IMQ down		2&amp;gt; /dev/null &amp;gt; /dev/null
modprobe -r ipt_IMQ		# iptables
modprobe -r imq			# device
modprobe -r cls_u32
modprobe -r sch_esfq		# requires modified tc
modprobe -r sch_sfq
modprobe -r sch_htb
modprobe -r sch_ingress

if [ "$1" = "stop" ]; then 
	exit
fi

###### {2} uplink (EGRESS) on IFE
# This part shapes on the external interface:  (HERE --&amp;gt; INTERNET)
# Install root HTB, point default traffic to 1:30:
tc qdisc add dev $IFE root handle 1: htb default 30

# Shape everything at $UPLINK speed - this prevents huge queues in your
# DSL modem which destroy latency:
tc class add dev $IFE parent 1: classid 1:1 htb rate ${uCEIL}kbit burst 32k cburst 20k

# High prio (interactive) class 1:10:
tc class add dev $IFE parent 1:1 classid 1:10 htb rate $[Ie*$UPLINK/100]kbit \
   ceil ${uCEIL}kbit burst 32k cburst 20k quantum 1514 prio 1

# Accelerated class 1:20 - the HIPRIO stuff:
tc class add dev $IFE parent 1:1 classid 1:20 htb rate $[Ae*$UPLINK/100]kbit \
   ceil $[96*$uCEIL/100]kbit burst 16k cburst 10k quantum 1514 prio 2

# Bulk &amp;amp; default class 1:30 - gets a low priority:
tc class add dev $IFE parent 1:1 classid 1:30 htb rate $[Be*$UPLINK/100]kbit \
   ceil $[92*$UPLINK/100]kbit burst 8k cburst 5k quantum 1514 prio 3
#   ceil $[Ae*$UPLINK/100]kbit burst 8k cburst 5k quantum 1514 prio 3

# Penalized class 1:40 - the LOPRIO stuff gets the lowest rate and priority:
tc class add dev $IFE parent 1:1 classid 1:40 htb rate $[Pe*$UPLINK/100]kbit \
   ceil $[80*$UPLINK/100]kbit burst 2k quantum 1514 prio 4
#   ceil $[Be*$UPLINK/100]kbit burst 2k quantum 1514 prio 4

# Some get Stochastic Fairness:
# LARTC mailing list indicates that interactive should not be included.  Andy
# Furniss suggests that bulk be the only thing subject to SF.  I set a long
# perturb for accelerated and exclude interactive.
# Increased limit from 64 to reduce # of dropped packets 7Dec07
# 11Dec07: esfq limit must be less than or equal depth; depth max = 1024:
#tc qdisc add dev $IFE parent 1:10 handle 10: esfq limit 64 depth 64 divisor 10 hash classic perturb 20
tc qdisc add dev $IFE parent 1:20 handle 20: esfq limit 256 depth 256 divisor 10 hash classic perturb 99
tc qdisc add dev $IFE parent 1:30 handle 30: esfq limit 1024 depth 1024 divisor 10 hash classic perturb 20
tc qdisc add dev $IFE parent 1:40 handle 40: esfq limit 32 depth 32 divisor 10 hash classic perturb 10

# ARP:
tc filter add dev $IFE parent 1: protocol all prio 5 u32 \
   match u16 0x0806 0xffff at -2 flowid 1:40

###### Accelerate (interactive) the following:
# To speed up downloads while an upload is going on, put ACK packets in
# the interactive class 1:10:
# IP header length 0x5 (32 bit words)
# IP total length 0x34 (ACK + 12 bytes of TCP options)
# TCP ACK set (bit 5, offset 33)
# ("at nexthdr+33" = "at 13")

## Match ACK on all TCP packets with the ACK bit set:
## Caveat!: This can match packets up to 64K; don't do it.  Match small.
#tc filter add dev $IFE parent 1: protocol all prio 5 u32 \
#    match ip protocol 6 0xff \
#    match u8 0x10 0xff at nexthdr+13 \
#    flowid 1:10

# Match TCP packets smaller than 128 bytes:
# Because of the mask, can only match powers of 2 (32, 64, 128...)
# 0xfff8 - 8
# 0xfff0 - 16
# 0xffe0 - 32
# 0xffc0 - 64
# 0xff80 - 128
# Remarked out ACK, normally 5th line:  match u8 0x10 0xff at 33 \
# "match u8 0x05 0x0f at 0" makes sure the IP header is 20 bytes.
tc filter add dev $IFE parent 1: protocol all prio 5 u32 \
    match ip protocol 6 0xff \
    match u8 0x05 0x0f at 0 \
    match u16 0x0000 0xff80 at 2 \
    flowid 1:10

# SSH and scp are interactive.
tc filter add dev $IFE parent 1: protocol all prio 5 u32 \
    match ip dport 22 0xffff flowid 1:10
tc filter add dev $IFE parent 1: protocol all prio 5 u32 \
    match ip sport 22 0xffff flowid 1:10

# dns is interactive:
tc filter add dev $IFE parent 1: protocol all prio 5 u32 \
    match ip dport 53 0xffff flowid 1:10
tc filter add dev $IFE parent 1: protocol all prio 5 u32 \
    match ip sport 53 0xffff flowid 1:10

###### Some traffic is preferred, so in our class 1:20:
for a in $eHiPrioDPORT; do
 	tc filter add dev $IFE parent 1: protocol all prio 5 u32 \
	   match ip dport $a 0xffff flowid 1:20
done
for a in $eHiPrioSPORT; do
 	tc filter add dev $IFE parent 1: protocol all prio 5 u32 \
	   match ip sport $a 0xffff flowid 1:20
done
for a in $eHiPrioCIDR_Src; do
 	tc filter add dev $IFE parent 1: protocol all prio 5 u32 \
	   match ip src $a flowid 1:20
done
for a in $eHiPrioCIDR_Dst; do
 	tc filter add dev $IFE parent 1: protocol all prio 5 u32 \
	   match ip dst $a flowid 1:20
done

###### Give these short shrift:
# Penalized traffic suffers a worse fate in our slowest class 1:40:
# Special for torrents ports 6880-6887:
# The mask determines the number of ports: ffff=1 fffe=2 fffc=4 fff8=8 fff0=16
tc filter add dev $IFE parent 1: protocol all prio 5 u32 \
   match ip dport 6881 0xfff8 flowid 1:40
tc filter add dev $IFE parent 1: protocol all prio 5 u32 \
   match ip sport 6881 0xfff8 flowid 1:40
for a in $eLoPrioDPORT; do
	tc filter add dev $IFE parent 1: protocol all prio 5 u32 \
	   match ip dport $a 0xffff flowid 1:40
done
for a in $eLoPrioSPORT; do
 	tc filter add dev $IFE parent 1: protocol all prio 5 u32 \
	   match ip sport $a 0xffff flowid 1:40
done
for a in $eLoPrioCIDR_Src; do
 	tc filter add dev $IFE parent 1: protocol all prio 5 u32 \
	   match ip src $a flowid 1:40
done
for a in $eLoPrioCIDR_Dst; do
 	tc filter add dev $IFE parent 1: protocol all prio 5 u32 \
	   match ip dst $a flowid 1:40
done
if [ -f /etc/firewall/shitlist ]; then
   while read SLIST; do
      SLIST=$(echo "$SLIST" | awk '{print $1}')
      tc filter add dev $IFE parent 1: protocol all prio 5 u32 \
         match ip dst $SLIST flowid 1:40
   done &amp;lt;-- INTERNET)
modprobe imq numdevs=1
# Since class 1:10 uses the default pfifo_fast, we need to give it txqueuelen
# packets because pfifo_fast drops incoming packets when the queue fills up:
ip link set $IMQ up txqueuelen 1024 mtu 1500

# Install root HTB, point default traffic to 1:30:
tc qdisc add dev $IMQ root handle 1: htb default 30

# Shape everything at DNLINK speed:
# Root class
tc class add dev $IMQ parent 1: classid 1:1 htb rate ${dCEIL}kbit burst 32k \
  cburst 20k quantum 1500

# High priority (interactive) class 1:10
tc class add dev $IMQ parent 1:1 classid 1:10 htb rate $[Ii*$DNLINK/100]kbit \
   ceil ${dCEIL}kbit burst 32k cburst 20k quantum 1500 prio 1

# Accelerated class 1:20 
tc class add dev $IMQ parent 1:1 classid 1:20 htb rate $[Ai*$DNLINK/100]kbit \
   ceil $[96*$dCEIL/100]kbit burst 16k cburst 10k quantum 1500 prio 2

# Bulk &amp;amp; default class 1:30
tc class add dev $IMQ parent 1:1 classid 1:30 htb rate $[Bi*$DNLINK/100]kbit \
   ceil $[92*$dCEIL/100]kbit burst 8k cburst 5k quantum 1500 prio 3

# Stochastic Fairness
tc qdisc add dev $IMQ parent 1:20 handle 20: esfq limit 1024 depth 1024 divisor 10 hash dst perturb 99 
tc qdisc add dev $IMQ parent 1:30 handle 30: esfq limit 768 depth 768 divisor 10 hash dst perturb 20 

# Interactive ports:
IMQint="22 53 5500 5900"

# Accelerated ports:
IMQacc="80 113 123 443 873 6502"

for a in $IMQint; do
   tc filter add dev $IMQ parent 1: protocol all prio 5 u32 match \
      ip dport $a 0xffff flowid 1:10
   tc filter add dev $IMQ parent 1: protocol all prio 5 u32 match \
      ip sport $a 0xffff flowid 1:10
done

for a in $IMQacc; do
   tc filter add dev $IMQ parent 1: protocol all prio 5 u32 match \
      ip dport $a 0xffff flowid 1:20
   tc filter add dev $IMQ parent 1: protocol all prio 5 u32 match \
      ip sport $a 0xffff flowid 1:20
done

# Not needed because 1:30 is default:
## Match everything else: 
#tc filter add dev $IMQ parent 1: protocol all prio 5 u32 match u32 0 0 flowid 1:30

iptables -t mangle -I PREROUTING -i $IFE -j IMQ --todev 0

# Done ultimate.sh&lt;/pre&gt;
&lt;/span&gt;</description><author>emaknyus@gmail.com (tamvan &amp;amp; verani)</author></item><item><title>fw_function</title><link>http://emaknyus.blogspot.com/2011/09/fwfunction.html</link><category>bash</category><category>script</category><pubDate>Thu, 8 Sep 2011 16:51:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3787219161379371544.post-1008792998582830919</guid><description>#-----------------------&lt;br /&gt;# FONCTIONS Firewall&lt;br /&gt;# guibo@guibo.com&lt;br /&gt;# version 1.2&lt;br /&gt;# tested on slk&lt;br /&gt;#-----------------------&lt;br /&gt;&lt;br /&gt;load_module() {&lt;br /&gt;IP_MODULES=`/sbin/lsmod | awk '{print $1}' | /bin/grep '^ip' | grep $1`&lt;br /&gt;if [ -z "$IP_MODULES" ]; then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if [ -e $PATH_modules/$1.$EXTENSION_module ]; then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; /sbin/insmod $PATH_modules/$1.$EXTENSION_module&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo " - MUST HAVE Compiled kernel $1 support"&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fi&lt;br /&gt;fi&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;load_module_q() {&lt;br /&gt;IP_MODULES=`/sbin/lsmod | awk '{print $1}'`&lt;br /&gt;if [ -z "$IP_MODULES" ]; then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if [ -e $PATH_modules_q/$1.$EXTENSION_module ]; then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; /sbin/insmod $PATH_modules_q/$1.$EXTENSION_module&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo " - MUST HAVE Compiled kernel $1 support"&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fi&lt;br /&gt;fi&lt;br /&gt;}&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;flush_regle() {&lt;br /&gt;echo " - Flushing Table"&lt;br /&gt;$IPTABLES -F&lt;br /&gt;$IPTABLES -F -t mangle&lt;br /&gt;$IPTABLES -t mangle -X&lt;br /&gt;$IPTABLES -t filter -F INPUT&lt;br /&gt;$IPTABLES -t filter -F OUTPUT&lt;br /&gt;$IPTABLES -t filter -F FORWARD&lt;br /&gt;$IPTABLES -t nat --flush PREROUTING&lt;br /&gt;$IPTABLES -t nat --flush POSTROUTING&lt;br /&gt;$IPTABLES -t nat --flush OUTPUT&lt;br /&gt;$IPTABLES -X&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;zero_compteur() {&lt;br /&gt;echo " - Reseting compteur"&lt;br /&gt;$IPTABLES -t filter -Z INPUT&lt;br /&gt;$IPTABLES -t filter -Z OUTPUT&lt;br /&gt;$IPTABLES -t filter -Z FORWARD&lt;br /&gt;$IPTABLES -t nat -Z PREROUTING&lt;br /&gt;$IPTABLES -t nat -Z POSTROUTING&lt;br /&gt;$IPTABLES -t nat -Z OUTPUT&lt;br /&gt;$IPTABLES -t mangle -F &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;config_kernel() {&lt;br /&gt;echo " - Rejecting non routable ip"&lt;br /&gt;for i in $KERNEL_conf/conf/*/rp_filter ; do echo 1 &amp;gt; $i ; done&lt;br /&gt;echo " - Logging Martians"&lt;br /&gt;if [ -e $KERNEL_conf/conf/all/log_martians ]; then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for i in $KERNEL_conf/conf/*/log_martians ; do&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo 1 &amp;gt; $i ; done&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fi&lt;br /&gt;echo " - Ignore broadcast PING"&lt;br /&gt;if [ -e $KERNEL_conf/icmp_echo_ignore_broadcasts ]; then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo 1 &amp;gt; $KERNEL_conf/icmp_echo_ignore_broadcasts&lt;br /&gt;fi&lt;br /&gt;echo " - Icmp Bogus reponse"&lt;br /&gt;if [ -e $KERNEL_conf/icmp_ignore_bogus_error_responses ]; then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo 1 &amp;gt; $KERNEL_conf/icmp_ignore_bogus_error_responses&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fi&lt;br /&gt;echo " - DROP icmp_redirect"&lt;br /&gt;if [ -e $KERNEL_conf/conf/all/accept_redirects ]; then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo 0 &amp;gt; $KERNEL_conf/conf/all/accept_redirects&lt;br /&gt;fi&lt;br /&gt;echo " - Active ip_forward"&lt;br /&gt;echo 1 &amp;gt; $KERNEL_conf/ip_forward&lt;br /&gt;if [ -e $KERNEL_conf/conf/all/accept_source_route ];then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo 1 &amp;gt; $KERNEL_conf/conf/all/accept_source_route&lt;br /&gt;fi&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;net_redirect() {&lt;br /&gt;IF_EXT=$1&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; # external interface &lt;br /&gt;PORT_ex=$2&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; # external port to redirect&lt;br /&gt;IP_REDIR_in=$3&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; # internal IP &lt;br /&gt;PORT_REDIR_in=$4&amp;nbsp;&amp;nbsp;&amp;nbsp; # internal port&lt;br /&gt;echo " - Redirecting $IF_EXT:$PORT_ex to $IP_REDIR_in:$PORT_REDIR_in"&lt;br /&gt;$IPTABLES -A FORWARD -p tcp -i $IF_EXT --dport $PORT_ex -j ACCEPT&lt;br /&gt;$IPTABLES -A OUTPUT -p tcp -o $IF_EXT --dport $PORT_ex -j ACCEPT&lt;br /&gt;&lt;br /&gt;$IPTABLES -t nat -A PREROUTING -p tcp -i $IF_EXT --dport $PORT_ex \&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -j DNAT --to $IP_REDIR_in:$PORT_REDIR_in&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;default_rule() {&lt;br /&gt;echo " - Default rule set"&lt;br /&gt;$IPTABLES -P INPUT DROP&lt;br /&gt;$IPTABLES -P FORWARD DROP&lt;br /&gt;$IPTABLES -P OUTPUT ACCEPT&lt;br /&gt;# $IPTABLES -A FORWARD -f -j ACCEPT # accept fragment &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;block_nmap() {&lt;br /&gt;echo " - Creating VALID_CHECK rule"&lt;br /&gt;$IPTABLES -N VALID_CHECK &lt;br /&gt;$IPTABLES -F VALID_CHECK&lt;br /&gt;&lt;br /&gt;LOGLEVEL=7&lt;br /&gt;# (NMAP) FIN/URG/PSH&lt;br /&gt;$IPTABLES -A VALID_CHECK -p tcp --tcp-flags ALL FIN,URG,PSH -m limit --limit 3/m --limit-burst 5 -j LOG --log-level $LOGLEVEL --log-prefix "Stealth XMAS scan: "&lt;br /&gt;&lt;br /&gt;# SYN/RST/ACK/FIN/URG&lt;br /&gt;$IPTABLES -A VALID_CHECK -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -m limit --limit 3/m --limit-burst 5 -j LOG --log-level $LOGLEVEL --log-prefix "Stealth XMAS-PSH scan: "&lt;br /&gt;&lt;br /&gt;# ALL/ALL&lt;br /&gt;$IPTABLES -A VALID_CHECK -p tcp --tcp-flags ALL ALL -m limit --limit 3/m --limit-burst 5 -j LOG --log-level $LOGLEVEL --log-prefix "Stealth XMAS-ALL scan: "&lt;br /&gt;&lt;br /&gt;# NMAP FIN Stealth&lt;br /&gt;$IPTABLES -A VALID_CHECK -p tcp --tcp-flags ALL FIN -m limit --limit 3/m --limit-burst 5 -j LOG --log-level $LOGLEVEL --log-prefix "Stealth FIN scan: "&lt;br /&gt;&lt;br /&gt;# SYN/RST&lt;br /&gt;$IPTABLES -A VALID_CHECK -p tcp --tcp-flags SYN,RST SYN,RST -m limit --limit 3/m --limit-burst 5 -j LOG --log-level $LOGLEVEL --log-prefix "Stealth SYN/RST scan: "&lt;br /&gt;&lt;br /&gt;# SYN/FIN (probably)&lt;br /&gt;$IPTABLES -A VALID_CHECK -p tcp --tcp-flags SYN,FIN SYN,FIN -m limit --limit 3/m --limit-burst 5 -j LOG --log-level $LOGLEVEL --log-prefix "Stealth SYN/FIN scan(?): "&lt;br /&gt;&lt;br /&gt;# Null scan&lt;br /&gt;$IPTABLES -A VALID_CHECK -p tcp --tcp-flags ALL NONE -m limit --limit 3/m --limit-burst 5 -j LOG --log-level $LOGLEVEL --log-prefix "Stealth Null scan: "&lt;br /&gt;&lt;br /&gt;# NMAP FIN/URG/PSH&lt;br /&gt;$IPTABLES -A VALID_CHECK -p tcp --tcp-flags ALL FIN,URG,PSH -j DROP&lt;br /&gt;&lt;br /&gt;# SYN/RST/ACK/FIN/URG&lt;br /&gt;$IPTABLES -A VALID_CHECK -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -j DROP&lt;br /&gt;&lt;br /&gt;# ALL/ALL Scan&lt;br /&gt;$IPTABLES -A VALID_CHECK -p tcp --tcp-flags ALL ALL -j DROP&lt;br /&gt;&lt;br /&gt;# NMAP FIN Stealth&lt;br /&gt;$IPTABLES -A VALID_CHECK -p tcp --tcp-flags ALL FIN -j DROP&lt;br /&gt;&lt;br /&gt;# SYN/RST&lt;br /&gt;$IPTABLES -A VALID_CHECK -p tcp --tcp-flags SYN,RST SYN,RST -j DROP&lt;br /&gt;&lt;br /&gt;# SYN/FIN -- Scan(probably)&lt;br /&gt;$IPTABLES -A VALID_CHECK -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROP&lt;br /&gt;&lt;br /&gt;# NMAP Null Scan&lt;br /&gt;$IPTABLES -A VALID_CHECK -p tcp --tcp-flags ALL NONE -j DROP&lt;br /&gt;&lt;br /&gt;# Port 0 fingerprint attempt&lt;br /&gt;echo " - Detecting Fingerprint attempt"&lt;br /&gt;$IPTABLES -N CHECK&lt;br /&gt;$IPTABLES -F CHECK&lt;br /&gt;$IPTABLES -A CHECK -p tcp --dport 0 -m limit --limit 1/h --limit-burst 1 -j LOG --log-level $LOGLEVEL --log-prefix "TCP port 0 OS fingerprint: "&lt;br /&gt;$IPTABLES -A CHECK -p udp --dport 0 -m limit --limit 1/h --limit-burst 1 -j LOG --log-level $LOGLEVEL --log-prefix "UDP port 0 OS fingerprint: "&lt;br /&gt;&lt;br /&gt;# Drop port 0 port scan packets&lt;br /&gt;$IPTABLES -A CHECK -p tcp --dport 0 -j DROP&lt;br /&gt;$IPTABLES -A CHECK -p udp --dport 0 -j DROP&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;set_tos() {&lt;br /&gt;# TOS table&lt;br /&gt;# Options:&lt;br /&gt;#&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Normal-Service = 0 (0x00)&lt;br /&gt;#&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Minimize-Cost = 2 (0x02)&lt;br /&gt;#&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Maximize-Reliability = 4 (0x04)&lt;br /&gt;#&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Maximize-Throughput = 8 (0x08)&lt;br /&gt;#&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Minimize-Delay = 16 (0x10)&lt;br /&gt;IF_EXT=$1&lt;br /&gt;echo " - Setting Tos"&lt;br /&gt;$IPTABLES -t mangle -A OUTPUT -p tcp -o $IF_EXT --dport ftp-data -j TOS --set-tos Minimize-Cost&lt;br /&gt;$IPTABLES -t mangle -A OUTPUT -p tcp -o $IF_EXT --dport ftp -j TOS --set-tos Maximize-Throughput&lt;br /&gt;$IPTABLES -t mangle -A OUTPUT -p tcp -o $IF_EXT --dport ssh -j TOS --set-tos Minimize-Delay&lt;br /&gt;#$IPTABLES -t mangle -A OUTPUT -p tcp -o $IF_EXT --dport telnet -j TOS --set-tos Minimize-Delay&lt;br /&gt;$IPTABLES -t mangle -A OUTPUT -p tcp -o $IF_EXT --dport smtp -j TOS --set-tos Minimize-Cost&lt;br /&gt;$IPTABLES -t mangle -A OUTPUT -p udp -o $IF_EXT --dport domain -j TOS --set-tos Maximize-Throughput&lt;br /&gt;#$IPTABLES -t mangle -A OUTPUT -p tcp -o $IF_EXT --dport bootps -j TOS --set-tos Minimize-Delay&lt;br /&gt;# to add http in priority list of QoS, is set in Minimize-Delay not in Maximize-Throughput&lt;br /&gt;$IPTABLES -t mangle -A OUTPUT -p tcp -o $IF_EXT --dport http -j TOS --set-tos Minimize-Delay&lt;br /&gt;# http internal&lt;br /&gt;$IPTABLES -t mangle -A OUTPUT -p tcp -o $IF_EXT --dport 81 -j TOS --set-tos Minimize-Delay&lt;br /&gt;$IPTABLES -t mangle -A OUTPUT -p tcp -o $IF_EXT --dport pop3 -j TOS --set-tos Maximize-Throughput&lt;br /&gt;$IPTABLES -t mangle -A OUTPUT -p tcp -o $IF_EXT --dport auth -j TOS --set-tos Minimize-Delay&lt;br /&gt;$IPTABLES -t mangle -A OUTPUT -p tcp -o $IF_EXT --dport ntp -j TOS --set-tos Minimize-Delay&lt;br /&gt;$IPTABLES -t mangle -A OUTPUT -p tcp -o $IF_EXT --dport imap -j TOS --set-tos Maximize-Throughput&lt;br /&gt;$IPTABLES -t mangle -A OUTPUT -p tcp -o $IF_EXT --dport https -j TOS --set-tos Maximize-Throughput&lt;br /&gt;$IPTABLES -t mangle -A OUTPUT -p tcp -o $IF_EXT --dport imaps -j TOS --set-tos Maximize-Throughput&lt;br /&gt;$IPTABLES -t mangle -A OUTPUT -p tcp -o $IF_EXT --dport pop3s -j TOS --set-tos Maximize-Throughput&lt;br /&gt;$IPTABLES -t mangle -A OUTPUT -p tcp -o $IF_EXT --dport socks -j TOS --set-tos Minimize-Delay&lt;br /&gt;$IPTABLES -t mangle -A OUTPUT -p tcp -o $IF_EXT --dport 6000:6063 -j TOS --set-tos Maximize-Throughput&lt;br /&gt;&lt;br /&gt;# rules for mldonkey&lt;br /&gt;$IPTABLES -t mangle -A OUTPUT -p tcp -o $IF_EXT --dport 4080 -j MARK --set-mark 1 &lt;br /&gt;$IPTABLES -t mangle -A OUTPUT -p tcp -o $IF_EXT --dport 4662 -j MARK --set-mark 1&lt;br /&gt;&lt;br /&gt;$IPTABLES -t mangle -A PREROUTING -p tcp --dport ftp-data -j TOS --set-tos Minimize-Cost&lt;br /&gt;$IPTABLES -t mangle -A PREROUTING -p tcp --dport ftp -j TOS --set-tos Maximize-Throughput&lt;br /&gt;$IPTABLES -t mangle -A PREROUTING -p tcp --dport ssh -j TOS --set-tos Minimize-Delay&lt;br /&gt;#$IPTABLES -t mangle -A PREROUTING -p tcp --dport telnet -j TOS --set-tos Minimize-Delay&lt;br /&gt;$IPTABLES -t mangle -A PREROUTING -p tcp --dport smtp -j TOS --set-tos Minimize-Cost&lt;br /&gt;$IPTABLES -t mangle -A PREROUTING -p udp --dport domain -j TOS --set-tos Maximize-Throughput&lt;br /&gt;$IPTABLES -t mangle -A PREROUTING -p tcp --dport bootps -j TOS --set-t Minimize-Delay&lt;br /&gt;# http internal&lt;br /&gt;$IPTABLES -t mangle -A PREROUTING -p tcp --dport 81 -j TOS --set-tos Minimize-Delay&lt;br /&gt;$IPTABLES -t mangle -A PREROUTING -p tcp --dport http -j TOS --set-tos Minimize-Delay&lt;br /&gt;$IPTABLES -t mangle -A PREROUTING -p tcp --dport pop3 -j TOS --set-tos Maximize-Throughput&lt;br /&gt;$IPTABLES -t mangle -A PREROUTING -p tcp --dport auth -j TOS --set-tos Minimize-Delay&lt;br /&gt;$IPTABLES -t mangle -A PREROUTING -p tcp --dport ntp -j TOS --set-tos Minimize-Delay&lt;br /&gt;$IPTABLES -t mangle -A PREROUTING -p tcp --dport imap -j TOS --set-tos Maximize-Throughput&lt;br /&gt;$IPTABLES -t mangle -A PREROUTING -p tcp --dport https -j TOS --set-tos Maximize-Throughput&lt;br /&gt;$IPTABLES -t mangle -A PREROUTING -p tcp --dport imaps -j TOS --set-tos Maximize-Throughput&lt;br /&gt;$IPTABLES -t mangle -A PREROUTING -p tcp --dport pop3s -j TOS --set-tos Maximize-Throughput&lt;br /&gt;$IPTABLES -t mangle -A PREROUTING -p tcp --dport socks -j TOS --set-tos Minimize-Delay&lt;br /&gt;$IPTABLES -t mangle -A PREROUTING -p tcp --dport 6000:6063 -j TOS --set-tos Maximize-Throughput&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;masquerade_net() {&lt;br /&gt;HOME_NET=$1 &amp;nbsp;&amp;nbsp;&amp;nbsp; # ex: 10.0.1.0/24&lt;br /&gt;echo " - Masquerading $HOME_NET"&lt;br /&gt;$IPTABLES -t nat -A POSTROUTING -s $HOME_NET -j MASQUERADE&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;accept_tcp() {&lt;br /&gt;IN_ETH=$1 &amp;nbsp;&amp;nbsp;&amp;nbsp; # input interface &lt;br /&gt;PORT=$2 &amp;nbsp;&amp;nbsp;&amp;nbsp; # port for network service&lt;br /&gt;echo " - Accept TCP port $PORT on $IN_ETH"&lt;br /&gt;$IPTABLES -A INPUT -p tcp -i $IN_ETH --dport $PORT -j ACCEPT&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;accept_udp() {&lt;br /&gt;IN_ETH=$1 &amp;nbsp;&amp;nbsp;&amp;nbsp; # input interface &lt;br /&gt;PORT=$2 &amp;nbsp;&amp;nbsp;&amp;nbsp; # port for network service&lt;br /&gt;echo " - Accept UDP port $PORT from $IN_ETH"&lt;br /&gt;$IPTABLES -A INPUT -p udp -i $IN_ETH --dport $PORT -j ACCEPT&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;create_block() {&lt;br /&gt;echo " - Creating Block "&lt;br /&gt;$IPTABLES -N block&lt;br /&gt;$IPTABLES -F block&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;accept_interne() {&lt;br /&gt;# accept all traffic from internal network&lt;br /&gt;echo " - Accept traffic coming from internal"&lt;br /&gt;$IPTABLES -A block -m state --state ESTABLISHED,RELATED -j ACCEPT&lt;br /&gt;$IPTABLES -A block -m state --state NEW -i ! $IF_EXT -j ACCEPT&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;reject_host() {&lt;br /&gt;IF_ETH=$1&lt;br /&gt;IP_DENIED=$2&lt;br /&gt;echo " - Deny $IP_DENIED on $IF_ETH"&lt;br /&gt;$IPTABLES -I INPUT -p tcp -s $IP_DENIED -j DROP&lt;br /&gt;$IPTABLES -I INPUT -p udp -s $IP_DENIED -j DROP&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;reject_tcp_udp() {&lt;br /&gt;IF_ETH=$1&lt;br /&gt;IP_DENIED=$2&lt;br /&gt;PORT=$3&lt;br /&gt;echo " - Deny $IP_DENIED on $IF_ETH port $PORT"&lt;br /&gt;$IPTABLES -I INPUT -p tcp -i $IF_ETH --dport $PORT -s $IP_DENIED -j DROP&lt;br /&gt;$IPTABLES -I INPUT -p udp -i $IF_ETH --dport $PORT -s $IP_DENIED -j DROP&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;drop_trojan() {&lt;br /&gt;PORT_DENY=$1&lt;br /&gt;NAME_trojan=$2&lt;br /&gt;PROTOCOL=$3&lt;br /&gt;echo " - Deny $NAME_trojan $PORT_DENY $PROTOCOL"&lt;br /&gt;$IPTABLES -A DENY_PORTS -p $PROTOCOL --dport $PORT_DENY -m limit --limit 5/minute \&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -j LOG --log-level 7 --log-prefix "$NAME_trojan:"&lt;br /&gt;$IPTABLES -A DENY_PORTS -p $PROTOCOL --sport $PORT_DENY -m limit --limit 5/minute \&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -j LOG --log-level 7 --log-prefix "$NAME_trojan:"&lt;br /&gt;$IPTABLES -A DENY_PORTS -p $PROTOCOL --sport $PORT_DENY -j DROP&lt;br /&gt;$IPTABLES -A DENY_PORTS -p $PROTOCOL --dport $PORT_DENY -j DROP&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;reject_all() {&lt;br /&gt;echo " - Reject all with Block"&lt;br /&gt;$IPTABLES -A block -j LOG&lt;br /&gt;$IPTABLES -A INPUT -j block&lt;br /&gt;$IPTABLES -A FORWARD -j block&lt;br /&gt;$IPTABLES -A block -j REJECT&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;reject_classic() {&lt;br /&gt;echo " - Drop Status invalid, flood and PoD"&lt;br /&gt;# invalid state&lt;br /&gt;$IPTABLES -A INPUT -m state --state INVALID -i $IF_EXT -j DROP&lt;br /&gt;$IPTABLES -A FORWARD -m state --state NEW,INVALID -i $IF_EXT -j DROP&lt;br /&gt;# flood&lt;br /&gt;$IPTABLES -A FORWARD -p tcp --syn -m limit --limit 1/s -j ACCEPT&lt;br /&gt;$IPTABLES -A FORWARD -p tcp --tcp-flags SYN,ACK,FIN,RST RST -m limit --limit 1/s -j ACCEPT&lt;br /&gt;# ping of death&lt;br /&gt;$IPTABLES -A FORWARD -p icmp --icmp-type echo-request -m limit --limit 1/s -j ACCEPT&lt;br /&gt;$IPTABLES -A FORWARD -p icmp --icmp-type echo-request -j DROP&lt;br /&gt;&lt;br /&gt;echo " - Creating and Applying DENY_PORTS"&lt;br /&gt;$IPTABLES -N DENY_PORTS&lt;br /&gt;$IPTABLES -F DENY_PORTS&lt;br /&gt;# samba&lt;br /&gt;$IPTABLES -A DENY_PORTS -p tcp -i $IF_EXT --dport 137:139 -j DROP&lt;br /&gt;$IPTABLES -A DENY_PORTS -p tcp -i $IF_EXT --sport 137:139 -j DROP&lt;br /&gt;# Drop X&lt;br /&gt;$IPTABLES -A DENY_PORTS -p tcp --dport 5999:6063 -j DROP&lt;br /&gt;$IPTABLES -A DENY_PORTS -p tcp --sport 5999:6063 -j DROP&lt;br /&gt;#Drop VNC &lt;br /&gt;$IPTABLES -A DENY_PORTS -p tcp --dport 5900:5910 -j DROP&lt;br /&gt;$IPTABLES -A DENY_PORTS -p tcp --sport 5900:5910 -j DROP&lt;br /&gt;# Drop NFS&lt;br /&gt;$IPTABLES -A DENY_PORTS -p tcp --dport 2049 -j DROP&lt;br /&gt;$IPTABLES -A DENY_PORTS -p tcp --sport 2049 -j DROP&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;mangle_tc() {&lt;br /&gt;# from http://downloads.thedonkeynetwork.com/dserver_patch/shaped&lt;br /&gt;# This script use QOS (Quality OF Service) to control the bandwidth of the Internet line&lt;br /&gt;# Note : QOS controls only the upload&lt;br /&gt;# CBQ uses timers to control the bandwitdh, and a finer resolution of timer means a finer control of&lt;br /&gt;# the bandwidth&lt;br /&gt;echo " - Setting QoS"&lt;br /&gt;UPLINK=$UPLINK&lt;br /&gt;LOWUP=$LOWUP&lt;br /&gt;DEV=$IF_EXT&lt;br /&gt;LOCALNET=$HOME_NET&lt;br /&gt;AVPKT=200&lt;br /&gt;&lt;br /&gt;# clean existing qdiscs, hide errors&lt;br /&gt;tc qdisc del dev $DEV root&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;gt;/dev/null 2&amp;gt;&amp;amp;1&lt;br /&gt;# qdisc&lt;br /&gt;tc qdisc add dev $DEV root handle 1: cbq avpkt $AVPKT bandwidth 10mbit allot 1514 cell 8&amp;nbsp; mpu 96&lt;br /&gt;&lt;br /&gt;# classe locale pour notre reseau local, on utilise 9mbit seulement.&lt;br /&gt;# tc class add dev $DEV parent 1: classid 1:1 cbq bandwidth 10mbit rate 9mbit allot 1514 maxburst 40 avpkt $AVPKT prio 5 bounded&lt;br /&gt;&lt;br /&gt;# shape everything at $UPLINK speed - this prevents huge queues in your&lt;br /&gt;# DSL modem which destroy latency:&lt;br /&gt;# main class&lt;br /&gt;# tc class add dev $DEV parent 1: classid 1:2 cbq bandwidth 10mbit rate ${UPLINK} allot 1514 cell 8 maxburst 10 avpkt $AVPKT bounded prio 1&lt;br /&gt;&lt;br /&gt;# high prio class 1:10:&lt;br /&gt;tc class add dev $DEV parent 1: classid 1:10 cbq rate ${UPLINK} weight 118kbit allot 1514 cell 8 prio 1 avpkt $AVPKT isolated&lt;br /&gt;&lt;br /&gt;# low prio class 1:20:&lt;br /&gt;tc class add dev $DEV parent 1: classid 1:20 cbq rate ${LOWUP} weight 10kbit allot 1514 prio 8 mpu 96 avpkt $AVPKT bounded &lt;br /&gt;&lt;br /&gt;tc qdisc add dev $DEV parent 1:10 handle 10: sfq quantum 1514b perturb 10&lt;br /&gt;tc qdisc add dev $DEV parent 1:20 handle 20: sfq quantum 1514b perturb 10&lt;br /&gt;&lt;br /&gt;# comunications on our LAN are at full speed of the link&lt;br /&gt;# Les communications vers le réseau local sont a 10mbit&lt;br /&gt;# tc filter add dev $DEV parent 1:0 protocol ip prio 5 u32 match ip dst $LOCALNET flowid 1:1&lt;br /&gt;&lt;br /&gt;# TOS Minimum Delay (ssh) prioritaire&lt;br /&gt;# This is for us, admins, who want to log to our machine remotely with SSH&lt;br /&gt;tc filter add dev $DEV parent 1:0 protocol ip prio 5 u32 match ip tos 0x10 0xff&amp;nbsp; flowid 1:10&lt;br /&gt;&lt;br /&gt;# We want SYN packets to be in High priority flow&lt;br /&gt;tc filter add dev $DEV parent 1: protocol ip prio 5 u32 match ip protocol 6 0xff match u8 0x05 0x0f at 0 match u8 0x02 0xff at 33 flowid 1:10&lt;br /&gt;&lt;br /&gt;# everything else in Low priority flow&lt;br /&gt;tc filter add dev $DEV parent 1: protocol ip prio 5 u32 match ip dst 0.0.0.0/0 flowid 1:20&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# mldonkey rules&lt;br /&gt;tc class add dev $DEV parent 1:0 classid 1:3 cbq bandwidth 10Mbit \&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rate 10Kbit allot 1514 prio 8 maxburst 2 avpkt 200 bounded&lt;br /&gt;tc filter add dev $DEV parent 1:0 protocol ip handle 1 fw flowid 1:3&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;</description><author>emaknyus@gmail.com (tamvan &amp;amp; verani)</author></item><item><title>Traffic Control</title><link>http://emaknyus.blogspot.com/2011/09/traffic-control.html</link><category>bandwidth</category><category>iptables</category><category>tc</category><category>u32</category><pubDate>Thu, 8 Sep 2011 16:49:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3787219161379371544.post-2134029507086822367</guid><description>&lt;span class="Apple-style-span" style="background-color: white; color: #222222; font-family: Georgia,'Times New Roman',serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"&gt;&lt;h2 style="background-image: none; color: #000066; font-family: Tahoma,sans-serif; font-size: 21px; margin: 0px 0px 0.6em; padding-bottom: 0.17em; padding-top: 0.5em; width: auto;"&gt;
&lt;span class="mw-headline" id="Introduction"&gt;Introduction&lt;/span&gt;&lt;/h2&gt;
&lt;div style="margin: 0.4em 0px 0.5em;"&gt;
Linux's traffic control functionality offers a lot of capabilities related to influencing the rate of flow, as well as latency, of primarily outgoing but also in some cases incoming network traffic. It is designed to be a "construction kit" rather than a turn-key system, where complex network traffic policing and shaping decisions can be made using a variety of algorithms. The Linux traffic control code is also often used by academia for research purposes, where is it can be a useful mechanism to simulate and explore the impact of a variety of different network behaviors. See&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;a class="external text" href="http://www.linuxfoundation.org/collaborate/workgroups/networking/netem" style="background-image: url(&amp;quot;file:///J:/match/Traffic_Control_files/images/external-link-ltr-icon.png&amp;quot;); background-position: 100% 50%; color: #3366bb; padding: 0px 13px 0px 0px; text-decoration: none;"&gt;netem&lt;/a&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;for an example of a simulation framework that can be used for this purpose.&lt;/div&gt;
&lt;div style="margin: 0.4em 0px 0.5em;"&gt;
Of course, Linux traffic control can also be extremely useful in an IT context, and this document is intended to focus on the practical, useful applications of Linux traffic control, where these capabilities can be applied to solve problems that are often experienced on modern networks.&lt;/div&gt;
&lt;div style="margin: 0.4em 0px 0.5em;"&gt;
&lt;/div&gt;
&lt;a name='more'&gt;&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;h2 style="background-image: none; color: #000066; font-family: Tahoma,sans-serif; font-size: 21px; margin: 0px 0px 0.6em; padding-bottom: 0.17em; padding-top: 0.5em; width: auto;"&gt;
&lt;span class="mw-headline" id="Incoming_and_Outgoing_Traffic"&gt;Incoming and Outgoing Traffic&lt;/span&gt;&lt;/h2&gt;
&lt;div style="margin: 0.4em 0px 0.5em;"&gt;
One common use of Linux traffic control is to configure a Linux system as a Linux router or bridge, so that the Linux system sits between two networks, or between the "inside" of the network and the real router, so that it can shape traffic going to local machines as well as out to the Internet. This provides a way to prioritize, shape and police both incoming (from the Internet) and outgoing (from local machines) network traffic, because it is easiest to create traffic control rules for traffic flowing&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;i&gt;out&lt;/i&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;of an interface, since we can control when the system&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;i&gt;sends&lt;/i&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;data, but controlling when we&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;i&gt;receive&lt;/i&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;data requires an additional&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;i&gt;intermediate queue&lt;/i&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;to be created to buffer incoming data. When a Linux system is configured as a firewall or router with a physical interface for each part of the network, we can avoid using intermediate queues.&lt;/div&gt;
&lt;div style="margin: 0.4em 0px 0.5em;"&gt;
A simple way to set up a layer 2 bridge using Linux involves creating a bridge device with&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;tt&gt;brctl&lt;/tt&gt;, adding two Ethernet ports to this bridge (again using&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;tt&gt;brctl&lt;/tt&gt;), and then apply prioritization, shaping and policing rules to both interfaces. The rules will apply to&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;i&gt;outgoing&lt;/i&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;traffic on each interface. One physical interface will be connected to an upstream router on the same network, while the other network port will be connected to a layer 2 access switch to which local machines are connected. This allows powerful egress shaping policies to be created on both interfaces, to control the flows in and out of the network.&lt;/div&gt;
&lt;h2 style="background-image: none; color: #000066; font-family: Tahoma,sans-serif; font-size: 21px; margin: 0px 0px 0.6em; padding-bottom: 0.17em; padding-top: 0.5em; width: auto;"&gt;
&lt;span class="mw-headline" id="Recommended_Resources"&gt;Recommended Resources&lt;/span&gt;&lt;/h2&gt;
&lt;div style="margin: 0.4em 0px 0.5em;"&gt;
Resources you should take a look at, in order:&lt;/div&gt;
&lt;ul style="color: #333333; font-size: 13px; list-style-image: url(&amp;quot;file:///J:/match/Traffic_Control_files/images/bullet-icon.png&amp;quot;); list-style-type: square; margin: 0.3em 0px 0px 1.5em; padding: 0px;"&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;&lt;a class="external text" href="http://luxik.cdi.cz/%7Edevik/qos/htb/manual/userg.htm" style="background-image: url(&amp;quot;file:///J:/match/Traffic_Control_files/images/external-link-ltr-icon.png&amp;quot;); background-position: 100% 50%; color: #3366bb; padding: 0px 13px 0px 0px; text-decoration: none;"&gt;HTB documentation&lt;/a&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;by Martin Devera. Best way to create different priority classes and bandwidth allocations.&lt;/li&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;&lt;a class="external text" href="http://www.opalsoft.net/qos/DS.htm" style="background-image: url(&amp;quot;file:///J:/match/Traffic_Control_files/images/external-link-ltr-icon.png&amp;quot;); background-position: 100% 50%; color: #3366bb; padding: 0px 13px 0px 0px; text-decoration: none;"&gt;Differentiated Services On Linux HOWTO&lt;/a&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;by Leonardo Balliache. Good general docs.&lt;/li&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;&lt;a class="external text" href="http://blog.edseek.com/%7Ejasonb/articles/traffic_shaping/index.html" style="background-image: url(&amp;quot;file:///J:/match/Traffic_Control_files/images/external-link-ltr-icon.png&amp;quot;); background-position: 100% 50%; color: #3366bb; padding: 0px 13px 0px 0px; text-decoration: none;"&gt;A Practical Guide to Linux Traffic Control&lt;/a&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;by Jason Boxman. Good general docs.&lt;/li&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;&lt;a class="external text" href="http://www.linuxfoundation.org/collaborate/workgroups/networking/ifb" style="background-image: url(&amp;quot;file:///J:/match/Traffic_Control_files/images/external-link-ltr-icon.png&amp;quot;); background-position: 100% 50%; color: #3366bb; padding: 0px 13px 0px 0px; text-decoration: none;"&gt;IFB - replacement for Linux IMQ&lt;/a&gt;, with examples. This is the official best way to do&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;i&gt;inbound&lt;/i&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;traffic control, when you don't have dedicated in/out interfaces.&lt;/li&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;&lt;a class="external text" href="http://seclists.org/fulldisclosure/2006/Feb/702" style="background-image: url(&amp;quot;file:///J:/match/Traffic_Control_files/images/external-link-ltr-icon.png&amp;quot;); background-position: 100% 50%; color: #3366bb; padding: 0px 13px 0px 0px; text-decoration: none;"&gt;Use of iptables hashlimit&lt;/a&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;- Great functionality in iptables. There's a hashlimit example below as well.&lt;/li&gt;
&lt;/ul&gt;
&lt;div style="margin: 0.4em 0px 0.5em;"&gt;
Related Interesting Links:&lt;/div&gt;
&lt;ul style="color: #333333; font-size: 13px; list-style-image: url(&amp;quot;file:///J:/match/Traffic_Control_files/images/bullet-icon.png&amp;quot;); list-style-type: square; margin: 0.3em 0px 0px 1.5em; padding: 0px;"&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;&lt;a class="external text" href="http://wiki.secondlife.com/wiki/BLT" style="background-image: url(&amp;quot;file:///J:/match/Traffic_Control_files/images/external-link-ltr-icon.png&amp;quot;); background-position: 100% 50%; color: #3366bb; padding: 0px 13px 0px 0px; text-decoration: none;"&gt;Second Life Bandwidth Testing Protocol&lt;/a&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;- example of Netem&lt;/li&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;&lt;a class="external text" href="http://www.29west.com/docs/THPM/udp-buffer-sizing.html" style="background-image: url(&amp;quot;file:///J:/match/Traffic_Control_files/images/external-link-ltr-icon.png&amp;quot;); background-position: 100% 50%; color: #3366bb; padding: 0px 13px 0px 0px; text-decoration: none;"&gt;UDP Buffer Sizing&lt;/a&gt;, part of&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;a class="external text" href="http://www.29west.com/docs/THPM/index.html" style="background-image: url(&amp;quot;file:///J:/match/Traffic_Control_files/images/external-link-ltr-icon.png&amp;quot;); background-position: 100% 50%; color: #3366bb; padding: 0px 13px 0px 0px; text-decoration: none;"&gt;Topics in High Performance Messaging&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 style="background-image: none; color: #000066; font-family: Tahoma,sans-serif; font-size: 21px; margin: 0px 0px 0.6em; padding-bottom: 0.17em; padding-top: 0.5em; width: auto;"&gt;
&lt;span class="mw-headline" id="Recommended_Approaches"&gt;Recommended Approaches&lt;/span&gt;&lt;/h2&gt;
&lt;div style="margin: 0.4em 0px 0.5em;"&gt;
Daniel Robbins has had very good results with the&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;a class="external text" href="http://luxik.cdi.cz/%7Edevik/qos/htb/" style="background-image: url(&amp;quot;file:///J:/match/Traffic_Control_files/images/external-link-ltr-icon.png&amp;quot;); background-position: 100% 50%; color: #3366bb; padding: 0px 13px 0px 0px; text-decoration: none;"&gt;HTB queuing discipline&lt;/a&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;- it has very good features, and also has&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;a class="external text" href="http://luxik.cdi.cz/%7Edevik/qos/htb/manual/userg.htm" style="background-image: url(&amp;quot;file:///J:/match/Traffic_Control_files/images/external-link-ltr-icon.png&amp;quot;); background-position: 100% 50%; color: #3366bb; padding: 0px 13px 0px 0px; text-decoration: none;"&gt;very good documentation&lt;/a&gt;, which is just as important, and is designed to deliver useful results in a production environment. And it works. If you use traffic control under Funtoo Linux, please use the HTB queuing discipline as the root queuing discipline because you will get good results in very little time. Avoid using any other queuing discipline under Funtoo Linux as the&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;i&gt;root&lt;/i&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;queuing discipline on any interface. If you are creating a tree of classes and qdiscs, HTB should be at the top, and you should avoid hanging classes under any other qdisc unless you have plenty of time to experiment and verify that your QoS rules are working as expected. Please see&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;a href="http://www.blogger.com/blogger.g?blogID=3787219161379371544#State_of_the_Code" style="background-image: none; color: navy; text-decoration: none;"&gt;State of the Code&lt;/a&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;for more info on what Daniel Robbins considers to be the current state of the traffic control implementation in Linux.&lt;/div&gt;
&lt;h2 style="background-image: none; color: #000066; font-family: Tahoma,sans-serif; font-size: 21px; margin: 0px 0px 0.6em; padding-bottom: 0.17em; padding-top: 0.5em; width: auto;"&gt;
&lt;span class="mw-headline" id="State_of_the_Code"&gt;State of the Code&lt;/span&gt;&lt;/h2&gt;
&lt;div style="margin: 0.4em 0px 0.5em;"&gt;
If you are using enterprise kernels, especially any RHEL5-based kernels, you must be aware that the traffic control code in these kernels is about 5 years old and contains many significant bugs. In general, it is possible to avoid these bugs by using HTB as your root queueing discipline and testing things carefully to ensure that you are getting the proper behavior. The&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;tt&gt;prio&lt;/tt&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;queueing discipline is known to not work reliably in RHEL5 kernels. See&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;a href="http://www.funtoo.org/wiki/Broken_Traffic_Control" style="background-image: none; color: navy; text-decoration: none;" title="Broken Traffic Control"&gt;Broken Traffic Control&lt;/a&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;for more information on known bugs with older kernels.&lt;/div&gt;
&lt;div style="margin: 0.4em 0px 0.5em;"&gt;
If you are using a more modern kernel, Linux traffic control should be fairly robust. The examples below should work with RHEL5 as well as newer kernels.&lt;/div&gt;
&lt;h2 style="background-image: none; color: #000066; font-family: Tahoma,sans-serif; font-size: 21px; margin: 0px 0px 0.6em; padding-bottom: 0.17em; padding-top: 0.5em; width: auto;"&gt;
&lt;span class="mw-headline" id="Inspect_Your_Rules"&gt;Inspect Your Rules&lt;/span&gt;&lt;/h2&gt;
&lt;div style="margin: 0.4em 0px 0.5em;"&gt;
If you are implementing Linux traffic control, you should be running these commands frequently to monitor the behavior of your queuing discipline. Replace&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;tt&gt;$wanif&lt;/tt&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;with the actual network interface name.&lt;/div&gt;
&lt;div class="mw-geshi" dir="ltr" style="background-color: cornsilk; border: 1px dashed rgb(47, 111, 171); margin: 1em 0px; padding: 1em; text-align: left;"&gt;
&lt;div class="bash source-bash" style="font-family: monospace; line-height: normal;"&gt;
&lt;pre class="de1" style="background-image: none; border: 0px none white; clear: both; font: 1em/1.2em monospace; margin: 0px; padding: 0px; vertical-align: top;"&gt;tc &lt;span class="re5" style="color: #660033;"&gt;-s&lt;/span&gt; qdisc &lt;span class="kw2" style="color: #c20cb9; font-weight: bold;"&gt;ls&lt;/span&gt; dev &lt;span class="re1" style="color: #007800;"&gt;$wanif&lt;/span&gt;
tc &lt;span class="re5" style="color: #660033;"&gt;-s&lt;/span&gt; class &lt;span class="kw2" style="color: #c20cb9; font-weight: bold;"&gt;ls&lt;/span&gt; dev &lt;span class="re1" style="color: #007800;"&gt;$wanif&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h2 style="background-image: none; color: #000066; font-family: Tahoma,sans-serif; font-size: 21px; margin: 0px 0px 0.6em; padding-bottom: 0.17em; padding-top: 0.5em; width: auto;"&gt;
&lt;span class="mw-headline" id="Matching"&gt;Matching&lt;/span&gt;&lt;/h2&gt;
&lt;div style="margin: 0.4em 0px 0.5em;"&gt;
Here are some examples you can use as the basis for your own filters/classifiers:&lt;/div&gt;
&lt;ol style="color: #333333; font-size: 13px; list-style-image: none; margin: 0.3em 0px 0px 1.5em; padding: 0px;"&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;&lt;tt&gt;protocol arp u32 match u32 0 0&lt;/tt&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;- match ARP packets&lt;/li&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;&lt;tt&gt;protocol ip u32 match ip protocol 0x11 0xff&lt;/tt&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;- match UDP packets&lt;/li&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;&lt;tt&gt;protocol ip u32 match ip protocol 17 0xff&lt;/tt&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;- (also) match UDP packets&lt;/li&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;&lt;tt&gt;protocol ip u32 match ip protocol 0x6 0xff&lt;/tt&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;- match TCP packets&lt;/li&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;&lt;tt&gt;protocol ip u32 match ip protocol 1 0xff&lt;/tt&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;- match ICMP (ping) packets&lt;/li&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;&lt;tt&gt;protocol ip u32 match ip dst 4.3.2.1/32&lt;/tt&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;- match all IP traffic headed for IP 4.3.2.1&lt;/li&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;&lt;tt&gt;protocol ip u32 match ip src 4.3.2.1/32 match ip sport 80 0xffff&lt;/tt&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;- match all IP traffic from 4.3.2.1 port 80&lt;/li&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;&lt;tt&gt;protocol ip u32 match ip sport 53 0xffff&lt;/tt&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;- match originating DNS (both TCP and UDP)&lt;/li&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;&lt;tt&gt;protocol ip u32 match ip dport 53 0xffff&lt;/tt&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;- match response DNS (both TCP and UDP)&lt;/li&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;&lt;tt&gt;protocol ip u32 match ip protocol 6 0xff match u8 0x10 0xff at nexthdr+13&lt;/tt&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;- match packets with ACK bit set&lt;/li&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;&lt;tt&gt;protocol ip u32 match ip protocol 6 0xff match u8 0x10 0xff at nexthdr+13 match u16 0x0000 0xffc0 at 2&lt;/tt&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;- packets less than 64 bytes in size with ACK bit set&lt;/li&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;&lt;tt&gt;protocol ip u32 match ip tos 0x10 0xff&lt;/tt&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;- match IP packets with "type of service" set to "Minimize delay"/"Interactive"&lt;/li&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;&lt;tt&gt;protocol ip u32 match ip tos 0x08 0xff&lt;/tt&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;- match IP packets with "type of service" set to "Maximize throughput"/"Bulk" (see "QDISC PARAMETERS" in&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;tt&gt;tc-prio&lt;/tt&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;man page)&lt;/li&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;&lt;tt&gt;protocol ip u32 match tcp dport 53 0xffff match ip protocol 0x6 0xff&lt;/tt&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;- match TCP packets heading for dest. port 53 (my not work)&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 style="background-image: none; color: #000066; font-family: Tahoma,sans-serif; font-size: 21px; margin: 0px 0px 0.6em; padding-bottom: 0.17em; padding-top: 0.5em; width: auto;"&gt;
&lt;span class="mw-headline" id="Sample_Traffic_Control_Code"&gt;Sample Traffic Control Code&lt;/span&gt;&lt;/h2&gt;
&lt;div class="mw-geshi" dir="ltr" style="background-color: cornsilk; border: 1px dashed rgb(47, 111, 171); margin: 1em 0px; padding: 1em; text-align: left;"&gt;
&lt;div class="bash source-bash" style="font-family: monospace; line-height: normal;"&gt;
&lt;pre class="de1" style="background-image: none; border: 0px none white; clear: both; font: 1em/1.2em monospace; margin: 0px; padding: 0px; vertical-align: top;"&gt;&lt;span class="re2" style="color: #007800;"&gt;modemif&lt;/span&gt;=eth4
&amp;nbsp;
iptables &lt;span class="re5" style="color: #660033;"&gt;-t&lt;/span&gt; mangle &lt;span class="re5" style="color: #660033;"&gt;-A&lt;/span&gt; POSTROUTING &lt;span class="re5" style="color: #660033;"&gt;-o&lt;/span&gt; &lt;span class="re1" style="color: #007800;"&gt;$modemif&lt;/span&gt; &lt;span class="re5" style="color: #660033;"&gt;-p&lt;/span&gt; tcp &lt;span class="re5" style="color: #660033;"&gt;-m&lt;/span&gt; tos &lt;span class="re5" style="color: #660033;"&gt;--tos&lt;/span&gt; Minimize-Delay &lt;span class="re5" style="color: #660033;"&gt;-j&lt;/span&gt; CLASSIFY &lt;span class="re5" style="color: #660033;"&gt;--set-class&lt;/span&gt; &lt;span class="nu0" style="color: black;"&gt;1&lt;/span&gt;:&lt;span class="nu0" style="color: black;"&gt;10&lt;/span&gt;
iptables &lt;span class="re5" style="color: #660033;"&gt;-t&lt;/span&gt; mangle &lt;span class="re5" style="color: #660033;"&gt;-A&lt;/span&gt; POSTROUTING &lt;span class="re5" style="color: #660033;"&gt;-o&lt;/span&gt; &lt;span class="re1" style="color: #007800;"&gt;$modemif&lt;/span&gt; &lt;span class="re5" style="color: #660033;"&gt;-p&lt;/span&gt; tcp &lt;span class="re5" style="color: #660033;"&gt;--dport&lt;/span&gt; &lt;span class="nu0" style="color: black;"&gt;53&lt;/span&gt; &lt;span class="re5" style="color: #660033;"&gt;-j&lt;/span&gt; CLASSIFY &lt;span class="re5" style="color: #660033;"&gt;--set-class&lt;/span&gt; &lt;span class="nu0" style="color: black;"&gt;1&lt;/span&gt;:&lt;span class="nu0" style="color: black;"&gt;10&lt;/span&gt;
iptables &lt;span class="re5" style="color: #660033;"&gt;-t&lt;/span&gt; mangle &lt;span class="re5" style="color: #660033;"&gt;-A&lt;/span&gt; POSTROUTING &lt;span class="re5" style="color: #660033;"&gt;-o&lt;/span&gt; &lt;span class="re1" style="color: #007800;"&gt;$modemif&lt;/span&gt; &lt;span class="re5" style="color: #660033;"&gt;-p&lt;/span&gt; tcp &lt;span class="re5" style="color: #660033;"&gt;--dport&lt;/span&gt; &lt;span class="nu0" style="color: black;"&gt;80&lt;/span&gt; &lt;span class="re5" style="color: #660033;"&gt;-j&lt;/span&gt; CLASSIFY &lt;span class="re5" style="color: #660033;"&gt;--set-class&lt;/span&gt; &lt;span class="nu0" style="color: black;"&gt;1&lt;/span&gt;:&lt;span class="nu0" style="color: black;"&gt;10&lt;/span&gt;
iptables &lt;span class="re5" style="color: #660033;"&gt;-t&lt;/span&gt; mangle &lt;span class="re5" style="color: #660033;"&gt;-A&lt;/span&gt; POSTROUTING &lt;span class="re5" style="color: #660033;"&gt;-o&lt;/span&gt; &lt;span class="re1" style="color: #007800;"&gt;$modemif&lt;/span&gt; &lt;span class="re5" style="color: #660033;"&gt;-p&lt;/span&gt; tcp &lt;span class="re5" style="color: #660033;"&gt;--dport&lt;/span&gt; &lt;span class="nu0" style="color: black;"&gt;443&lt;/span&gt; &lt;span class="re5" style="color: #660033;"&gt;-j&lt;/span&gt; CLASSIFY &lt;span class="re5" style="color: #660033;"&gt;--set-class&lt;/span&gt; &lt;span class="nu0" style="color: black;"&gt;1&lt;/span&gt;:&lt;span class="nu0" style="color: black;"&gt;10&lt;/span&gt;
&amp;nbsp;
tc qdisc add dev &lt;span class="re1" style="color: #007800;"&gt;$modemif&lt;/span&gt; root handle &lt;span class="nu0" style="color: black;"&gt;1&lt;/span&gt;: htb default &lt;span class="nu0" style="color: black;"&gt;12&lt;/span&gt;
tc class add dev &lt;span class="re1" style="color: #007800;"&gt;$modemif&lt;/span&gt; parent &lt;span class="nu0" style="color: black;"&gt;1&lt;/span&gt;: classid &lt;span class="nu0" style="color: black;"&gt;1&lt;/span&gt;:&lt;span class="nu0" style="color: black;"&gt;1&lt;/span&gt; htb rate 1500kbit ceil 1500kbit burst 10k
tc class add dev &lt;span class="re1" style="color: #007800;"&gt;$modemif&lt;/span&gt; parent &lt;span class="nu0" style="color: black;"&gt;1&lt;/span&gt;:&lt;span class="nu0" style="color: black;"&gt;1&lt;/span&gt; classid &lt;span class="nu0" style="color: black;"&gt;1&lt;/span&gt;:&lt;span class="nu0" style="color: black;"&gt;10&lt;/span&gt; htb rate 700kbit ceil 1500kbit prio &lt;span class="nu0" style="color: black;"&gt;1&lt;/span&gt; burst 10k
tc class add dev &lt;span class="re1" style="color: #007800;"&gt;$modemif&lt;/span&gt; parent &lt;span class="nu0" style="color: black;"&gt;1&lt;/span&gt;:&lt;span class="nu0" style="color: black;"&gt;1&lt;/span&gt; classid &lt;span class="nu0" style="color: black;"&gt;1&lt;/span&gt;:&lt;span class="nu0" style="color: black;"&gt;12&lt;/span&gt; htb rate 800kbit ceil 800kbit prio &lt;span class="nu0" style="color: black;"&gt;2&lt;/span&gt;
tc filter add dev &lt;span class="re1" style="color: #007800;"&gt;$modemif&lt;/span&gt; protocol ip parent &lt;span class="nu0" style="color: black;"&gt;1&lt;/span&gt;:&lt;span class="nu0" style="color: black;"&gt;0&lt;/span&gt; prio &lt;span class="nu0" style="color: black;"&gt;1&lt;/span&gt; u32 match ip protocol 0x11 0xff flowid &lt;span class="nu0" style="color: black;"&gt;1&lt;/span&gt;:&lt;span class="nu0" style="color: black;"&gt;10&lt;/span&gt;
tc qdisc add dev &lt;span class="re1" style="color: #007800;"&gt;$modemif&lt;/span&gt; parent &lt;span class="nu0" style="color: black;"&gt;1&lt;/span&gt;:&lt;span class="nu0" style="color: black;"&gt;10&lt;/span&gt; handle &lt;span class="nu0" style="color: black;"&gt;20&lt;/span&gt;: sfq perturb &lt;span class="nu0" style="color: black;"&gt;10&lt;/span&gt;
tc qdisc add dev &lt;span class="re1" style="color: #007800;"&gt;$modemif&lt;/span&gt; parent &lt;span class="nu0" style="color: black;"&gt;1&lt;/span&gt;:&lt;span class="nu0" style="color: black;"&gt;12&lt;/span&gt; handle &lt;span class="nu0" style="color: black;"&gt;30&lt;/span&gt;: sfq perturb &lt;span class="nu0" style="color: black;"&gt;10&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style="margin: 0.4em 0px 0.5em;"&gt;
The code above is a working traffic control script that is even compatible with RHEL5 kernels, for a 1500kbps outbound link (T1, Cable or similar.) In this example,&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;tt&gt;eth4&lt;/tt&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;is part of a bridge. The code above should work regardless of whether&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;tt&gt;eth4&lt;/tt&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;is in a bridge or not -- just make sure that&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;tt&gt;modemif&lt;/tt&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;is set to the interface on which traffic is flowing&lt;i&gt;out&lt;/i&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;and you wish to apply traffic control.&lt;/div&gt;
&lt;h3 style="background-image: none; border-bottom-style: none; color: #333399; font-family: Tahoma,sans-serif; font-size: 18px; font-weight: bold; margin: 0px 0px 0.3em; padding-bottom: 0.17em; padding-top: 0.5em; width: auto;"&gt;
&lt;span class="mw-headline" id="tc_code_walkthrough"&gt;&lt;tt&gt;tc&lt;/tt&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;code walkthrough&lt;/span&gt;&lt;/h3&gt;
&lt;div style="margin: 0.4em 0px 0.5em;"&gt;
This script uses the&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;tt&gt;tc&lt;/tt&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;command to create two priority classes - 1:10 and 1:12. By default, all traffic goes into the low-priority class, 1:12. 1:10 has priority over 1:12 (&lt;tt&gt;prio 1&lt;/tt&gt;vs.&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;tt&gt;prio 2&lt;/tt&gt;,) so if there is any traffic in 1:10 ready to be sent, it will be sent ahead of 1:12. 1:10 has a rate of 700kbit but can use up to the full outbound bandwidth of 1500kbit by borrowing from 1:12.&lt;/div&gt;
&lt;div style="margin: 0.4em 0px 0.5em;"&gt;
UDP traffic (traffic that matches&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;tt&gt;ip protocol 0x11 0xff&lt;/tt&gt;) will be put in the high priority class 1:10. This can be good for things like FPS games, to ensure that latency is low and not drowned out by lower-priority traffic.&lt;/div&gt;
&lt;div style="margin: 0.4em 0px 0.5em;"&gt;
If we stopped here, however, we would get a bit worse results than if we didn't use&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;tt&gt;tc&lt;/tt&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;at all. We have basically created two outgoing sub-channels of different priorities. The higher priority class&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;i&gt;can&lt;/i&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;drown out the lower-priority class, and this is intentional so it isn't the issue -- in this case we&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;i&gt;want&lt;/i&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;that functionality. The problem is that the high priority and low priority classes can both be dominated by high-bandwidth flows, causing other traffic flows of the same priority to be drowned out. To fix this, two&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;tt&gt;sfq&lt;/tt&gt;queuing disciplines are added to the high and low priority classes and will ensure that individual traffic flows are identified and each given a fair shot at sending data out of their respective classes. This should prevent starvation within the classes themselves.&lt;/div&gt;
&lt;h3 style="background-image: none; border-bottom-style: none; color: #333399; font-family: Tahoma,sans-serif; font-size: 18px; font-weight: bold; margin: 0px 0px 0.3em; padding-bottom: 0.17em; padding-top: 0.5em; width: auto;"&gt;
&lt;span class="mw-headline" id="iptables_code_walkthrough"&gt;&lt;tt&gt;iptables&lt;/tt&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;code walkthrough&lt;/span&gt;&lt;/h3&gt;
&lt;div style="margin: 0.4em 0px 0.5em;"&gt;
First note that we are adding netfilter rules to the&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;tt&gt;POSTROUTING&lt;/tt&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;chain, in the&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;tt&gt;mangle&lt;/tt&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;table. This table allows us to modify the packets&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;i&gt;right before&lt;/i&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;they are queued to be sent out of an interface, which is exactly what we want. At this point, these packets could have been locally-generated or forwarded -- as long as they are on their way to going out of&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;tt&gt;modemif&lt;/tt&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;(eth4 in this case), the&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;tt&gt;mangle&lt;/tt&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;tt&gt;POSTROUTING&lt;/tt&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;chain will see them and we can classify them and perform other useful tweaks.&lt;/div&gt;
&lt;div style="margin: 0.4em 0px 0.5em;"&gt;
The iptables code puts all traffic with the "minimize-delay" flag (interactive ssh traffic, for example) in the high priority traffic class. In addition, all HTTP, HTTPS and DNS TCP traffic will be classified as high-priority. Remember that all UDP traffic is being classified as high priority via the&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;tt&gt;tc&lt;/tt&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;rule described above, so this will take care of DNS UDP traffic automatically.&lt;/div&gt;
&lt;h3 style="background-image: none; border-bottom-style: none; color: #333399; font-family: Tahoma,sans-serif; font-size: 18px; font-weight: bold; margin: 0px 0px 0.3em; padding-bottom: 0.17em; padding-top: 0.5em; width: auto;"&gt;
&lt;span class="mw-headline" id="Further_optimizations"&gt;Further optimizations&lt;/span&gt;&lt;/h3&gt;
&lt;h4 style="background-image: none; border-bottom-style: none; color: #333399; font-family: Tahoma,sans-serif; font-size: 16px; font-weight: bold; margin: 0px 0px 0.3em; padding-bottom: 0.17em; padding-top: 0.5em; width: auto;"&gt;
&lt;span class="mw-headline" id="SSH"&gt;SSH&lt;/span&gt;&lt;/h4&gt;
&lt;div class="mw-geshi" dir="ltr" style="background-color: cornsilk; border: 1px dashed rgb(47, 111, 171); margin: 1em 0px; padding: 1em; text-align: left;"&gt;
&lt;div class="bash source-bash" style="font-family: monospace; line-height: normal;"&gt;
&lt;pre class="de1" style="background-image: none; border: 0px none white; clear: both; font: 1em/1.2em monospace; margin: 0px; padding: 0px; vertical-align: top;"&gt;iptables &lt;span class="re5" style="color: #660033;"&gt;-t&lt;/span&gt; mangle &lt;span class="re5" style="color: #660033;"&gt;-N&lt;/span&gt; tosfix
iptables &lt;span class="re5" style="color: #660033;"&gt;-t&lt;/span&gt; mangle &lt;span class="re5" style="color: #660033;"&gt;-A&lt;/span&gt; tosfix &lt;span class="re5" style="color: #660033;"&gt;-p&lt;/span&gt; tcp &lt;span class="re5" style="color: #660033;"&gt;-m&lt;/span&gt; length &lt;span class="re5" style="color: #660033;"&gt;--length&lt;/span&gt; &lt;span class="nu0" style="color: black;"&gt;0&lt;/span&gt;:&lt;span class="nu0" style="color: black;"&gt;512&lt;/span&gt; &lt;span class="re5" style="color: #660033;"&gt;-j&lt;/span&gt; RETURN
&lt;span class="co0" style="color: #666666; font-style: italic;"&gt;#allow screen redraws under interactive SSH sessions to be fast:&lt;/span&gt;
iptables &lt;span class="re5" style="color: #660033;"&gt;-t&lt;/span&gt; mangle &lt;span class="re5" style="color: #660033;"&gt;-A&lt;/span&gt; tosfix &lt;span class="re5" style="color: #660033;"&gt;-m&lt;/span&gt; hashlimit &lt;span class="re5" style="color: #660033;"&gt;--hashlimit&lt;/span&gt; &lt;span class="nu0" style="color: black;"&gt;20&lt;/span&gt;&lt;span class="sy0" style="color: black; font-weight: bold;"&gt;/&lt;/span&gt;sec &lt;span class="re5" style="color: #660033;"&gt;--hashlimit-burst&lt;/span&gt; &lt;span class="nu0" style="color: black;"&gt;20&lt;/span&gt; \
&lt;span class="re5" style="color: #660033;"&gt;--hashlimit-mode&lt;/span&gt; srcip,srcport,dstip,dstport &lt;span class="re5" style="color: #660033;"&gt;--hashlimit-name&lt;/span&gt; minlat &lt;span class="re5" style="color: #660033;"&gt;-j&lt;/span&gt; RETURN
iptables &lt;span class="re5" style="color: #660033;"&gt;-t&lt;/span&gt; mangle &lt;span class="re5" style="color: #660033;"&gt;-A&lt;/span&gt; tosfix &lt;span class="re5" style="color: #660033;"&gt;-j&lt;/span&gt; TOS &lt;span class="re5" style="color: #660033;"&gt;--set-tos&lt;/span&gt; Maximize-Throughput
iptables &lt;span class="re5" style="color: #660033;"&gt;-t&lt;/span&gt; mangle &lt;span class="re5" style="color: #660033;"&gt;-A&lt;/span&gt; tosfix &lt;span class="re5" style="color: #660033;"&gt;-j&lt;/span&gt; RETURN
&amp;nbsp;
iptables &lt;span class="re5" style="color: #660033;"&gt;-t&lt;/span&gt; mangle &lt;span class="re5" style="color: #660033;"&gt;-A&lt;/span&gt; POSTROUTING &lt;span class="re5" style="color: #660033;"&gt;-p&lt;/span&gt; tcp &lt;span class="re5" style="color: #660033;"&gt;-m&lt;/span&gt; tos &lt;span class="re5" style="color: #660033;"&gt;--tos&lt;/span&gt; Minimize-Delay &lt;span class="re5" style="color: #660033;"&gt;-j&lt;/span&gt; tosfix&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style="margin: 0.4em 0px 0.5em;"&gt;
To use this code, place it&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;i&gt;near the top of the file&lt;/i&gt;, just below the&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;tt&gt;modemif="eth4"&lt;/tt&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;line, but&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;i&gt;before&lt;/i&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;the main&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;tt&gt;iptables&lt;/tt&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;and&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;tt&gt;tc&lt;/tt&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;rules. These rules will apply to&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;i&gt;all&lt;/i&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;packets about to get queued to any interface, but this is not necessarily a bad thing, since the TCP flags being set are not just specific to our traffic control functionality. To make these rules specific to&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;tt&gt;modemif&lt;/tt&gt;, add "-o $modemif" after "-A POSTROUTING" on the last line, above. As-is, the rules above will set the TCP flags on all packets flowing out of all interfaces, but the the traffic control rules will only take effect for&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;tt&gt;modemif&lt;/tt&gt;, because they are only configured for that interface.&lt;/div&gt;
&lt;div style="margin: 0.4em 0px 0.5em;"&gt;
SSH is a tricky protocol. By default, all the outgoing SSH traffic is classified as "minimize-delay" traffic, which will cause it to all flow into our high-priority class, even if it is a bulk&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;tt&gt;scp&lt;/tt&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;transfer running in the background. This code will grab all "minimize-delay" traffic such as SSH and telnet and route it through some special rules. Any individual keystrokes (small packets) will be left as "minimize-delay" packets. For anything else, we will run the&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;tt&gt;hashlimit&lt;/tt&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;iptables module, which will identify individual outbound flows and allow small bursts of traffic (even big packets) to remain "minimize-delay" packets. These settings have been specifically tuned so that most&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;tt&gt;GNU screen&lt;/tt&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;screen changes (^A^N) when logging into your server(s) remotely will be fast. Any traffic over these burst limits will be reclassified as "maximize-throughput" and thus will drop to our lower-priority class 1:12. Combined with the traffic control rules, this will allow you to have very responsive SSH sessions into your servers, even if they are doing some kind of bulk outbound copy, like rsync over SSH.&lt;/div&gt;
&lt;div style="margin: 0.4em 0px 0.5em;"&gt;
Code in our main&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;tt&gt;iptables&lt;/tt&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;rules will ensure that any "minimize-delay" traffic is tagged to be in the high-priority 1:10 class.&lt;/div&gt;
&lt;div style="margin: 0.4em 0px 0.5em;"&gt;
What this does is keep interactive SSH and telnet keystrokes in the high-priority class, allow GNU screen full redraws and reasonable full-screen editor scrolling to remain in the high-priority class, while forcing bulk transfers into the lower-priority class.&lt;/div&gt;
&lt;h4 style="background-image: none; border-bottom-style: none; color: #333399; font-family: Tahoma,sans-serif; font-size: 16px; font-weight: bold; margin: 0px 0px 0.3em; padding-bottom: 0.17em; padding-top: 0.5em; width: auto;"&gt;
&lt;span class="mw-headline" id="ACKs"&gt;ACKs&lt;/span&gt;&lt;/h4&gt;
&lt;div class="mw-geshi" dir="ltr" style="background-color: cornsilk; border: 1px dashed rgb(47, 111, 171); margin: 1em 0px; padding: 1em; text-align: left;"&gt;
&lt;div class="bash source-bash" style="font-family: monospace; line-height: normal;"&gt;
&lt;pre class="de1" style="background-image: none; border: 0px none white; clear: both; font: 1em/1.2em monospace; margin: 0px; padding: 0px; vertical-align: top;"&gt;iptables &lt;span class="re5" style="color: #660033;"&gt;-t&lt;/span&gt; mangle &lt;span class="re5" style="color: #660033;"&gt;-N&lt;/span&gt; ack
iptables &lt;span class="re5" style="color: #660033;"&gt;-t&lt;/span&gt; mangle &lt;span class="re5" style="color: #660033;"&gt;-A&lt;/span&gt; ack &lt;span class="re5" style="color: #660033;"&gt;-m&lt;/span&gt; tos &lt;span class="sy0" style="color: black; font-weight: bold;"&gt;!&lt;/span&gt; &lt;span class="re5" style="color: #660033;"&gt;--tos&lt;/span&gt; Normal-Service &lt;span class="re5" style="color: #660033;"&gt;-j&lt;/span&gt; RETURN
iptables &lt;span class="re5" style="color: #660033;"&gt;-t&lt;/span&gt; mangle &lt;span class="re5" style="color: #660033;"&gt;-A&lt;/span&gt; ack &lt;span class="re5" style="color: #660033;"&gt;-p&lt;/span&gt; tcp &lt;span class="re5" style="color: #660033;"&gt;-m&lt;/span&gt; length &lt;span class="re5" style="color: #660033;"&gt;--length&lt;/span&gt; &lt;span class="nu0" style="color: black;"&gt;0&lt;/span&gt;:&lt;span class="nu0" style="color: black;"&gt;128&lt;/span&gt; &lt;span class="re5" style="color: #660033;"&gt;-j&lt;/span&gt; TOS &lt;span class="re5" style="color: #660033;"&gt;--set-tos&lt;/span&gt; Minimize-Delay
iptables &lt;span class="re5" style="color: #660033;"&gt;-t&lt;/span&gt; mangle &lt;span class="re5" style="color: #660033;"&gt;-A&lt;/span&gt; ack &lt;span class="re5" style="color: #660033;"&gt;-p&lt;/span&gt; tcp &lt;span class="re5" style="color: #660033;"&gt;-m&lt;/span&gt; length &lt;span class="re5" style="color: #660033;"&gt;--length&lt;/span&gt; &lt;span class="nu0" style="color: black;"&gt;128&lt;/span&gt;: &lt;span class="re5" style="color: #660033;"&gt;-j&lt;/span&gt; TOS &lt;span class="re5" style="color: #660033;"&gt;--set-tos&lt;/span&gt; Maximize-Throughput
iptables &lt;span class="re5" style="color: #660033;"&gt;-t&lt;/span&gt; mangle &lt;span class="re5" style="color: #660033;"&gt;-A&lt;/span&gt; ack &lt;span class="re5" style="color: #660033;"&gt;-j&lt;/span&gt; RETURN
&amp;nbsp;
iptables &lt;span class="re5" style="color: #660033;"&gt;-t&lt;/span&gt; mangle &lt;span class="re5" style="color: #660033;"&gt;-A&lt;/span&gt; POSTROUTING &lt;span class="re5" style="color: #660033;"&gt;-p&lt;/span&gt; tcp &lt;span class="re5" style="color: #660033;"&gt;-m&lt;/span&gt; tcp &lt;span class="re5" style="color: #660033;"&gt;--tcp-flags&lt;/span&gt; SYN,RST,ACK ACK &lt;span class="re5" style="color: #660033;"&gt;-j&lt;/span&gt; ack&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style="margin: 0.4em 0px 0.5em;"&gt;
To use this code, place it&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;i&gt;near the top of the file, just below the&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;tt&gt;modemif="eth4"&lt;/tt&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;line, but&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/i&gt;before&lt;i&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;the main&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;tt&gt;iptables&lt;/tt&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;and&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;tt&gt;tc&lt;/tt&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;rules.&lt;/i&gt;&lt;/div&gt;
&lt;div style="margin: 0.4em 0px 0.5em;"&gt;
ACK optimization is another useful thing to do. If we prioritize small ACKs heading out to the modem, it will allow TCP traffic to flow more smoothly without unnecessary delay. The lines above accomplish this.&lt;/div&gt;
&lt;div style="margin: 0.4em 0px 0.5em;"&gt;
This code basically sets the "minimize-delay" flag on small ACKs. Code in our main&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;tt&gt;iptables&lt;/tt&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;rules will then tag these packets so they enter high-priority traffic class 1:10.&lt;/div&gt;
&lt;h2 style="background-image: none; color: #000066; font-family: Tahoma,sans-serif; font-size: 21px; margin: 0px 0px 0.6em; padding-bottom: 0.17em; padding-top: 0.5em; width: auto;"&gt;
&lt;span class="mw-headline" id="Other_Links_of_Interest"&gt;Other Links of Interest&lt;/span&gt;&lt;/h2&gt;
&lt;ul style="color: #333333; font-size: 13px; list-style-image: url(&amp;quot;file:///J:/match/Traffic_Control_files/images/bullet-icon.png&amp;quot;); list-style-type: square; margin: 0.3em 0px 0px 1.5em; padding: 0px;"&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;&lt;a class="external free" href="http://pupa.da.ru/tc/" style="background-image: url(&amp;quot;file:///J:/match/Traffic_Control_files/images/external-link-ltr-icon.png&amp;quot;); background-position: 100% 50%; color: #3366bb; padding: 0px 13px 0px 0px; text-decoration: none;"&gt;http://pupa.da.ru/tc/&lt;/a&gt;&lt;/li&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;&lt;a class="external free" href="http://manpages.ubuntu.com/manpages/maverick/en/man8/ufw.8.html" style="background-image: url(&amp;quot;file:///J:/match/Traffic_Control_files/images/external-link-ltr-icon.png&amp;quot;); background-position: 100% 50%; color: #3366bb; padding: 0px 13px 0px 0px; text-decoration: none;"&gt;http://manpages.ubuntu.com/manpages/maverick/en/man8/ufw.8.html&lt;/a&gt;&lt;/li&gt;
&lt;li style="margin-bottom: 0.1em;"&gt;&lt;a class="external free" href="https://help.ubuntu.com/community/UFW" style="background-image: url(&amp;quot;file:///J:/match/Traffic_Control_files/images/lock-icon.png&amp;quot;); background-position: 100% 50%; color: #3366bb; padding: 0px 18px 0px 0px; text-decoration: none;"&gt;https://help.ubuntu.com/community/UFW&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
http://www.funtoo.org/wiki/Welcome &lt;br /&gt;
</description><author>emaknyus@gmail.com (tamvan &amp;amp; verani)</author></item><item><title>IPTables U32 Match Tutorial</title><link>http://emaknyus.blogspot.com/2011/09/iptables-u32-match-tutorial.html</link><category>filter</category><category>match</category><category>u32</category><pubDate>Thu, 8 Sep 2011 16:46:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3787219161379371544.post-2396229702753464999</guid><description>&lt;h2&gt;
Introduction&lt;/h2&gt;
IPTables has always been a relatively flexible and modular
firewall; if it can't currently test for a particular packet
characteristic, you have the option of writing a test or modifying an
existing test.  The catch - as with so much of open source - is that
most of us aren't programmers.&lt;br /&gt;


	It turns out we do have an option that doesn't require
programming.  Don Cohen was kind enough to write an IPTables module that
pulls any bytes you'd like out of the packet, does some manipulation,
and sees if the result is in a particular range.  For example, I can
grab the Fragmentation information out of the IP header, throw away
everything except the More Fragments flag, and see if that flag is
set.&lt;br /&gt;


	Without writing any C code at all.  :-)&lt;br /&gt;


	What I'll do is introduce the core concepts here, and put in
hopefully enough annotated examples that you'll be able to write your
own tests.&lt;br /&gt;


	I won't be focusing on &lt;i&gt;what&lt;/i&gt; these fields are, or why
you'd want to test them; there are lots of (warning - shameless plug for
my employer ahead!) &lt;a href="http://www.sans.org/"&gt;resources&lt;/a&gt; for
doing that.  If you simply need a quick reference for the packet
headers, see &lt;a href="http://www.sans.org/resources/tcpip.pdf"&gt;tcpip.pdf&lt;/a&gt;.&lt;br /&gt;


	All byte positions in this article start counting at 0 as the
first byte of the header.  For example, in the IP header, byte "0" holds
the 4 bit "Version" and 4 bit "IP Header Length", byte "1" holds the
"TOS" field, etc.&lt;br /&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;


&lt;h3&gt;
Check the value of a 2 byte field&lt;/h3&gt;
In it's simplest form, u32 grabs a block of 4 bytes starting
at Start, applies a mask of Mask to it, and compares the result to
Range.  Here's the syntax we'll use for our first examples:&lt;br /&gt;


&lt;code&gt;
iptables -m u32 --u32 "Start&amp;amp;Mask=Range"
&lt;/code&gt;

	We'll generally pick a "Start" value that's 3 less than the
last byte in which you're interested.  So, if you want bytes 4 and 5 of
the IP header (the IP ID field), Start needs to be 5-3 = 2.  Mask strips
out all the stuff you don't want; it's a bitmask that can be as large as
0xFFFFFFFF.  To get to our target of bytes 4 or 5, we have to discard
bytes 2 and 3.  Here's the mask we'll use:  0x0000FFFF .  We'll actually
use the shorter, and equivalent, 0xFFFF instead.&lt;br /&gt;


	So, to test for &lt;b&gt;IPID&lt;/b&gt;'s from 2 to 256, the iptables
command line is:&lt;br /&gt;


&lt;code&gt;
iptables -m u32 --u32 "2&amp;amp;0xFFFF=0x2:0x0100"
&lt;/code&gt;

	To read this off from left to right: "Load the u32 module,
and perform the following u32 tests on this packet; grab the 4 bytes
starting with byte 2 (bytes 2 and 3 are the Total Length field, and
bytes 4 and 5 are the IPID), apply a mask of 0x0000FFFF (which sets the
first two bytes to all zeroes, leaving the last two bytes untouched),
and see if that value - the IPID - falls between 2 and 256 inclusive; if
so, return true, otherwise false."&lt;br /&gt;


	There is no standalone IPID check in IPTables, but this is
the equivalent of the "ip[2:2] &amp;gt;= 2 and ip[2:2] &amp;lt;= 256" tcpdump/bpf filter.

	&lt;br /&gt;
I leave off actions in these examples, but you can add things
like:&lt;br /&gt;


&lt;code&gt;
-j LOG --log-prefix "ID-in-2-256 "&lt;br /&gt;
-j DROP
&lt;/code&gt;

	or any other action.  You can also add other tests, as we'll
do in a minute.&lt;br /&gt;


	Don offers this test to see if the &lt;b&gt;total packet length&lt;/b&gt;
is greater than or equal to 256.  The total length field is bytes 2 and
3 of the IP header, so our starting position is 3-3 = 0.  Since we're
pulling out two bytes again, the mask will be 0xFFFF here as well.  The
final test is:&lt;br /&gt;


&lt;code&gt;
iptables -m u32 --u32 "0&amp;amp;0xFFFF=0x100:0xFFFF"
&lt;/code&gt;

	This is the same as:&lt;br /&gt;


&lt;code&gt;
iptables -m length --length 256:65535&lt;br /&gt;
	or the bpf filter&lt;br /&gt;
"len &amp;gt;= 256"
&lt;/code&gt;

&lt;h3&gt;
Check the value of a 1 byte field&lt;/h3&gt;
Much the same, except we'll use a mask of 0x000000FF (or it's
shorter equivalent 0xFF) to pull out a single byte from the 4 bytes u32
initially hands us.  Let's say I want to test the &lt;b&gt;TTL&lt;/b&gt; field for
TTL's below 3 to find people tracerouting to us.  Yes, there's a ttl
module, but let's see how this would be done in u32.&lt;br /&gt;


	I want to end up with byte 8 of the IP header, so my starting
position is 8-3 = 5.  Here's the test:&lt;br /&gt;


&lt;code&gt;
iptables -m u32 --u32 "5&amp;amp;0xFF=0:3"
&lt;/code&gt;

	Which is equivalent to:&lt;br /&gt;


&lt;code&gt;
iptables -m ttl --ttl-lt 4&lt;br /&gt;
	or the bpf filter&lt;br /&gt;
"ip[8] &amp;lt;= 3"
&lt;/code&gt;


&lt;h3&gt;
Looking at 4 bytes at once&lt;/h3&gt;
To check a complete destination IP address, we'll
inspect bytes 16-19.  Because we want all 4 bytes, we don't need a mask
at all.  Let's see if the destination address is 224.0.0.1:&lt;br /&gt;


&lt;code&gt;
iptables -m u32 --u32 "16=0xE0000001"
&lt;/code&gt;

	This is equivalent to:&lt;br /&gt;


&lt;code&gt;
iptables -d 224.0.0.1/32
&lt;/code&gt;

	If we only want to look at the first three bytes (to check if
a source address is part of a given class C network), we'll need to use
a mask again.  The mask we'll use is 0xFFFFFF00 , which throws away the
last octet.  Let's check if the source address (from bytes 12-15,
although we'll ignore byte 15 with the mask) is in the class C network
192.168.15.0 (0xC0A80F00):&lt;br /&gt;


&lt;code&gt;
iptables -m u32 --u32 "12&amp;amp;0xFFFFFF00=0xC0A80F00"
&lt;/code&gt;

	Which is the same as:&lt;br /&gt;


&lt;code&gt;
iptables -s 192.168.15.0/24
&lt;/code&gt;


&lt;h3&gt;
Inspecting early bytes in the header&lt;/h3&gt;
Obviously, if I want to look at the &lt;b&gt;TOS&lt;/b&gt; field (byte 1 of the
IP header), I can't start at byte 1-3 = -2.  What we'll do instead is
start at byte 0, pull out the byte we want, and then move it down to the
last position for easy testing.  This isn't the only way we could do
this, but it helps demonstrate a technique we'll need in a minute.&lt;br /&gt;


	To pull out the TOS field, I first ask u32 to give me bytes
0-3 by using an offset of 0.  Now, I pull out byte 1 (the second byte in
that block) with a mask of 0x00FF0000 .  I need to shift the TOS value
down to the far right position for easy comparison.  To do this, I use a
technique called, unsuprisingly, "right shift".  The symbol for right
shift is "&amp;gt;&amp;gt;"; this is followed by the number of bits right to move the
data.  If you're unfamiliar with right shift, take a look at this
&lt;a href="http://www.harpercollege.edu/bus-ss/cis/166/mmckenzi/lect19/l19n.htm"&gt;tutorial from Harper College&lt;/a&gt;.&lt;br /&gt;




	I want to move TOS two bytes  - or 16 bits - to the right. 
This is done with "&amp;gt;&amp;gt;16".  Now that we have TOS in the correct position,
we compare it to 0x08 (Maximize Throughput):&lt;br /&gt;


&lt;code&gt;
iptables -m u32 --u32 "0&amp;amp;0x00FF0000&amp;gt;&amp;gt;16=0x08"
&lt;/code&gt;



	which is the equivalent of:&lt;br /&gt;


&lt;code&gt;
iptables -m ttl --tos 8
&lt;/code&gt;


&lt;h3&gt;
Inspecting individual bits&lt;/h3&gt;
I'd like to look at the "&lt;b&gt;More Fragments&lt;/b&gt;" flag - a flag
which has no existing test in iptables (-f matches 2nd and further
fragments, I want to match all fragments except the last).  Byte 6
contains this, so I'll start with offset 3 and throw away bytes 3-5. 
Normally this would use a mask of 0x000000FF, but I also want to discard
the other bits in that last byte.  The only bit I want to keep is the
third from the top (0010 0000), so the mask I'll use is 0x00000020 . 
Now I have two choices; move that bit down to the lowest position and
compare, or leave it in its current position and compare.&lt;br /&gt;


	To move it down, we'll right shift 5 bits.  The final test
is:&lt;br /&gt;


&lt;code&gt;
iptables -m u32 --u32 "3&amp;amp;0x20&amp;gt;&amp;gt;5=1"
&lt;/code&gt;

	If I take the other approach of leaving the bit where it is,
I need to be careful about the compare value on the right.  If that bit
is turned on, the compare value needs to be 0x20 as well.&lt;br /&gt;


&lt;code&gt;
iptables -m u32 --u32 "3&amp;amp;0x20=0x20"
&lt;/code&gt;

	Both approaches return true if the More Fragments flag is
turned on.&lt;br /&gt;



&lt;h3&gt;
Combining tests&lt;/h3&gt;
If you want to inspect more than one aspect of a packet, use:&lt;br /&gt;


&lt;code&gt;
&amp;amp;&amp;amp;
&lt;/code&gt;

	between each test.&lt;br /&gt;



&lt;h3&gt;
Moving on to the TCP header&lt;/h3&gt;
This is a little tricky.  Let's say I'd like to look at bytes
4-7 of the TCP header (the &lt;b&gt;TCP sequence number&lt;/b&gt;).  Let's take the
simple approach first, and then look at some ways to improve this.&lt;br /&gt;


	For our first version, let's assume that the IP header is 20
bytes long - usually a good guess.  Our starting point is byte 4 of the
tcp header that immediately follows the IP header.  Our simplistic test
for whether the sequence number is 41 (hex 29) might look like this:&lt;br /&gt;


&lt;code&gt;
iptables -m u32 --u32 "24=0x29"
&lt;/code&gt;

	For packets where the IP header length is 20, this will
actually work, but there are a few problems.  Let's fix them one by
one.&lt;br /&gt;


	First, we never check to see if the packet is even a TCP
packet.  This is stored in byte 9 of the IP header, so we'll pull 4
bytes starting at byte 6, drop 6-8, and check to see if it's 6.  The new 
rule that first checks if this is a TCP packet at all and also checks
that the Sequence Number is 41 is:&lt;br /&gt;


&lt;code&gt;
iptables -m u32 --u32 "6&amp;amp;0xFF=0x6 &amp;amp;&amp;amp; 24=0x29"
&lt;/code&gt;

	The second problem we've momentarily ignored is the IP header
length.  True, it usually is 20 bytes long, but it &lt;i&gt;can&lt;/i&gt; be longer,
if IP options are used.&lt;br /&gt;




	Here are the steps.  We pull the IP header length (a nibble
that shows how many 4 bytes words there are in the header, usually 5)
out of the IP header.  We multiply it by 4 to get the number of bytes in
the IP header.  We use this number to say how many bytes to jump to get
to the beginning of the TCP header, and jump 4 more bytes to get to the
Sequence number.&lt;br /&gt;


	To get the header length, we need the first byte:
&lt;code&gt;"0&amp;gt;&amp;gt;24"&lt;/code&gt;, but we need to only grab the lower nibble and we
need to multiply that number by 4 to get the actual number of bytes in
the header.  To do the multiply, we'll right shift 22 instead of 24. 
With this shift, we'll need to use a mask of 0x3C instead of the 0x0F we
would have used.  The expression so far is: &lt;code&gt;"0&amp;gt;&amp;gt;22&amp;amp;0x3C"&lt;/code&gt;. 
On an IP header with no options, that expression returns 20; just what
we'd expect.  Now we need to tell u32 to &lt;i&gt;use&lt;/i&gt; that number and make
a jump that many bytes into the packet, a step performed by the "@"
operator.&lt;br /&gt;


&lt;code&gt;
iptables -m u32 --u32 "6&amp;amp;0xFF=0x6 &amp;amp;&amp;amp; 0&amp;gt;&amp;gt;22&amp;amp;0x3C@4=0x29"
&lt;/code&gt;

	The "@" grabs the number we created on its left (20,
normally) and jumps that many bytes forward (we can even do this more
than once - see the TCP payload section below).  The 4 to its right
tells u32 to grab bytes 4-7, but u32 knows to pull them relative to the
20 bytes it skipped over.  This gives us the Sequence Number, even if
the IP header grows because of options.  *phew*!&lt;br /&gt;


	The last quirk to handle is fragments.  When we were only
working with the IP header, this wasn't an issue; IP is designed in such
a way that the IP header itself can never be fragmented.  The TCP header
and application payload technically might be, and if we're handed the
second or further fragment, we might be looking not at the Sequence
Number in bytes 4-7, but perhaps some other part of the TCP header, or
more likely, some application layer data.&lt;br /&gt;


	What we'll do is check that this is the first fragment (or an
unfragmented packet, the test won't care), so that we're sure we're
looking at tcp header info.  To do this, we test the fragment offset in
most (we discard the top three flag bits) of bytes 6 and 7 of the IP
header to make sure the offset is 0.  The test is:
&lt;code&gt;"4&amp;amp;0x1FFF=0"&lt;/code&gt;

	&lt;br /&gt;
The final expression (check for TCP, check for unfragmented
packet or first fragment, and jump over the IP header, checking that
bytes 4-7 of the TCP header are equal to 41) is:&lt;br /&gt;


&lt;code&gt;
iptables -m u32 --u32 "6&amp;amp;0xFF=0x6 &amp;amp;&amp;amp; 4&amp;amp;0x1FFF=0 &amp;amp;&amp;amp; 0&amp;gt;&amp;gt;22&amp;amp;0x3C@4=0x29"
&lt;/code&gt;

	If the packet is, in fact, fragmented, we have one more
consideration; the fragment might be so small that the field we're
testing might have been put in a future fragment!  In this one case,
it's not an issue because every IP link should handle packets of at
least 68 bytes; even if the IP header was at its maximum of 60 bytes,
the first 8 bytes of the TCP header should be included in that first
fragment.&lt;br /&gt;


	When we start testing for things further in to the packet,
we'll have to depend on u32's ability to simply return false if we ever
try to ask for a value that falls outside of the packet being
inspected.&lt;br /&gt;



&lt;h3&gt;
Checking for values in the ICMP header&lt;/h3&gt;
Let's look for ICMP Host Unreachables (ICMP, type 3, code 1). 
Just as in the above example, we need to check for the Protocol field
(Protocol 1 = ICMP this time) and that we're looking at a complete
packet or at least the first fragment: &lt;code&gt;"6&amp;amp;0xFF=1 &amp;amp;&amp;amp;
4&amp;amp;0x1FFF=0"&lt;/code&gt;&lt;br /&gt;


	To check for the ICMP Type and Code, we skip over the IP
header again (&lt;code&gt;"0&amp;gt;&amp;gt;22&amp;amp;0x3C@..."&lt;/code&gt;).  To grab the first two
bytes, we'll start at offset 0 and just right shift 16 bits.  The final
test is:&lt;br /&gt;


&lt;code&gt;
iptables -m u32 --u32 "6&amp;amp;0xFF=1 &amp;amp;&amp;amp; 4&amp;amp;0x1FFF=0 &amp;amp;&amp;amp; 0&amp;gt;&amp;gt;22&amp;amp;0x3C@0&amp;gt;&amp;gt;16=0x0301"
&lt;/code&gt;


&lt;h3&gt;
Checking for values in the UDP payload&lt;/h3&gt;
Lets try going all the way into the packet payload now, and
match packets that are UDP DNS queries.  Here we're not only going to
check for destination port 53, but we're also going to test the top bit
of byte 2 of the payload; if set, this is a DNS query.&lt;br /&gt;


	We start by checking that this is a UDP packet:
&lt;code&gt;"6&amp;amp;0xFF=17"&lt;/code&gt;.  We add the now familiar check for first
fragment: &lt;code&gt;"4&amp;amp;0x1FFF=0"&lt;/code&gt;.&lt;br /&gt;


	To test the destination port, we grab bytes 2 and 3 from the
udp header (after jumping over the IP header as in the previous
examples): &lt;code&gt;"0&amp;gt;&amp;gt;22&amp;amp;0x3C@0&amp;amp;0xFFFF=53"&lt;/code&gt;.&lt;br /&gt;


	If the packet has passed all of the above, we go back to
check the payload (remember we have to jump over the variable-length IP
and 8 byte UDP headers &lt;code&gt;"0&amp;gt;&amp;gt;22&amp;amp;0x3C@8 ..."&lt;/code&gt;) to make sure
this is a DNS &lt;i&gt;query&lt;/i&gt; rather than a response.  To grab the high bit
from byte 2, I'll use offset 8 to grab the first 4 payload bytes, right
shift 15 bits to deposit the Query bit in the lowest position, and throw
away all the rest of the bits with a mask of 0x01:
&lt;code&gt;"0&amp;gt;&amp;gt;22&amp;amp;0x3C@8&amp;gt;&amp;gt;15&amp;amp;0x01=1"&lt;/code&gt;&lt;br /&gt;


	The final test is:&lt;br /&gt;


&lt;code&gt;
iptables -m u32 --u32 "6&amp;amp;0xFF=17 &amp;amp;&amp;amp; 4&amp;amp;0x1FFF=0 
&amp;amp;&amp;amp; 0&amp;gt;&amp;gt;22&amp;amp;0x3C@0&amp;amp;0xFFFF=53 &amp;amp;&amp;amp; 
0&amp;gt;&amp;gt;22&amp;amp;0x3C@8&amp;gt;&amp;gt;15&amp;amp;0x01=1"
&lt;/code&gt;

	Ugh.  I've seen stellar noise that had less entropy  :-) 
Note that we're doing the whole thing with u32 checks; we could pull out
the "udp", "first/no fragment" and "port 53" checks into other modules,
and end up with this slightly more readable version:&lt;br /&gt;


&lt;code&gt;
iptables -p udp --dport 53 \! -f -m u32 --u32 "0&amp;gt;&amp;gt;22&amp;amp;0x3C@8&amp;gt;&amp;gt;15&amp;amp;0x01=1"
&lt;/code&gt;




&lt;h3&gt;
Checking for values in the TCP payload&lt;/h3&gt;
As with the udp payload example above, this approach is only
useful if we're absolutely certain of where our data of interest can be
found.  In this example, I want to find ssh sessions, even if they're on
a port _other_ than 22.  But wait - ssh connections are encrypted!  
Sounds hopeless?  Actually, it isn't.&lt;br /&gt;


	The first thing to happen in an ssh connection is that the
server sends a protocol string back to the client.  The protocol looks like:

&lt;code&gt;
SSH-protoversion-softwareversion comments
&lt;/code&gt;

	&lt;br /&gt;
The protoversion is generally 1.99, 2.0, or 1.5 .  The entire
line, including a possible trailing carriage return and linefeed, needs
to be smaller than 255 bytes.  This line _may_ have another line before
it, but this would break compatibility with ssh 1.0 clients, so I'm
guessing this is uncommon.  The above information comes from
&lt;a href="http://www.ietf.org/internet-drafts/draft-ietf-secsh-transport-17.txt"&gt;draft-ietf-secsh-transport-17.txt&lt;/a&gt;
, if you want to see more details.&lt;br /&gt;


	The interesting piece, as far as we're concerned, is that
"SSH-" string.  It lands in the first 4 bytes of the connection.  Bingo! 
We can use the u32 module to look at only those bytes in the early part
of a connection; this is a much less intensive check than checking with
the string module, and makes it feasible to look for ssh connections on
any port without undue load on the firewall.&lt;br /&gt;


	Lets get the easy stuff out of the way.  I want to check tcp
packets, unfragmented ones, I'm only interested in packets in the first 255 bytes of a
connection, and established ones, obviously, and the entire packet
length needs to be between 45 and 375 bytes (think about the minimums
and maximums for IP and tcp headers and ssh protocol string):&lt;br /&gt;


&lt;code&gt;
iptables -p tcp \! -f -m connbytes --connbytes 0:255 -m state --state ESTABLISHED -m length --length 46:375
&lt;/code&gt;

	With these restrictions, we should be inspecting very few
packets; this allows us to look at the first few packets of every
connection for legitimate or rogue ssh connections.&lt;br /&gt;


	Now u32 does its magic.  We'll build it up from scratch. 
Because we've already checked for protocol TCP, we'll skip 6&amp;amp;0xFF=0x6. 
We skip over the IP header with &lt;code&gt;0&amp;gt;&amp;gt;22&amp;amp;0x3C@&lt;/code&gt;:&lt;br /&gt;


&lt;code&gt;
0&amp;gt;&amp;gt;22&amp;amp;0x3C@
&lt;/code&gt;

	We now need to skip over the tcp header; we pull the TCP
header length from the first half of byte 12.  Although we'd need to
right shift it 28 bits to get it into the last 4 bits of our 32 bit
buffer, we have to multiply this by 4, too, to get the number of 4-byte
words this number expresses; this is why we right shift by 26 and mask
again with 0x3C:&lt;br /&gt;


&lt;code&gt;
0&amp;gt;&amp;gt;22&amp;amp;0x3C@ 12&amp;gt;&amp;gt;26&amp;amp;0x3C@
&lt;/code&gt;

	This slides us into the tcp payload portion of the packet. 
As the bytes we want to test should generally be in the first 4 bytes of
the packet, we just grab 4 bytes starting at 0 and compare them to
0x5353482D (the hex equivalent of "SSH-"):&lt;br /&gt;


&lt;code&gt;
0&amp;gt;&amp;gt;22&amp;amp;0x3C@ 12&amp;gt;&amp;gt;26&amp;amp;0x3C@ 0=0x5353482D
&lt;/code&gt;

	Here's the entire test, line wrapped to save screen space:&lt;br /&gt;


&lt;code&gt;
iptables -p tcp \! -f -m connbytes --connbytes 0:255 -m state --state ESTABLISHED
 -m length --length 46:375 -m u32 --u32 "0&amp;gt;&amp;gt;22&amp;amp;0x3C@ 12&amp;gt;&amp;gt;26&amp;amp;0x3C@ 0=0x5353482D"
&lt;/code&gt;

	Once I've done this, I can even check for specific SSH
protocol versions with &lt;code&gt;-m string --string "SSH-1.99"&lt;/code&gt; or
even as specific as &lt;code&gt;-m string --string
"SSH-1.99-OpenSSH_3.7.1p2"&lt;/code&gt; .  This string match - normally very
expensive in terms of processor time per packet - isn't bad at all if
we've already figured out with the previous iptables command that this
is almost certainly an ssh protocol string.  By essentially requiring
"SSH-" in the first 4 bytes of the connection, we avoid the problem of
the string match incorrectly matching "SSH-" when someone downloads this
article over port 80.&lt;br /&gt;


&lt;h3&gt;
Wrapup&lt;/h3&gt;
With homage to Douglas Adams, Don't Panic.&lt;br /&gt;


	The examples we've worked through have been annoyingly
complex.  The nice part?  You don't have to rewrite them every time you
want to inspect something else in the icmp header, or tcp payload, or
anything else.  Just grab the appropriate tests from above - or the
table below - and finish them off with the specific field you wanted to
inspect.&lt;br /&gt;























&lt;h3&gt;
Tests&lt;/h3&gt;
First, a recap of the above, then some additional tests.&lt;br /&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;code&gt;"2&amp;amp;0xFFFF=0x2:0x0100"&lt;/code&gt;

&lt;/dt&gt;
&lt;dd&gt;Test for IPID's between 2 and 256

&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;"0&amp;amp;0xFFFF=0x100:0xFFFF"&lt;/code&gt;

&lt;/dt&gt;
&lt;dd&gt;Check for packets with 256 or more bytes.

&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;"5&amp;amp;0xFF=0:3"&lt;/code&gt;

&lt;/dt&gt;
&lt;dd&gt;Match packets with a TTL of 3 or less.

&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;"16=0xE0000001"&lt;/code&gt;

&lt;/dt&gt;
&lt;dd&gt;Destination IP address is 224.0.0.1

&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;"12&amp;amp;0xFFFFFF00=0xC0A80F00"&lt;/code&gt;

&lt;/dt&gt;
&lt;dd&gt;Source IP is in the 192.168.15.X class C network.

&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;0&amp;amp;0x00FF0000&amp;gt;&amp;gt;16=0x08&lt;/code&gt;

&lt;/dt&gt;
&lt;dd&gt;Is the TOS field 8 (Maximize Throughput)?

&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;"3&amp;amp;0x20&amp;gt;&amp;gt;5=1"&lt;/code&gt;

&lt;/dt&gt;
&lt;dd&gt;Is the More Fragments flag set?

&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;"6&amp;amp;0xFF=0x6"&lt;/code&gt;

&lt;/dt&gt;
&lt;dd&gt;Is the packet a TCP packet?

&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;"4&amp;amp;0x1FFF=0"&lt;/code&gt;

&lt;/dt&gt;
&lt;dd&gt;Is the fragment offset 0?  (If so, this is either an unfragmented
packet or the first fragment).

&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;"0&amp;gt;&amp;gt;22&amp;amp;0x3C@4=0x29"&lt;/code&gt;

&lt;/dt&gt;
&lt;dd&gt;Is the TCP Sequence number 41?  (This requires the previous two
checks for TCP and First Fragment as well)

&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;"0&amp;gt;&amp;gt;22&amp;amp;0x3C@0&amp;gt;&amp;gt;16=0x0301"&lt;/code&gt;

&lt;/dt&gt;
&lt;dd&gt;Check for ICMP type=3 and code=1 (needs UDP and first fragment tests too)

&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;"0&amp;gt;&amp;gt;22&amp;amp;0x3C@0&amp;amp;0xFFFF=53"&lt;/code&gt;

&lt;/dt&gt;
&lt;dd&gt;Is the UDP destination port 53?  (Check for udp and first/no
fragment first)

&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;"0&amp;gt;&amp;gt;22&amp;amp;0x3C@8&amp;gt;&amp;gt;15&amp;amp;0x01=1"&lt;/code&gt;

&lt;/dt&gt;
&lt;dd&gt;Check that the UDP DNS Query bit is set (again, check for UDP,
first/no fragment, and dest port 53 first).

&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;"0&amp;gt;&amp;gt;22&amp;amp;0x3C@ 12&amp;gt;&amp;gt;26&amp;amp;0x3C@ 0=0x5353482D"&lt;/code&gt;

&lt;/dt&gt;
&lt;dd&gt;Are the first 4 bytes of the TCP payload "SSH-"?  (this requires a
number of additional checks; the entire line is:

&lt;code&gt;
iptables -p tcp \! -f -m connbytes --connbytes 0:255 -m state --state ESTABLISHED
 -m length --length 46:375 -m u32 --u32 "0&amp;gt;&amp;gt;22&amp;amp;0x3C@ 12&amp;gt;&amp;gt;26&amp;amp;0x3C@ 0=0x5353482D"
&lt;/code&gt;






































	And now, some new tests:&lt;br /&gt;


&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;"6&amp;amp;0xFF=1"&lt;/code&gt;

&lt;/dt&gt;
&lt;dd&gt;Is this an ICMP packet?  (From Don Cohen's documentation)

&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;"6&amp;amp;0xFF=17"&lt;/code&gt;

&lt;/dt&gt;
&lt;dd&gt;Is this a UDP packet?

&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;"4&amp;amp;0x3FFF=0"&lt;/code&gt;

&lt;/dt&gt;
&lt;dd&gt;Is the fragment offset 0 &lt;i&gt;and&lt;/i&gt; MF cleared?  (If so, this is an
unfragmented packet).

&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;"4&amp;amp;0x3FFF=1:0x3FFF"&lt;/code&gt;

&lt;/dt&gt;
&lt;dd&gt;Is the fragment offset greater than 0 &lt;i&gt;or&lt;/i&gt; MF set?  (If so,
this is a fragment).

&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;0&amp;gt;&amp;gt;22&amp;amp;0x3C@12&amp;gt;&amp;gt;26&amp;amp;0x3C@-3&amp;amp;0xFF=0:255&lt;/code&gt;

&lt;/dt&gt;
&lt;dd&gt;Is there any payload on this tcp packet (check for tcp and not
fragmented first)?  This elegant test was contributed by Don Cohen as I
fumbled for a way to look for payload on a syn packet.  By simply
testing to see if payload byte 0 has a value between 0 and 255, we get
true if payload byte 0 exists (read: "if there is any payload at all"),
and false if we've gone beyond the end of the packet (read: "if there is
no payload").

&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;"0&amp;gt;&amp;gt;22&amp;amp;0x3C@8=3000"&lt;/code&gt;

&lt;/dt&gt;
&lt;dd&gt;Is the TCP ack field 3000?  (This, too, needs the TCP and First
fragment checks)

&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;"0&amp;gt;&amp;gt;22&amp;amp;0x3C@10&amp;amp;0x80=0x80"&lt;/code&gt;

&lt;/dt&gt;
&lt;dd&gt;Is the high order bit (CWR) of the TCP flag byte (13) turned on? 
(Needs TCP and first fragment checks too).  To see if it's off, use =0
at the end instead of =0x80.

&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;"0&amp;gt;&amp;gt;22&amp;amp;0x3C@10&amp;amp;0x40=0x40"&lt;/code&gt;

&lt;/dt&gt;
&lt;dd&gt;Is the next bit down (ECN-Echo) turned on? Likewise, =0 to see if
it's off.

&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;"3&amp;amp;0xE0=0x20"&lt;/code&gt;

&lt;/dt&gt;
&lt;dd&gt;Is the More Fragments bit set, and are the Reserved and Don't
fragment flags cleared?

&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;"3&amp;amp;0x20=0x20"&lt;/code&gt;

&lt;/dt&gt;
&lt;dd&gt;This also checks if MF is set, but doesn't care about Reserved or
Don't fragment.

&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;"3&amp;amp;0xE0=0x60"&lt;/code&gt;

&lt;/dt&gt;
&lt;dd&gt;Are More Fragments and Don't fragment set, and is Reserved cleared?

&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;"3&amp;amp;0xE0=0x80"&lt;/code&gt;

&lt;/dt&gt;
&lt;dd&gt;Is reserved set, and are More Fragments and Don't fragment cleared?

&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;"0&amp;gt;&amp;gt;22&amp;amp;0x3C@2&amp;amp;0xFFFF=0"&lt;/code&gt;

&lt;/dt&gt;
&lt;dd&gt;Is the ICMP ID (inside an echo request or reply packet) 0?  This
assumes you've already checked that the packet is icmp, unfragmented,
and an echo request or reply.

&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;"0&amp;gt;&amp;gt;22&amp;amp;0x3C@4&amp;amp;0xFFFF=35"&lt;/code&gt;

&lt;/dt&gt;
&lt;dd&gt;Is the ICMP echo Sequence number 35?


&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;&lt;/code&gt;

&lt;/dt&gt;
&lt;dd&gt;




&lt;/dd&gt;&lt;/dl&gt;
&lt;hr /&gt;


	Don Cohen wrote the u32 module, and also wrote some (if
you'll forgive me) somewhat cryptic documentation inside the source code
for the module.  William Stearns wrote this text, which borrows some
examples and concepts from Don's documentation.  Many thanks to Don for
reviewing an early draft of this article.  Thanks also to Gary Kessler
and Sans for making the TCP/IP pocket reference guide freely
available.&lt;br /&gt;
&lt;br /&gt;
http://www.stearns.org/doc/iptables-u32.v0.1.7.html</description><author>emaknyus@gmail.com (tamvan &amp;amp; verani)</author></item><item><title>unix toolbox</title><link>http://emaknyus.blogspot.com/2011/09/unix-toolbox.html</link><category>cli</category><category>command</category><category>unixtool</category><pubDate>Thu, 8 Sep 2011 16:15:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3787219161379371544.post-1681722330615919115</guid><description>This document is a collection of Unix/Linux/BSD commands and tasks which are useful for IT work or for advanced users. This is a practical guide with concise explanations, however the reader is supposed to know what s/he is doing.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Unix Toolbox revision 14.3&lt;br /&gt;
&lt;br /&gt;
The latest version of this document can be found at http://cb.vu/unixtoolbox.xhtml. Replace .xhtml on the link with .pdf for the PDF version and with .book.pdf for the booklet version. On a duplex printer the booklet will create a small book ready to bind. This XHTML page can be converted into a nice PDF document with a CSS3 compliant application (see the script example). See also the about page.&lt;br /&gt;
&lt;br /&gt;
Error reports and comments are most welcome - c@cb.vu Colin Barschel.&lt;br /&gt;
&lt;br /&gt;
© Colin Barschel 2007-2011. Some rights reserved under Creative Commons.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 1.&amp;nbsp;&amp;nbsp; System&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 2.&amp;nbsp;&amp;nbsp; Processes&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 3.&amp;nbsp;&amp;nbsp; File System&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 4.&amp;nbsp;&amp;nbsp; Network&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 5.&amp;nbsp;&amp;nbsp; SSH SCP&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 6.&amp;nbsp;&amp;nbsp; VPN with SSH&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 7.&amp;nbsp;&amp;nbsp; RSYNC&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 8.&amp;nbsp;&amp;nbsp; SUDO&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 9.&amp;nbsp;&amp;nbsp; Encrypt Files&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 10.&amp;nbsp;&amp;nbsp; Encrypt Partitions&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 11.&amp;nbsp;&amp;nbsp; SSL Certificates&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 12.&amp;nbsp;&amp;nbsp; CVS&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 13.&amp;nbsp;&amp;nbsp; SVN&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 14.&amp;nbsp;&amp;nbsp; Useful Commands&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 15.&amp;nbsp;&amp;nbsp; Install Software&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 16.&amp;nbsp;&amp;nbsp; Convert Media&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 17.&amp;nbsp;&amp;nbsp; Printing&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 18.&amp;nbsp;&amp;nbsp; Databases&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 19.&amp;nbsp;&amp;nbsp; Disk Quota&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 20.&amp;nbsp;&amp;nbsp; Shells&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 21.&amp;nbsp;&amp;nbsp; Scripting&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 22.&amp;nbsp;&amp;nbsp; Programming&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 23.&amp;nbsp;&amp;nbsp; Online Help&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;white&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;black&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
System&lt;br /&gt;
&lt;br /&gt;
Hardware | Statistics | Users | Limits | Runlevels | root password | Compile kernel | Repair grub&lt;br /&gt;
&lt;br /&gt;
Running kernel and system information&lt;br /&gt;
&lt;br /&gt;
# uname -a&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Get the kernel version (and BSD version)&lt;br /&gt;
# lsb_release -a&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Full release info of any LSB distribution&lt;br /&gt;
# cat /etc/SuSE-release&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Get SuSE version&lt;br /&gt;
# cat /etc/debian_version&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Get Debian version&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Use /etc/DISTR-release with DISTR= lsb (Ubuntu), redhat, gentoo, mandrake, sun (Solaris), and so on. See also /etc/issue.&lt;br /&gt;
&lt;br /&gt;
# uptime&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Show how long the system has been running + load&lt;br /&gt;
# hostname&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # system's host name&lt;br /&gt;
# hostname -i&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Display the IP address of the host. (Linux only)&lt;br /&gt;
# man hier&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Description of the file system hierarchy&lt;br /&gt;
# last reboot&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Show system reboot history&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Hardware Informations&lt;br /&gt;
&lt;br /&gt;
Kernel detected hardware&lt;br /&gt;
&lt;br /&gt;
# dmesg&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Detected hardware and boot messages&lt;br /&gt;
# lsdev&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # information about installed hardware&lt;br /&gt;
# dd if=/dev/mem bs=1k skip=768 count=256 2&amp;gt;/dev/null | strings -n 8 # Read BIOS&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Linux&lt;br /&gt;
&lt;br /&gt;
# cat /proc/cpuinfo&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # CPU model&lt;br /&gt;
# cat /proc/meminfo&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Hardware memory&lt;br /&gt;
# grep MemTotal /proc/meminfo&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Display the physical memory&lt;br /&gt;
# watch -n1 'cat /proc/interrupts'&amp;nbsp;&amp;nbsp; # Watch changeable interrupts continuously&lt;br /&gt;
# free -m&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Used and free memory (-m for MB)&lt;br /&gt;
# cat /proc/devices&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Configured devices&lt;br /&gt;
# lspci -tv&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Show PCI devices&lt;br /&gt;
# lsusb -tv&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Show USB devices&lt;br /&gt;
# lshal&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Show a list of all devices with their properties&lt;br /&gt;
# dmidecode&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Show DMI/SMBIOS: hw info from the BIOS&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
FreeBSD&lt;br /&gt;
&lt;br /&gt;
# sysctl hw.model&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # CPU model&lt;br /&gt;
# sysctl hw&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Gives a lot of hardware information&lt;br /&gt;
# sysctl hw.ncpu&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # number of active CPUs installed&lt;br /&gt;
# sysctl vm&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Memory usage&lt;br /&gt;
# sysctl hw.realmem&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Hardware memory&lt;br /&gt;
# sysctl -a | grep mem&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Kernel memory settings and info&lt;br /&gt;
# sysctl dev&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Configured devices&lt;br /&gt;
# pciconf -l -cv&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Show PCI devices&lt;br /&gt;
# usbdevs -v&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Show USB devices&lt;br /&gt;
# atacontrol list&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Show ATA devices&lt;br /&gt;
# camcontrol devlist -v&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Show SCSI devices&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Load, statistics and messages&lt;br /&gt;
&lt;br /&gt;
The following commands are useful to find out what is going on on the system.&lt;br /&gt;
&lt;br /&gt;
# top&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # display and update the top cpu processes&lt;br /&gt;
# mpstat 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # display processors related statistics&lt;br /&gt;
# vmstat 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # display virtual memory statistics&lt;br /&gt;
# iostat 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # display I/O statistics (2 s intervals)&lt;br /&gt;
# systat -vmstat 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # BSD summary of system statistics (1 s intervals)&lt;br /&gt;
# systat -tcp 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # BSD tcp connections (try also -ip)&lt;br /&gt;
# systat -netstat 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # BSD active network connections&lt;br /&gt;
# systat -ifstat 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # BSD network traffic through active interfaces&lt;br /&gt;
# systat -iostat 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # BSD CPU and and disk throughput&lt;br /&gt;
# tail -n 500 /var/log/messages&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Last 500 kernel/syslog messages&lt;br /&gt;
# tail /var/log/warn&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # System warnings messages see syslog.conf&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Users&lt;br /&gt;
&lt;br /&gt;
# id&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Show the active user id with login and group&lt;br /&gt;
# last&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Show last logins on the system&lt;br /&gt;
# who&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Show who is logged on the system&lt;br /&gt;
# groupadd admin&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Add group "admin" and user colin (Linux/Solaris)&lt;br /&gt;
# useradd -c "Colin Barschel" -g admin -m colin&lt;br /&gt;
# usermod -a -G &amp;lt;group&amp;gt; &amp;lt;user&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Add existing user to group (Debian)&lt;br /&gt;
# groupmod -A &amp;lt;user&amp;gt; &amp;lt;group&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Add existing user to group (SuSE)&lt;br /&gt;
# userdel colin&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Delete user colin (Linux/Solaris)&lt;br /&gt;
# adduser joe&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # FreeBSD add user joe (interactive)&lt;br /&gt;
# rmuser joe&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # FreeBSD delete user joe (interactive)&lt;br /&gt;
# pw groupadd admin&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Use pw on FreeBSD&lt;br /&gt;
# pw groupmod admin -m newmember&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Add a new member to a group&lt;br /&gt;
# pw useradd colin -c "Colin Barschel" -g admin -m -s /bin/tcsh &lt;br /&gt;
# pw userdel colin; pw groupdel admin&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Encrypted passwords are stored in /etc/shadow for Linux and Solaris and /etc/master.passwd on FreeBSD. If the master.passwd is modified manually (say to delete a password), run # pwd_mkdb -p master.passwd to rebuild the database.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To temporarily prevent logins system wide (for all users but root) use nologin. The message in nologin will be displayed (might not work with ssh pre-shared keys).&lt;br /&gt;
&lt;br /&gt;
# echo "Sorry no login now" &amp;gt; /etc/nologin&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # (Linux)&lt;br /&gt;
# echo "Sorry no login now" &amp;gt; /var/run/nologin&amp;nbsp;&amp;nbsp; # (FreeBSD)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Limits&lt;br /&gt;
&lt;br /&gt;
Some application require higher limits on open files and sockets (like a proxy&lt;br /&gt;
web server, database). The default limits are usually too low.&lt;br /&gt;
Linux&lt;br /&gt;
&lt;br /&gt;
Per shell/script&lt;br /&gt;
&lt;br /&gt;
The shell limits are governed by ulimit. The status is checked&lt;br /&gt;
with ulimit -a. For example to change the open files limit from&lt;br /&gt;
1024 to 10240 do:&lt;br /&gt;
&lt;br /&gt;
# ulimit -n 10240&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # This is only valid within the shell&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The ulimit command can be used in a script to change the limits for the script only.&lt;br /&gt;
&lt;br /&gt;
Per user/process&lt;br /&gt;
&lt;br /&gt;
Login users and applications can be configured in /etc/security/limits.conf. For example:&lt;br /&gt;
&lt;br /&gt;
# cat /etc/security/limits.conf&lt;br /&gt;
*&amp;nbsp;&amp;nbsp; hard&amp;nbsp;&amp;nbsp;&amp;nbsp; nproc&amp;nbsp;&amp;nbsp; 250&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Limit user processes&lt;br /&gt;
asterisk hard nofile 409600&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Limit application open files&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
System wide&lt;br /&gt;
&lt;br /&gt;
Kernel limits are set with sysctl. Permanent limits are set in /etc/sysctl.conf.&lt;br /&gt;
&lt;br /&gt;
# sysctl -a&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # View all system limits&lt;br /&gt;
# sysctl fs.file-max&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # View max open files limit&lt;br /&gt;
# sysctl fs.file-max=102400&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Change max open files limit&lt;br /&gt;
# echo "1024 50000" &amp;gt; /proc/sys/net/ipv4/ip_local_port_range&amp;nbsp; # port range&lt;br /&gt;
# cat /etc/sysctl.conf&lt;br /&gt;
fs.file-max=102400&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Permanent entry in sysctl.conf&lt;br /&gt;
# cat /proc/sys/fs/file-nr&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # How many file descriptors are in use&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
FreeBSD&lt;br /&gt;
&lt;br /&gt;
Per shell/script&lt;br /&gt;
&lt;br /&gt;
Use the command limits in csh or tcsh or as in Linux, use ulimit in an sh or bash shell.&lt;br /&gt;
Per user/process&lt;br /&gt;
&lt;br /&gt;
The default limits on login are set in /etc/login.conf. An unlimited value is still limited by the system maximal value.&lt;br /&gt;
System wide&lt;br /&gt;
&lt;br /&gt;
Kernel limits are also set with sysctl. Permanent limits are set in /etc/sysctl.conf or /boot/loader.conf. The syntax is the same as Linux but the keys are different.&lt;br /&gt;
&lt;br /&gt;
# sysctl -a&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # View all system limits&lt;br /&gt;
# sysctl kern.maxfiles=XXXX&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # maximum number of file descriptors&lt;br /&gt;
kern.ipc.nmbclusters=32768&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Permanent entry in /etc/sysctl.conf&lt;br /&gt;
kern.maxfiles=65536&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Typical values for Squid&lt;br /&gt;
kern.maxfilesperproc=32768&lt;br /&gt;
kern.ipc.somaxconn=8192&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # TCP queue. Better for apache/sendmail&lt;br /&gt;
# sysctl kern.openfiles&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # How many file descriptors are in use&lt;br /&gt;
# sysctl kern.ipc.numopensockets&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # How many open sockets are in use&lt;br /&gt;
# sysctl net.inet.ip.portrange.last=50000 # Default is 1024-5000&lt;br /&gt;
# netstat -m&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # network memory buffers statistics&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
See The FreeBSD handbook Chapter 11http://www.freebsd.org/handbook/configtuning-kernel-limits.html for details.&lt;br /&gt;
&lt;br /&gt;
Solaris&lt;br /&gt;
&lt;br /&gt;
The following values in /etc/system will increase the maximum file descriptors per proc:&lt;br /&gt;
&lt;br /&gt;
set rlim_fd_max = 4096&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Hard limit on file descriptors for a single proc&lt;br /&gt;
set rlim_fd_cur = 1024&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Soft limit on file descriptors for a single proc&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Runlevels&lt;br /&gt;
&lt;br /&gt;
Linux&lt;br /&gt;
&lt;br /&gt;
Once booted, the kernel starts init which then starts rc which starts all scripts belonging to a runlevel. The scripts are stored in /etc/init.d and are linked into /etc/rc.d/rcN.d with N the runlevel number.&lt;br /&gt;
&lt;br /&gt;
The default runlevel is configured in /etc/inittab. It is usually 3 or 5:&lt;br /&gt;
&lt;br /&gt;
# grep default: /etc/inittab&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
id:3:initdefault:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The actual runlevel can be changed with init. For example to go from 3 to 5:&lt;br /&gt;
&lt;br /&gt;
# init 5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Enters runlevel 5&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Shutdown and halt&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Single-User mode (also S)&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Multi-user without network&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; 3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Multi-user with network&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Multi-user with X&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; 6&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Reboot&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Use chkconfig to configure the programs that will be started at boot in a runlevel.&lt;br /&gt;
&lt;br /&gt;
# chkconfig --list&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # List all init scripts&lt;br /&gt;
# chkconfig --list sshd&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Report the status of sshd&lt;br /&gt;
# chkconfig sshd --level 35 on&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Configure sshd for levels 3 and 5&lt;br /&gt;
# chkconfig sshd off&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Disable sshd for all runlevels&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Debian and Debian based distributions like Ubuntu or Knoppix use the command update-rc.d to manage the runlevels scripts. Default is to start in 2,3,4 and 5 and shutdown in 0,1 and 6.&lt;br /&gt;
&lt;br /&gt;
# update-rc.d sshd defaults&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Activate sshd with the default runlevels&lt;br /&gt;
# update-rc.d sshd start 20 2 3 4 5 . stop 20 0 1 6 .&amp;nbsp; # With explicit arguments&lt;br /&gt;
# update-rc.d -f sshd remove&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Disable sshd for all runlevels&lt;br /&gt;
# shutdown -h now (or # poweroff)&amp;nbsp;&amp;nbsp;&amp;nbsp; # Shutdown and halt the system&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
FreeBSD&lt;br /&gt;
&lt;br /&gt;
The BSD boot approach is different from the SysV, there are no runlevels. The final boot state (single user, with or without X) is configured in /etc/ttys. All OS scripts are located in /etc/rc.d/ and in /usr/local/etc/rc.d/ for third-party applications. The activation of the service is configured in /etc/rc.conf and /etc/rc.conf.local. The default behavior is configured in /etc/defaults/rc.conf. The scripts responds at least to start|stop|status.&lt;br /&gt;
&lt;br /&gt;
# /etc/rc.d/sshd status&lt;br /&gt;
sshd is running as pid 552.&lt;br /&gt;
# shutdown now&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Go into single-user mode&lt;br /&gt;
# exit&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Go back to multi-user mode&lt;br /&gt;
# shutdown -p now&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Shutdown and halt the system&lt;br /&gt;
# shutdown -r now&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Reboot&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The process init can also be used to reach one of the following states level. For example # init 6 for reboot.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Halt and turn the power off (signal USR2)&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Go to single-user mode (signal TERM)&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; 6&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Reboot the machine (signal INT)&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; c&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Block further logins (signal TSTP)&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; q&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Rescan the ttys(5) file (signal HUP)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Windows&lt;br /&gt;
&lt;br /&gt;
Start and stop a service with either the service name or "service description" (shown in the Services Control Panel) as follows:&lt;br /&gt;
&lt;br /&gt;
net stop WSearch&lt;br /&gt;
net start WSearch&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # start search service&lt;br /&gt;
net stop "Windows Search"&lt;br /&gt;
net start "Windows Search"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # same as above using descr.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Reset root password&lt;br /&gt;
&lt;br /&gt;
Linux method 1&lt;br /&gt;
&lt;br /&gt;
At the boot loader (lilo or grub), enter the following boot option:&lt;br /&gt;
&lt;br /&gt;
init=/bin/sh&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The kernel will mount the root partition and init will start the bourne shell&lt;br /&gt;
instead of rc and then a runlevel. Use the command passwd at the prompt to change the password and then reboot. Forget the single user mode as you need the password for that.&lt;br /&gt;
&lt;br /&gt;
If, after booting, the root partition is mounted read only, remount it rw:&lt;br /&gt;
&lt;br /&gt;
# mount -o remount,rw /&lt;br /&gt;
# passwd&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # or delete the root password (/etc/shadow)&lt;br /&gt;
# sync; mount -o remount,ro /&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # sync before to remount read only&lt;br /&gt;
# reboot&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
FreeBSD method 1&lt;br /&gt;
&lt;br /&gt;
On FreeBSD, boot in single user mode, remount / rw and use passwd. You can select the single user mode on the boot menu (option 4) which is displayed for 10 seconds at startup. The single user mode will give you a root shell on the / partition.&lt;br /&gt;
&lt;br /&gt;
# mount -u /; mount -a&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # will mount / rw&lt;br /&gt;
# passwd&lt;br /&gt;
# reboot&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Unixes and FreeBSD and Linux method 2&lt;br /&gt;
&lt;br /&gt;
Other Unixes might not let you go away with the simple init trick. The solution is to mount the root partition from an other OS (like a rescue CD) and change the password on the disk.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; Boot a live CD or installation CD into a rescue mode which will give you a shell.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; Find the root partition with fdisk e.g. fdisk /dev/sda&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; Mount it and use chroot:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# mount -o rw /dev/ad4s3a /mnt&lt;br /&gt;
# chroot /mnt&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # chroot into /mnt&lt;br /&gt;
# passwd&lt;br /&gt;
# reboot&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Kernel modules&lt;br /&gt;
&lt;br /&gt;
Linux&lt;br /&gt;
&lt;br /&gt;
# lsmod&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # List all modules loaded in the kernel&lt;br /&gt;
# modprobe isdn&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # To load a module (here isdn)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
FreeBSD&lt;br /&gt;
&lt;br /&gt;
# kldstat&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # List all modules loaded in the kernel&lt;br /&gt;
# kldload crypto&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # To load a module (here crypto)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Compile Kernel&lt;br /&gt;
&lt;br /&gt;
Linux&lt;br /&gt;
&lt;br /&gt;
# cd /usr/src/linux&lt;br /&gt;
# make mrproper&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Clean everything, including config files&lt;br /&gt;
# make oldconfig&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Reuse the old .config if existent&lt;br /&gt;
# make menuconfig&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # or xconfig (Qt) or gconfig (GTK)&lt;br /&gt;
# make&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Create a compressed kernel image&lt;br /&gt;
# make modules&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Compile the modules&lt;br /&gt;
# make modules_install&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Install the modules&lt;br /&gt;
# make install&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Install the kernel&lt;br /&gt;
# reboot&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
FreeBSD&lt;br /&gt;
&lt;br /&gt;
Optionally update the source tree (in /usr/src) with csup (as of FreeBSD 6.2 or later):&lt;br /&gt;
&lt;br /&gt;
# csup &amp;lt;supfile&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I use the following supfile:&lt;br /&gt;
&lt;br /&gt;
*default host=cvsup5.FreeBSD.org&amp;nbsp; # www.freebsd.org/handbook/cvsup.html#CVSUP-MIRRORS&lt;br /&gt;
*default prefix=/usr &lt;br /&gt;
*default base=/var/db&lt;br /&gt;
*default release=cvs delete tag=RELENG_7&lt;br /&gt;
src-all&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To modify and rebuild the kernel, copy the generic configuration file to a new name and edit it as needed (you can also edit the file GENERIC directly). To restart the build after an interruption, add the option NO_CLEAN=YES to the make command to avoid cleaning the objects already build.&lt;br /&gt;
&lt;br /&gt;
# cd /usr/src/sys/i386/conf/&lt;br /&gt;
# cp GENERIC MYKERNEL&lt;br /&gt;
# cd /usr/src&lt;br /&gt;
# make buildkernel KERNCONF=MYKERNEL&lt;br /&gt;
# make installkernel KERNCONF=MYKERNEL&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To rebuild the full OS:&lt;br /&gt;
&lt;br /&gt;
# make buildworld&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Build the full OS but not the kernel&lt;br /&gt;
# make buildkernel&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Use KERNCONF as above if appropriate&lt;br /&gt;
# make installkernel&lt;br /&gt;
# reboot&lt;br /&gt;
# mergemaster -p&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Compares only files known to be essential&lt;br /&gt;
# make installworld&lt;br /&gt;
# mergemaster -i -U&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Update all configurations and other files&lt;br /&gt;
# reboot&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For small changes in the source you can use NO_CLEAN=yes to avoid rebuilding the whole tree.&lt;br /&gt;
&lt;br /&gt;
# make buildworld NO_CLEAN=yes&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Don't delete the old objects&lt;br /&gt;
# make buildkernel KERNCONF=MYKERNEL NO_CLEAN=yes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Repair grub&lt;br /&gt;
&lt;br /&gt;
So you broke grub? Boot from a live cd, [find your linux partition under /dev and use fdisk to find the linux partion] mount the linux partition, add /proc and /dev and use grub-install /dev/xyz. Suppose linux lies on /dev/sda6:&lt;br /&gt;
&lt;br /&gt;
# mount /dev/sda6 /mnt&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # mount the linux partition on /mnt&lt;br /&gt;
# mount --bind /proc /mnt/proc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # mount the proc subsystem into /mnt&lt;br /&gt;
# mount --bind /dev /mnt/dev&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # mount the devices into /mnt&lt;br /&gt;
# chroot /mnt&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # change root to the linux partition&lt;br /&gt;
# grub-install /dev/sda&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # reinstall grub with your old settings&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Processes&lt;br /&gt;
&lt;br /&gt;
Listing | Priority | Background/Foreground | Top | Kill&lt;br /&gt;
&lt;br /&gt;
Listing and PIDs&lt;br /&gt;
&lt;br /&gt;
Each process has a unique number, the PID. A list of all running process is retrieved with ps.&lt;br /&gt;
&lt;br /&gt;
# ps -auxefw&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Extensive list of all running process&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
However more typical usage is with a pipe or with pgrep (for OS X install proctools from MacPorts):&lt;br /&gt;
&lt;br /&gt;
# ps axww | grep cron&lt;br /&gt;
&amp;nbsp; 586&amp;nbsp; ??&amp;nbsp; Is&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0:01.48 /usr/sbin/cron -s&lt;br /&gt;
# ps axjf&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # All processes in a tree format (Linux)&lt;br /&gt;
# ps aux | grep 'ss[h]'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Find all ssh pids without the grep pid&lt;br /&gt;
# pgrep -l sshd&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Find the PIDs of processes by (part of) name&lt;br /&gt;
# echo $$&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # The PID of your shell&lt;br /&gt;
# fuser -va 22/tcp&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # List processes using port 22 (Linux)&lt;br /&gt;
# pmap PID&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Memory map of process (hunt memory leaks) (Linux)&lt;br /&gt;
# fuser -va /home&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # List processes accessing the /home partition&lt;br /&gt;
# strace df&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Trace system calls and signals&lt;br /&gt;
# truss df&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # same as above on FreeBSD/Solaris/Unixware&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Priority&lt;br /&gt;
&lt;br /&gt;
Change the priority of a running process with renice. Negative numbers have a higher priority, the lowest is -20 and "nice" have a positive value.&lt;br /&gt;
&lt;br /&gt;
# renice -5 586&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Stronger priority&lt;br /&gt;
586: old priority 0, new priority -5&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Start the process with a defined priority with nice. Positive is "nice" or weak, negative is strong scheduling priority. Make sure you know if /usr/bin/nice or the shell built-in is used (check with # which nice).&lt;br /&gt;
&lt;br /&gt;
# nice -n -5 top&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Stronger priority (/usr/bin/nice)&lt;br /&gt;
# nice -n 5 top&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Weaker priority (/usr/bin/nice)&lt;br /&gt;
# nice +5 top&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # tcsh builtin nice (same as above!)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
While nice changes the CPU scheduler, an other useful command ionice will schedule the disk IO. This is very useful for intensive IO application (e.g. compiling). You can select a class (idle - best effort - real time), the man page is short and well explained.&lt;br /&gt;
&lt;br /&gt;
# ionice c3 -p123&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # set idle class for pid 123 (Linux only)&lt;br /&gt;
# ionice -c2 -n0 firefox&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Run firefox with best effort and high priority&lt;br /&gt;
# ionice -c3 -p$$&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Set the actual shell to idle priority&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The last command is very useful to compile (or debug) a large project. Every command launched from this shell will have a lover priority. $$ is your shell pid (try echo $$).&lt;br /&gt;
&lt;br /&gt;
FreeBSD uses idprio/rtprio (0 = max priority, 31 = most idle):&lt;br /&gt;
&lt;br /&gt;
# idprio 31 make&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # compile in the lowest priority&lt;br /&gt;
# idprio 31 -1234&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # set PID 1234 with lowest priority&lt;br /&gt;
# idprio -t -1234&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # -t removes any real time/idle priority&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Background/Foreground&lt;br /&gt;
&lt;br /&gt;
When started from a shell, processes can be brought in the background and back to the foreground with [Ctrl]-[Z] (^Z), bg and fg. List the processes with jobs.&lt;br /&gt;
&lt;br /&gt;
# ping cb.vu &amp;gt; ping.log&lt;br /&gt;
^Z&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # ping is suspended (stopped) with [Ctrl]-[Z] &lt;br /&gt;
# bg&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # put in background and continues running&lt;br /&gt;
# jobs -l&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # List processes in background&lt;br /&gt;
[1]&amp;nbsp; - 36232 Running&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ping cb.vu &amp;gt; ping.log&lt;br /&gt;
[2]&amp;nbsp; + 36233 Suspended (tty output)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; top&lt;br /&gt;
# fg %2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Bring process 2 back in foreground&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Use nohup to start a process which has to keep running when the shell is closed (immune to hangups).&lt;br /&gt;
&lt;br /&gt;
# nohup ping -i 60 &amp;gt; ping.log &amp;amp;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Top&lt;br /&gt;
&lt;br /&gt;
The program top displays running information of processes. See also the program htop from htop.sourceforge.net (a more powerful version of top) which runs on Linux and FreeBSD (ports/sysutils/htop/). While top is running press the key h for a help overview. Useful keys are:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; u [user name] To display only the processes belonging to the user. Use + or blank to see all users&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; k [pid] Kill the process with pid.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; 1 To display all processors statistics (Linux only)&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp;&amp;nbsp; R Toggle normal/reverse sort.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Signals/Kill&lt;br /&gt;
&lt;br /&gt;
Terminate or send a signal with kill or killall.&lt;br /&gt;
&lt;br /&gt;
# ping -i 60 cb.vu &amp;gt; ping.log &amp;amp;&lt;br /&gt;
[1] 4712&lt;br /&gt;
# kill -s TERM 4712&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # same as kill -15 4712&lt;br /&gt;
# killall -1 httpd&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Kill HUP processes by exact name&lt;br /&gt;
# pkill -9 http&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Kill TERM processes by (part of) name&lt;br /&gt;
# pkill -TERM -u www&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Kill TERM processes owned by www&lt;br /&gt;
# fuser -k -TERM -m /home&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Kill every process accessing /home (to umount)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Important signals are:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; HUP (hang up)&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; INT (interrupt)&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; 3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; QUIT (quit)&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; 9&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; KILL (non-catchable, non-ignorable kill)&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; 15&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TERM (software termination signal)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
File System&lt;br /&gt;
&lt;br /&gt;
Disk info | Boot | Disk usage | Opened files | Mount/remount | Mount SMB | Mount image | Burn ISO | Create image | Memory disk | Disk performance&lt;br /&gt;
&lt;br /&gt;
Permissions&lt;br /&gt;
&lt;br /&gt;
Change permission and ownership with chmod and chown. The default umask can be changed for all users in /etc/profile for Linux or /etc/login.conf for FreeBSD. The default umask is usually 022. The umask is subtracted from 777, thus umask 022 results in a permission 0f 755.&lt;br /&gt;
&lt;br /&gt;
1 --x execute&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Mode 764 = exec/read/write | read/write | read&lt;br /&gt;
2 -w- write&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # For:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |--&amp;nbsp; Owner&amp;nbsp; --|&amp;nbsp;&amp;nbsp; |- Group-|&amp;nbsp;&amp;nbsp; |Oth|&lt;br /&gt;
4 r-- read&lt;br /&gt;
&amp;nbsp; ugo=a&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; u=user, g=group, o=others, a=everyone&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# chmod [OPTION] MODE[,MODE] FILE&amp;nbsp;&amp;nbsp;&amp;nbsp; # MODE is of the form [ugoa]*([-+=]([rwxXst]))&lt;br /&gt;
# chmod 640 /var/log/maillog&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Restrict the log -rw-r-----&lt;br /&gt;
# chmod u=rw,g=r,o= /var/log/maillog # Same as above&lt;br /&gt;
# chmod -R o-r /home/*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Recursive remove other readable for all users&lt;br /&gt;
# chmod u+s /path/to/prog&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Set SUID bit on executable (know what you do!)&lt;br /&gt;
# find / -perm -u+s -print&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Find all programs with the SUID bit&lt;br /&gt;
# chown user:group /path/to/file&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Change the user and group ownership of a file&lt;br /&gt;
# chgrp group /path/to/file&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Change the group ownership of a file&lt;br /&gt;
# chmod 640 `find ./ -type f -print` # Change permissions to 640 for all files&lt;br /&gt;
# chmod 751 `find ./ -type d -print` # Change permissions to 751 for all directories&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Disk information&lt;br /&gt;
&lt;br /&gt;
# diskinfo -v /dev/ad2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # information about disk (sector/size) FreeBSD&lt;br /&gt;
# hdparm -I /dev/sda&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # information about the IDE/ATA disk (Linux)&lt;br /&gt;
# fdisk /dev/ad2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Display and manipulate the partition table&lt;br /&gt;
# smartctl -a /dev/ad2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Display the disk SMART info&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Boot&lt;br /&gt;
&lt;br /&gt;
FreeBSD&lt;br /&gt;
&lt;br /&gt;
To boot an old kernel if the new kernel doesn't boot, stop the boot at during the count down.&lt;br /&gt;
&lt;br /&gt;
# unload&lt;br /&gt;
# load kernel.old&lt;br /&gt;
# boot&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
System mount points/Disk usage&lt;br /&gt;
&lt;br /&gt;
# mount | column -t&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Show mounted file-systems on the system&lt;br /&gt;
# df&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # display free disk space and mounted devices&lt;br /&gt;
# cat /proc/partitions&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Show all registered partitions (Linux)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Disk usage&lt;br /&gt;
&lt;br /&gt;
# du -sh *&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Directory sizes as listing&lt;br /&gt;
# du -csh&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Total directory size of the current directory&lt;br /&gt;
# du -ks * | sort -n -r&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Sort everything by size in kilobytes&lt;br /&gt;
# ls -lSr&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Show files, biggest last&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Who has which files opened&lt;br /&gt;
&lt;br /&gt;
This is useful to find out which file is blocking a partition which has to be unmounted and gives a typical error of:&lt;br /&gt;
&lt;br /&gt;
# umount /home/&lt;br /&gt;
umount: unmount of /home&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # umount impossible because a file is locking home&lt;br /&gt;
&amp;nbsp;&amp;nbsp; failed: Device busy&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
FreeBSD and most Unixes&lt;br /&gt;
&lt;br /&gt;
# fstat -f /home&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # for a mount point&lt;br /&gt;
# fstat -p PID&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # for an application with PID&lt;br /&gt;
# fstat -u user&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # for a user name&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Find opened log file (or other opened files), say for Xorg:&lt;br /&gt;
&lt;br /&gt;
# ps ax | grep Xorg | awk '{print $1}'&lt;br /&gt;
1252&lt;br /&gt;
# fstat -p 1252&lt;br /&gt;
USER&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CMD&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PID&amp;nbsp;&amp;nbsp; FD MOUNT&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; INUM MODE&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SZ|DV R/W&lt;br /&gt;
root&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Xorg&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1252 root /&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2 drwxr-xr-x&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 512&amp;nbsp; r&lt;br /&gt;
root&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Xorg&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1252 text /usr&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 216016 -rws--x--x&amp;nbsp; 1679848 r&lt;br /&gt;
root&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Xorg&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1252&amp;nbsp;&amp;nbsp;&amp;nbsp; 0 /var&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 212042 -rw-r--r--&amp;nbsp;&amp;nbsp; 56987&amp;nbsp; w&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The file with inum 212042 is the only file in /var:&lt;br /&gt;
&lt;br /&gt;
# find -x /var -inum 212042&lt;br /&gt;
/var/log/Xorg.0.log&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Linux&lt;br /&gt;
&lt;br /&gt;
Find opened files on a mount point with fuser or lsof:&lt;br /&gt;
&lt;br /&gt;
# fuser -m /home&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # List processes accessing /home&lt;br /&gt;
# lsof /home&lt;br /&gt;
COMMAND&amp;nbsp;&amp;nbsp; PID&amp;nbsp;&amp;nbsp;&amp;nbsp; USER&amp;nbsp;&amp;nbsp; FD&amp;nbsp;&amp;nbsp; TYPE DEVICE&amp;nbsp;&amp;nbsp;&amp;nbsp; SIZE&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NODE NAME&lt;br /&gt;
tcsh&amp;nbsp;&amp;nbsp;&amp;nbsp; 29029 eedcoba&amp;nbsp; cwd&amp;nbsp;&amp;nbsp;&amp;nbsp; DIR&amp;nbsp;&amp;nbsp; 0,18&amp;nbsp;&amp;nbsp; 12288&amp;nbsp; 1048587 /home/eedcoba (guam:/home)&lt;br /&gt;
lsof&amp;nbsp;&amp;nbsp;&amp;nbsp; 29140 eedcoba&amp;nbsp; cwd&amp;nbsp;&amp;nbsp;&amp;nbsp; DIR&amp;nbsp;&amp;nbsp; 0,18&amp;nbsp;&amp;nbsp; 12288&amp;nbsp; 1048587 /home/eedcoba (guam:/home)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
About an application:&lt;br /&gt;
&lt;br /&gt;
ps ax | grep Xorg | awk '{print $1}'&lt;br /&gt;
3324&lt;br /&gt;
# lsof -p 3324&lt;br /&gt;
COMMAND&amp;nbsp;&amp;nbsp; PID&amp;nbsp;&amp;nbsp;&amp;nbsp; USER&amp;nbsp;&amp;nbsp; FD&amp;nbsp;&amp;nbsp; TYPE DEVICE&amp;nbsp;&amp;nbsp;&amp;nbsp; SIZE&amp;nbsp;&amp;nbsp;&amp;nbsp; NODE NAME&lt;br /&gt;
Xorg&amp;nbsp;&amp;nbsp;&amp;nbsp; 3324 root&amp;nbsp;&amp;nbsp;&amp;nbsp; 0w&amp;nbsp;&amp;nbsp; REG&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8,6&amp;nbsp;&amp;nbsp; 56296&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 12492 /var/log/Xorg.0.log&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
About a single file:&lt;br /&gt;
&lt;br /&gt;
# lsof /var/log/Xorg.0.log&lt;br /&gt;
COMMAND&amp;nbsp; PID USER&amp;nbsp;&amp;nbsp; FD&amp;nbsp;&amp;nbsp; TYPE DEVICE&amp;nbsp; SIZE&amp;nbsp; NODE NAME&lt;br /&gt;
Xorg&amp;nbsp;&amp;nbsp;&amp;nbsp; 3324 root&amp;nbsp;&amp;nbsp;&amp;nbsp; 0w&amp;nbsp;&amp;nbsp; REG&amp;nbsp;&amp;nbsp;&amp;nbsp; 8,6 56296 12492 /var/log/Xorg.0.log&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Mount/remount a file system&lt;br /&gt;
&lt;br /&gt;
For example the cdrom. If listed in /etc/fstab:&lt;br /&gt;
&lt;br /&gt;
# mount /cdrom&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Or find the device in /dev/ or with dmesg&lt;br /&gt;
FreeBSD&lt;br /&gt;
&lt;br /&gt;
# mount -v -t cd9660 /dev/cd0c /mnt&amp;nbsp; # cdrom&lt;br /&gt;
# mount_cd9660 /dev/wcd0c /cdrom&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # other method&lt;br /&gt;
# mount -v -t msdos /dev/fd0c /mnt&amp;nbsp;&amp;nbsp; # floppy&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Entry in /etc/fstab:&lt;br /&gt;
&lt;br /&gt;
# Device&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Mountpoint&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FStype&amp;nbsp; Options&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dump&amp;nbsp;&amp;nbsp;&amp;nbsp; Pass#&lt;br /&gt;
/dev/acd0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /cdrom&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cd9660&amp;nbsp; ro,noauto&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To let users do it:&lt;br /&gt;
&lt;br /&gt;
# sysctl vfs.usermount=1&amp;nbsp; # Or insert the line "vfs.usermount=1" in /etc/sysctl.conf&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Linux&lt;br /&gt;
&lt;br /&gt;
# mount -t auto /dev/cdrom /mnt/cdrom&amp;nbsp;&amp;nbsp; # typical cdrom mount command&lt;br /&gt;
# mount /dev/hdc -t iso9660 -r /cdrom&amp;nbsp;&amp;nbsp; # typical IDE&lt;br /&gt;
# mount /dev/scd0 -t iso9660 -r /cdrom&amp;nbsp; # typical SCSI cdrom&lt;br /&gt;
# mount /dev/sdc0 -t ntfs-3g /windows&amp;nbsp;&amp;nbsp; # typical SCSI&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Entry in /etc/fstab:&lt;br /&gt;
&lt;br /&gt;
/dev/cdrom&amp;nbsp;&amp;nbsp; /media/cdrom&amp;nbsp; subfs noauto,fs=cdfss,ro,procuid,nosuid,nodev,exec 0 0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Mount a FreeBSD partition with Linux&lt;br /&gt;
&lt;br /&gt;
Find the partition number containing with fdisk, this is usually the root partition, but it could be an other BSD slice too. If the FreeBSD has many slices, they are the one not listed in the fdisk table, but visible in /dev/sda* or /dev/hda*.&lt;br /&gt;
&lt;br /&gt;
# fdisk /dev/sda&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Find the FreeBSD partition&lt;br /&gt;
/dev/sda3&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5357&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7905&amp;nbsp;&amp;nbsp;&amp;nbsp; 20474842+&amp;nbsp; a5&amp;nbsp; FreeBSD&lt;br /&gt;
# mount -t ufs -o ufstype=ufs2,ro /dev/sda3 /mnt&lt;br /&gt;
/dev/sda10 = /tmp; /dev/sda11 /usr&amp;nbsp;&amp;nbsp; # The other slices&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Remount&lt;br /&gt;
&lt;br /&gt;
Remount a device without unmounting it. Necessary for fsck for example&lt;br /&gt;
&lt;br /&gt;
# mount -o remount,ro /&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Linux&lt;br /&gt;
# mount -o ro /&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # FreeBSD&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Copy the raw data from a cdrom into an iso image:&lt;br /&gt;
&lt;br /&gt;
# dd if=/dev/cd0c of=file.iso&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Add swap on-the-fly&lt;br /&gt;
&lt;br /&gt;
Suppose you need more swap (right now), say a 2GB file /swap2gb (Linux only).&lt;br /&gt;
&lt;br /&gt;
# dd if=/dev/zero of=/swap2gb bs=1024k count=2000&lt;br /&gt;
# mkswap /swap2gb&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # create the swap area&lt;br /&gt;
# swapon /swap2gb&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # activate the swap. It now in use&lt;br /&gt;
# swapoff /swap2gb&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # when done deactivate the swap&lt;br /&gt;
# rm /swap2gb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Mount an SMB share&lt;br /&gt;
&lt;br /&gt;
Suppose we want to access the SMB share myshare on the computer smbserver, the address as typed on a Windows PC is \\smbserver\myshare\. We mount on /mnt/smbshare. Warning&amp;gt; cifs wants an IP or DNS name, not a Windows name.&lt;br /&gt;
Linux&lt;br /&gt;
&lt;br /&gt;
# smbclient -U user -I 192.168.16.229 -L //smbshare/&amp;nbsp;&amp;nbsp;&amp;nbsp; # List the shares&lt;br /&gt;
# mount -t smbfs -o username=winuser //smbserver/myshare /mnt/smbshare&lt;br /&gt;
# mount -t cifs -o username=winuser,password=winpwd //192.168.16.229/myshare /mnt/share&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Additionally with the package mount.cifs it is possible to store the credentials in a file, for example /home/user/.smb:&lt;br /&gt;
&lt;br /&gt;
username=winuser&lt;br /&gt;
password=winpwd&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
And mount as follow:&lt;br /&gt;
&lt;br /&gt;
# mount -t cifs -o credentials=/home/user/.smb //192.168.16.229/myshare /mnt/smbshare&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
FreeBSD&lt;br /&gt;
&lt;br /&gt;
Use -I to give the IP (or DNS name); smbserver is the Windows name.&lt;br /&gt;
&lt;br /&gt;
# smbutil view -I 192.168.16.229 //winuser@smbserver&amp;nbsp;&amp;nbsp;&amp;nbsp; # List the shares&lt;br /&gt;
# mount_smbfs -I 192.168.16.229 //winuser@smbserver/myshare /mnt/smbshare&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Mount an image&lt;br /&gt;
&lt;br /&gt;
# hdiutil mount image.iso&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # OS X&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Linux loop-back&lt;br /&gt;
&lt;br /&gt;
# mount -t iso9660 -o loop file.iso /mnt&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Mount a CD image&lt;br /&gt;
# mount -t ext3 -o loop file.img /mnt&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Mount an image with ext3 fs&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
FreeBSD&lt;br /&gt;
&lt;br /&gt;
With memory device (do # kldload md.ko if necessary):&lt;br /&gt;
&lt;br /&gt;
# mdconfig -a -t vnode -f file.iso -u 0&lt;br /&gt;
# mount -t cd9660 /dev/md0 /mnt&lt;br /&gt;
# umount /mnt; mdconfig -d -u 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Cleanup the md device&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Or with virtual node:&lt;br /&gt;
&lt;br /&gt;
# vnconfig /dev/vn0c file.iso; mount -t cd9660 /dev/vn0c /mnt&lt;br /&gt;
# umount /mnt; vnconfig -u /dev/vn0c&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Cleanup the vn device&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Solaris and FreeBSD&lt;br /&gt;
&lt;br /&gt;
with loop-back file interface or lofi:&lt;br /&gt;
&lt;br /&gt;
# lofiadm -a file.iso&lt;br /&gt;
# mount -F hsfs -o ro /dev/lofi/1 /mnt&lt;br /&gt;
# umount /mnt; lofiadm -d /dev/lofi/1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Cleanup the lofi device&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Create and burn an ISO image&lt;br /&gt;
&lt;br /&gt;
This will copy the cd or DVD sector for sector. Without conv=notrunc, the image will be smaller if there is less content on the cd. See below and the dd examples.&lt;br /&gt;
&lt;br /&gt;
# dd if=/dev/hdc of=/tmp/mycd.iso bs=2048 conv=notrunc&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Use mkisofs to create a CD/DVD image from files in a directory. To overcome the file names restrictions: -r enables the Rock Ridge extensions common to UNIX systems, -J enables Joliet extensions used by Microsoft systems. -L allows ISO9660 filenames to begin with a period.&lt;br /&gt;
&lt;br /&gt;
# mkisofs -J -L -r -V TITLE -o imagefile.iso /path/to/dir&lt;br /&gt;
# hdiutil makehybrid -iso -joliet -o dir.iso dir/&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # OS X&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On FreeBSD, mkisofs is found in the ports in sysutils/cdrtools.&lt;br /&gt;
Burn a CD/DVD ISO image&lt;br /&gt;
&lt;br /&gt;
FreeBSD&lt;br /&gt;
&lt;br /&gt;
FreeBSD does not enable DMA on ATAPI drives by default. DMA is enabled with the sysctl command and the arguments below, or with /boot/loader.conf with the following entries:&lt;br /&gt;
&lt;br /&gt;
hw.ata.ata_dma="1"&lt;br /&gt;
hw.ata.atapi_dma="1"&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Use burncd with an ATAPI device (burncd is part of the base system) and cdrecord (in sysutils/cdrtools) with a SCSI drive.&lt;br /&gt;
&lt;br /&gt;
# burncd -f /dev/acd0 data imagefile.iso fixate&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # For ATAPI drive&lt;br /&gt;
# cdrecord -scanbus&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # To find the burner device (like 1,0,0)&lt;br /&gt;
# cdrecord dev=1,0,0 imagefile.iso&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Linux&lt;br /&gt;
&lt;br /&gt;
Also use cdrecord with Linux as described above. Additionally it is possible to use the native ATAPI interface which is found with:&lt;br /&gt;
&lt;br /&gt;
# cdrecord dev=ATAPI -scanbus&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
And burn the CD/DVD as above.&lt;br /&gt;
dvd+rw-tools&lt;br /&gt;
&lt;br /&gt;
The dvd+rw-tools package (FreeBSD: ports/sysutils/dvd+rw-tools) can do it all and includes growisofs to burn CDs or DVDs. The examples refer to the dvd device as /dev/dvd which could be a symlink to /dev/scd0 (typical scsi on Linux) or /dev/cd0 (typical FreeBSD) or /dev/rcd0c (typical NetBSD/OpenBSD character SCSI) or /dev/rdsk/c0t1d0s2 (Solaris example of a character SCSI/ATAPI CD-ROM device). There is a nice documentation with examples on the FreeBSD handbook chapter 18.7http://www.freebsd.org/handbook/creating-dvds.html.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # -dvd-compat closes the disk&lt;br /&gt;
# growisofs -dvd-compat -Z /dev/dvd=imagefile.iso&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Burn existing iso image&lt;br /&gt;
# growisofs -dvd-compat -Z /dev/dvd -J -R /p/to/data&amp;nbsp; # Burn directly&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Convert a Nero .nrg file to .iso&lt;br /&gt;
&lt;br /&gt;
Nero simply adds a 300Kb header to a normal iso image. This can be trimmed with dd.&lt;br /&gt;
&lt;br /&gt;
# dd bs=1k if=imagefile.nrg of=imagefile.iso skip=300&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Convert a bin/cue image to .iso&lt;br /&gt;
&lt;br /&gt;
The little bchunk programhttp://freshmeat.net/projects/bchunk/ can do this. It is in the FreeBSD ports in sysutils/bchunk.&lt;br /&gt;
&lt;br /&gt;
# bchunk imagefile.bin imagefile.cue imagefile.iso&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Create a file based image&lt;br /&gt;
&lt;br /&gt;
For example a partition of 1GB using the file /usr/vdisk.img. Here we use the vnode 0, but it could also be 1.&lt;br /&gt;
FreeBSD&lt;br /&gt;
&lt;br /&gt;
# dd if=/dev/random of=/usr/vdisk.img bs=1K count=1M&lt;br /&gt;
# mdconfig -a -t vnode -f /usr/vdisk.img -u 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Creates device /dev/md1&lt;br /&gt;
# bsdlabel -w /dev/md0&lt;br /&gt;
# newfs /dev/md0c&lt;br /&gt;
# mount /dev/md0c /mnt&lt;br /&gt;
# umount /mnt; mdconfig -d -u 0; rm /usr/vdisk.img&amp;nbsp;&amp;nbsp;&amp;nbsp; # Cleanup the md device&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The file based image can be automatically mounted during boot with an entry in /etc/rc.conf and /etc/fstab. Test your setup with # /etc/rc.d/mdconfig start (first delete the md0 device with # mdconfig -d -u 0).&lt;br /&gt;
&lt;br /&gt;
Note however that this automatic setup will only work if the file image is NOT on the root partition. The reason is that the /etc/rc.d/mdconfig script is executed very early during boot and the root partition is still read-only. Images located outside the root partition will be mounted later with the script /etc/rc.d/mdconfig2.&lt;br /&gt;
&lt;br /&gt;
/boot/loader.conf:&lt;br /&gt;
&lt;br /&gt;
md_load="YES"&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/etc/rc.conf:&lt;br /&gt;
&lt;br /&gt;
# mdconfig_md0="-t vnode -f /usr/vdisk.img"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # /usr is not on the root partition&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/etc/fstab: (The 0 0 at the end is important, it tell fsck to ignore this device, as is does not exist yet)&lt;br /&gt;
&lt;br /&gt;
/dev/md0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /usr/vdisk&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ufs&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rw&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It is also possible to increase the size of the image afterward, say for example 300 MB larger.&lt;br /&gt;
&lt;br /&gt;
# umount /mnt; mdconfig -d -u 0&lt;br /&gt;
# dd if=/dev/zero bs=1m count=300 &amp;gt;&amp;gt; /usr/vdisk.img&lt;br /&gt;
# mdconfig -a -t vnode -f /usr/vdisk.img -u 0&lt;br /&gt;
# growfs /dev/md0&lt;br /&gt;
# mount /dev/md0c /mnt&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # File partition is now 300 MB larger&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Linux&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# dd if=/dev/zero of=/usr/vdisk.img bs=1024k count=1024&lt;br /&gt;
# mkfs.ext3 /usr/vdisk.img&lt;br /&gt;
# mount -o loop /usr/vdisk.img /mnt&lt;br /&gt;
# umount /mnt; rm /usr/vdisk.img&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Cleanup&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Linux with losetup&lt;br /&gt;
&lt;br /&gt;
/dev/zero is much faster than urandom, but less secure for encryption.&lt;br /&gt;
&lt;br /&gt;
# dd if=/dev/urandom of=/usr/vdisk.img bs=1024k count=1024&lt;br /&gt;
# losetup /dev/loop0 /usr/vdisk.img&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Creates and associates /dev/loop0&lt;br /&gt;
# mkfs.ext3 /dev/loop0&lt;br /&gt;
# mount /dev/loop0 /mnt&lt;br /&gt;
# losetup -a&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Check used loops&lt;br /&gt;
# umount /mnt&lt;br /&gt;
# losetup -d /dev/loop0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Detach&lt;br /&gt;
# rm /usr/vdisk.img&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Create a memory file system&lt;br /&gt;
&lt;br /&gt;
A memory based file system is very fast for heavy IO application. How to create a 64 MB partition mounted on /memdisk:&lt;br /&gt;
FreeBSD&lt;br /&gt;
&lt;br /&gt;
# mount_mfs -o rw -s 64M md /memdisk&lt;br /&gt;
# umount /memdisk; mdconfig -d -u 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Cleanup the md device&lt;br /&gt;
md&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /memdisk&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mfs&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rw,-s64M&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # /etc/fstab entry&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Linux&lt;br /&gt;
&lt;br /&gt;
# mount -t tmpfs -osize=64m tmpfs /memdisk&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Disk performance&lt;br /&gt;
&lt;br /&gt;
Read and write a 1 GB file on partition ad4s3c (/home)&lt;br /&gt;
&lt;br /&gt;
# time dd if=/dev/ad4s3c of=/dev/null bs=1024k count=1000&lt;br /&gt;
# time dd if=/dev/zero bs=1024k count=1000 of=/home/1Gb.file&lt;br /&gt;
# hdparm -tT /dev/hda&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Linux only&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Network&lt;br /&gt;
&lt;br /&gt;
Routing | Additional IP | Change MAC | Ports | Firewall | IP Forward | NAT | DNS | DHCP | Traffic | QoS | NIS | Netcat&lt;br /&gt;
&lt;br /&gt;
Debugging (See also Traffic analysis)&lt;br /&gt;
&lt;br /&gt;
Linux&lt;br /&gt;
&lt;br /&gt;
# ethtool eth0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Show the ethernet status (replaces mii-diag)&lt;br /&gt;
# ethtool -s eth0 speed 100 duplex full # Force 100Mbit Full duplex&lt;br /&gt;
# ethtool -s eth0 autoneg off # Disable auto negotiation&lt;br /&gt;
# ethtool -p eth1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Blink the ethernet led - very useful when supported&lt;br /&gt;
# ip link show&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Display all interfaces on Linux (similar to ifconfig)&lt;br /&gt;
# ip link set eth0 up&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Bring device up (or down). Same as "ifconfig eth0 up"&lt;br /&gt;
# ip addr show&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Display all IP addresses on Linux (similar to ifconfig)&lt;br /&gt;
# ip neigh show&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Similar to arp -a&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Other OSes&lt;br /&gt;
&lt;br /&gt;
# ifconfig fxp0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Check the "media" field on FreeBSD&lt;br /&gt;
# arp -a&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Check the router (or host) ARP entry (all OS)&lt;br /&gt;
# ping cb.vu&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # The first thing to try...&lt;br /&gt;
# traceroute cb.vu&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Print the route path to destination&lt;br /&gt;
# ifconfig fxp0 media 100baseTX mediaopt full-duplex # 100Mbit full duplex (FreeBSD)&lt;br /&gt;
# netstat -s&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # System-wide statistics for each network protocol&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Additional commands which are not always installed per default but easy to find:&lt;br /&gt;
&lt;br /&gt;
# arping 192.168.16.254&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Ping on ethernet layer&lt;br /&gt;
# tcptraceroute -f 5 cb.vu&amp;nbsp; # uses tcp instead of icmp to trace through firewalls&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Routing&lt;br /&gt;
&lt;br /&gt;
Print routing table&lt;br /&gt;
&lt;br /&gt;
# route -n&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Linux or use "ip route"&lt;br /&gt;
# netstat -rn&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Linux, BSD and UNIX&lt;br /&gt;
# route print&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Windows&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Add and delete a route&lt;br /&gt;
&lt;br /&gt;
FreeBSD&lt;br /&gt;
&lt;br /&gt;
# route add 212.117.0.0/16 192.168.1.1&lt;br /&gt;
# route delete 212.117.0.0/16&lt;br /&gt;
# route add default 192.168.1.1&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Add the route permanently in /etc/rc.conf&lt;br /&gt;
&lt;br /&gt;
static_routes="myroute"&lt;br /&gt;
route_myroute="-net 212.117.0.0/16 192.168.1.1"&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Linux&lt;br /&gt;
&lt;br /&gt;
# route add -net 192.168.20.0 netmask 255.255.255.0 gw 192.168.16.254&lt;br /&gt;
# ip route add 192.168.20.0/24 via 192.168.16.254&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # same as above with ip route&lt;br /&gt;
# route add -net 192.168.20.0 netmask 255.255.255.0 dev eth0&lt;br /&gt;
# route add default gw 192.168.51.254&lt;br /&gt;
# ip route add default via 192.168.51.254 dev eth0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # same as above with ip route&lt;br /&gt;
# route delete -net 192.168.20.0 netmask 255.255.255.0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Solaris&lt;br /&gt;
&lt;br /&gt;
# route add -net 192.168.20.0 -netmask 255.255.255.0 192.168.16.254&lt;br /&gt;
# route add default 192.168.51.254 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # 1 = hops to the next gateway&lt;br /&gt;
# route change default 192.168.50.254 1&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Permanent entries are set in entry in /etc/defaultrouter.&lt;br /&gt;
Windows&lt;br /&gt;
&lt;br /&gt;
# Route add 192.168.50.0 mask 255.255.255.0 192.168.51.253&lt;br /&gt;
# Route add 0.0.0.0 mask 0.0.0.0 192.168.51.254&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Use add -p to make the route persistent.&lt;br /&gt;
&lt;br /&gt;
Configure additional IP addresses&lt;br /&gt;
&lt;br /&gt;
Linux&lt;br /&gt;
&lt;br /&gt;
# ifconfig eth0 192.168.50.254 netmask 255.255.255.0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # First IP&lt;br /&gt;
# ifconfig eth0:0 192.168.51.254 netmask 255.255.255.0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Second IP&lt;br /&gt;
# ip addr add 192.168.50.254/24 dev eth0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Equivalent ip commands&lt;br /&gt;
# ip addr add 192.168.51.254/24 dev eth0 label eth0:1&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
FreeBSD&lt;br /&gt;
&lt;br /&gt;
# ifconfig fxp0 inet 192.168.50.254/24&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # First IP&lt;br /&gt;
# ifconfig fxp0 alias 192.168.51.254 netmask 255.255.255.0 # Second IP&lt;br /&gt;
# ifconfig fxp0 -alias 192.168.51.254&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Remove second IP alias&lt;br /&gt;
&lt;br /&gt;
Permanent entries in /etc/rc.conf&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
ifconfig_fxp0="inet 192.168.50.254&amp;nbsp; netmask 255.255.255.0"&lt;br /&gt;
ifconfig_fxp0_alias0="192.168.51.254 netmask 255.255.255.0"&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Solaris&lt;br /&gt;
&lt;br /&gt;
Check the settings with ifconfig -a&lt;br /&gt;
&lt;br /&gt;
# ifconfig hme0 plumb&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Enable the network card&lt;br /&gt;
# ifconfig hme0 192.168.50.254 netmask 255.255.255.0 up&amp;nbsp;&amp;nbsp;&amp;nbsp; # First IP&lt;br /&gt;
# ifconfig hme0:1 192.168.51.254 netmask 255.255.255.0 up&amp;nbsp; # Second IP&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Change MAC address&lt;br /&gt;
&lt;br /&gt;
Normally you have to bring the interface down before the change. Don't tell me why you want to change the MAC address...&lt;br /&gt;
&lt;br /&gt;
# ifconfig eth0 down&lt;br /&gt;
# ifconfig eth0 hw ether 00:01:02:03:04:05&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Linux&lt;br /&gt;
# ifconfig fxp0 link 00:01:02:03:04:05&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # FreeBSD&lt;br /&gt;
# ifconfig hme0 ether 00:01:02:03:04:05&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Solaris&lt;br /&gt;
# sudo ifconfig en0 ether 00:01:02:03:04:05&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # OS X Tiger, Snow Leopard LAN*&lt;br /&gt;
# sudo ifconfig en0 lladdr 00:01:02:03:04:05&amp;nbsp;&amp;nbsp;&amp;nbsp; # OS X Leopard&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Typical wireless interface is en1 and needs do disassociate from&lt;br /&gt;
any network first (osxdaily howto).&lt;br /&gt;
&lt;br /&gt;
# echo "alias airport='/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport'"\&lt;br /&gt;
&amp;gt;&amp;gt; ~/.bash_profile&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # or symlink to /usr/sbin&lt;br /&gt;
# airport -z&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Disassociate from wireless networks&lt;br /&gt;
# airport -I&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Get info from wireless network&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Many tools exist for Windows. For example etherchangehttp://ntsecurity.nu/toolbox/etherchange. Or look for "Mac Makeup", "smac".&lt;br /&gt;
&lt;br /&gt;
Ports in use&lt;br /&gt;
&lt;br /&gt;
Listening open ports:&lt;br /&gt;
&lt;br /&gt;
# netstat -an | grep LISTEN&lt;br /&gt;
# lsof -i&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Linux list all Internet connections&lt;br /&gt;
# socklist&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Linux display list of open sockets&lt;br /&gt;
# sockstat -4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # FreeBSD application listing&lt;br /&gt;
# netstat -anp --udp --tcp | grep LISTEN&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Linux&lt;br /&gt;
# netstat -tup&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # List active connections to/from system (Linux)&lt;br /&gt;
# netstat -tupl&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # List listening ports from system (Linux)&lt;br /&gt;
# netstat -ano&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Windows&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Firewall&lt;br /&gt;
&lt;br /&gt;
Check if a firewall is running (typical configuration only):&lt;br /&gt;
Linux&lt;br /&gt;
&lt;br /&gt;
# iptables -L -n -v&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # For status&lt;br /&gt;
Open the iptables firewall&lt;br /&gt;
# iptables -P INPUT&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ACCEPT&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Open everything&lt;br /&gt;
# iptables -P FORWARD&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ACCEPT&lt;br /&gt;
# iptables -P OUTPUT&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ACCEPT&lt;br /&gt;
# iptables -Z&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Zero the packet and byte counters in all chains&lt;br /&gt;
# iptables -F&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Flush all chains&lt;br /&gt;
# iptables -X&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Delete all chains&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
FreeBSD&lt;br /&gt;
&lt;br /&gt;
# ipfw show&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # For status&lt;br /&gt;
# ipfw list 65535 # if answer is "65535 deny ip from any to any" the fw is disabled&lt;br /&gt;
# sysctl net.inet.ip.fw.enable=0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Disable&lt;br /&gt;
# sysctl net.inet.ip.fw.enable=1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Enable&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
IP Forward for routing&lt;br /&gt;
&lt;br /&gt;
Linux&lt;br /&gt;
&lt;br /&gt;
Check and then enable IP forward with:&lt;br /&gt;
&lt;br /&gt;
# cat /proc/sys/net/ipv4/ip_forward&amp;nbsp; # Check IP forward 0=off, 1=on&lt;br /&gt;
# echo 1 &amp;gt; /proc/sys/net/ipv4/ip_forward&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
or edit /etc/sysctl.conf with:&lt;br /&gt;
&lt;br /&gt;
net.ipv4.ip_forward = 1&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
FreeBSD&lt;br /&gt;
&lt;br /&gt;
Check and enable with:&lt;br /&gt;
&lt;br /&gt;
# sysctl net.inet.ip.forwarding&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Check IP forward 0=off, 1=on&lt;br /&gt;
# sysctl net.inet.ip.forwarding=1&lt;br /&gt;
# sysctl net.inet.ip.fastforwarding=1&amp;nbsp;&amp;nbsp; &amp;nbsp;# For dedicated router or firewall&lt;br /&gt;
Permanent with entry in /etc/rc.conf:&lt;br /&gt;
gateway_enable="YES"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Set to YES if this host will be a gateway.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Solaris&lt;br /&gt;
&lt;br /&gt;
# ndd -set /dev/ip ip_forwarding 1&amp;nbsp;&amp;nbsp; # Set IP forward 0=off, 1=on&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
NAT Network Address Translation&lt;br /&gt;
&lt;br /&gt;
Linux&lt;br /&gt;
&lt;br /&gt;
# iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE&amp;nbsp;&amp;nbsp; &amp;nbsp;# to activate NAT&lt;br /&gt;
# iptables -t nat -A PREROUTING -p tcp -d 78.31.70.238 --dport 20022 -j DNAT \&lt;br /&gt;
--to 192.168.16.44:22&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Port forward 20022 to internal IP port ssh&lt;br /&gt;
# iptables -t nat -A PREROUTING -p tcp -d 78.31.70.238 --dport 993:995 -j DNAT \&lt;br /&gt;
--to 192.168.16.254:993-995&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Port forward of range 993-995&lt;br /&gt;
# ip route flush cache&lt;br /&gt;
# iptables -L -t nat&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Check NAT status&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Delete the port forward with -D instead of -A. The program netstat-nathttp://tweegy.nl/projects/netstat-nat is very useful to track connections (it uses /proc/net/ip_conntrack or /proc/net/nf_conntrack).&lt;br /&gt;
&lt;br /&gt;
# netstat-nat -n&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # show all connections with IPs&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
FreeBSD&lt;br /&gt;
&lt;br /&gt;
# natd -s -m -u -dynamic -f /etc/natd.conf -n fxp0&lt;br /&gt;
Or edit /etc/rc.conf with:&lt;br /&gt;
firewall_enable="YES"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Set to YES to enable firewall functionality&lt;br /&gt;
firewall_type="open"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Firewall type (see /etc/rc.firewall)&lt;br /&gt;
natd_enable="YES"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Enable natd (if firewall_enable == YES).&lt;br /&gt;
natd_interface="tun0"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Public interface or IP address to use.&lt;br /&gt;
natd_flags="-s -m -u -dynamic -f /etc/natd.conf"&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Port forward with:&lt;br /&gt;
&lt;br /&gt;
# cat /etc/natd.conf &lt;br /&gt;
same_ports yes&lt;br /&gt;
use_sockets yes&lt;br /&gt;
unregistered_only&lt;br /&gt;
# redirect_port tcp insideIP:2300-2399 3300-3399&amp;nbsp; # port range&lt;br /&gt;
redirect_port udp 192.168.51.103:7777 7777&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
DNS&lt;br /&gt;
&lt;br /&gt;
On Unix the DNS entries are valid for all interfaces and are stored in /etc/resolv.conf. The domain to which the host belongs is also stored in this file. A minimal configuration is:&lt;br /&gt;
&lt;br /&gt;
nameserver 78.31.70.238&lt;br /&gt;
search sleepyowl.net intern.lab&lt;br /&gt;
domain sleepyowl.net&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Check the system domain name with:&lt;br /&gt;
&lt;br /&gt;
# hostname -d&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Same as dnsdomainname&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Windows&lt;br /&gt;
&lt;br /&gt;
On Windows the DNS are configured per interface. To display the configured DNS and to flush the DNS cache use:&lt;br /&gt;
&lt;br /&gt;
# ipconfig /?&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Display help&lt;br /&gt;
# ipconfig /all&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # See all information including DNS&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Flush DNS&lt;br /&gt;
&lt;br /&gt;
Flush the OS DNS cache, some application using their own cache (e.g. Firefox) and will be unaffected.&lt;br /&gt;
&lt;br /&gt;
# /etc/init.d/nscd restart&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Restart nscd if used - Linux/BSD/Solaris&lt;br /&gt;
# lookupd -flushcache&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # OS X Tiger&lt;br /&gt;
# dscacheutil -flushcache&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # OS X Leopard and newer&lt;br /&gt;
# ipconfig /flushdns&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Windows&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Forward queries&lt;br /&gt;
&lt;br /&gt;
Dig is you friend to test the DNS settings. For example the public DNS server 213.133.105.2 ns.second-ns.de can be used for testing. See from which server the client receives the answer (simplified answer).&lt;br /&gt;
&lt;br /&gt;
# dig sleepyowl.net&lt;br /&gt;
sleepyowl.net.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 600&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IN&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 78.31.70.238&lt;br /&gt;
;; SERVER: 192.168.51.254#53(192.168.51.254)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The router 192.168.51.254 answered and the response is the A entry. Any entry can be queried and the DNS server can be selected with @:&lt;br /&gt;
&lt;br /&gt;
# dig MX google.com&lt;br /&gt;
# dig @127.0.0.1 NS sun.com&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # To test the local server&lt;br /&gt;
# dig @204.97.212.10 NS MX heise.de&amp;nbsp; # Query an external server&lt;br /&gt;
# dig AXFR @ns1.xname.org cb.vu&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Get the full zone (zone transfer)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The program host is also powerful.&lt;br /&gt;
&lt;br /&gt;
# host -t MX cb.vu&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Get the mail MX entry&lt;br /&gt;
# host -t NS -T sun.com&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Get the NS record over a TCP connection&lt;br /&gt;
# host -a sleepyowl.net&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Get everything&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Reverse queries&lt;br /&gt;
&lt;br /&gt;
Find the name belonging to an IP address (in-addr.arpa.). This can be done with dig, host and nslookup:&lt;br /&gt;
&lt;br /&gt;
# dig -x 78.31.70.238&lt;br /&gt;
# host 78.31.70.238&lt;br /&gt;
# nslookup 78.31.70.238&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/etc/hosts&lt;br /&gt;
&lt;br /&gt;
Single hosts can be configured in the file /etc/hosts instead of running named locally to resolve the hostname queries. The format is simple, for example:&lt;br /&gt;
&lt;br /&gt;
78.31.70.238&amp;nbsp;&amp;nbsp; sleepyowl.net&amp;nbsp;&amp;nbsp; sleepyowl&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The priority between hosts and a dns query, that is the name resolution order, can be configured in /etc/nsswitch.conf AND /etc/host.conf. The file also exists on Windows, it is usually in:&lt;br /&gt;
&lt;br /&gt;
C:\WINDOWS\SYSTEM32\DRIVERS\ETC&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
DHCP&lt;br /&gt;
&lt;br /&gt;
Linux&lt;br /&gt;
&lt;br /&gt;
Some distributions (SuSE) use dhcpcd as client. The default interface is eth0.&lt;br /&gt;
&lt;br /&gt;
# dhcpcd -n eth0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Trigger a renew (does not always work)&lt;br /&gt;
# dhcpcd -k eth0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # release and shutdown&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The lease with the full information is stored in:&lt;br /&gt;
&lt;br /&gt;
/var/lib/dhcpcd/dhcpcd-eth0.info&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
FreeBSD&lt;br /&gt;
&lt;br /&gt;
FreeBSD (and Debian) uses dhclient. To configure an interface (for example bge0) run:&lt;br /&gt;
&lt;br /&gt;
# dhclient bge0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The lease with the full information is stored in:&lt;br /&gt;
&lt;br /&gt;
/var/db/dhclient.leases.bge0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Use &lt;br /&gt;
&lt;br /&gt;
/etc/dhclient.conf&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;to prepend options or force different options:&lt;br /&gt;
&lt;br /&gt;
# cat /etc/dhclient.conf&lt;br /&gt;
interface "rl0" {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; prepend domain-name-servers 127.0.0.1;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; default domain-name "sleepyowl.net";&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; supersede domain-name "sleepyowl.net";&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Windows&lt;br /&gt;
&lt;br /&gt;
The dhcp lease can be renewed with ipconfig:&lt;br /&gt;
&lt;br /&gt;
# ipconfig /renew&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # renew all adapters&lt;br /&gt;
# ipconfig /renew LAN&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # renew the adapter named "LAN"&lt;br /&gt;
# ipconfig /release WLAN&amp;nbsp;&amp;nbsp; # release the adapter named "WLAN"&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Yes it is a good idea to rename you adapter with simple names!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Traffic analysis&lt;br /&gt;
&lt;br /&gt;
Bmonhttp://people.suug.ch/~tgr/bmon/ is a small console bandwidth monitor and can display the flow on different interfaces. &lt;br /&gt;
Sniff with tcpdump&lt;br /&gt;
&lt;br /&gt;
# tcpdump -nl -i bge0 not port ssh and src \(192.168.16.121 or 192.168.16.54\)&lt;br /&gt;
# tcpdump -n -i eth1 net 192.168.16.121&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # select to/from a single IP&lt;br /&gt;
# tcpdump -n -i eth1 net 192.168.16.0/24&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # select traffic to/from a network&lt;br /&gt;
# tcpdump -l &amp;gt; dump &amp;amp;&amp;amp; tail -f dump&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Buffered output&lt;br /&gt;
# tcpdump -i rl0 -w traffic.rl0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Write traffic headers in binary file&lt;br /&gt;
# tcpdump -i rl0 -s 0 -w traffic.rl0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Write traffic + payload in binary file&lt;br /&gt;
# tcpdump -r traffic.rl0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Read from file (also for ethereal&lt;br /&gt;
# tcpdump port 80&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # The two classic commands&lt;br /&gt;
# tcpdump host google.com&lt;br /&gt;
# tcpdump -i eth0 -X port \(110 or 143\)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Check if pop or imap is secure&lt;br /&gt;
# tcpdump -n -i eth0 icmp&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Only catch pings&lt;br /&gt;
# tcpdump -i eth0 -s 0 -A port 80 | grep GET&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # -s 0 for full packet -A for ASCII&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Additional important options:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; -A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Print each packets in clear text (without header)&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; -X&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Print packets in hex and ASCII&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; -l&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Make stdout line buffered&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; -D&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Print all interfaces available&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On Windows use windump from www.winpcap.org. Use windump -D to list the interfaces.&lt;br /&gt;
Scan with nmap&lt;br /&gt;
&lt;br /&gt;
Nmaphttp://insecure.org/nmap/ is a port scanner with OS detection, it is usually installed on most distributions and is also available for Windows. If you don't scan your servers, hackers do it for you...&lt;br /&gt;
&lt;br /&gt;
# nmap cb.vu&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # scans all reserved TCP ports on the host&lt;br /&gt;
# nmap -sP 192.168.16.0/24 # Find out which IP are used and by which host on 0/24&lt;br /&gt;
# nmap -sS -sV -O cb.vu&amp;nbsp;&amp;nbsp;&amp;nbsp; # Do a stealth SYN scan with version and OS detection&lt;br /&gt;
PORT&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; STATE&amp;nbsp; SERVICE&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VERSION&lt;br /&gt;
22/tcp&amp;nbsp;&amp;nbsp;&amp;nbsp; open&amp;nbsp;&amp;nbsp; ssh&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; OpenSSH 3.8.1p1 FreeBSD-20060930 (protocol 2.0)&lt;br /&gt;
25/tcp&amp;nbsp;&amp;nbsp;&amp;nbsp; open&amp;nbsp;&amp;nbsp; smtp&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Sendmail smtpd 8.13.6/8.13.6&lt;br /&gt;
80/tcp&amp;nbsp;&amp;nbsp;&amp;nbsp; open&amp;nbsp;&amp;nbsp; http&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Apache httpd 2.0.59 ((FreeBSD) DAV/2 PHP/4.&lt;br /&gt;
[...]&lt;br /&gt;
Running: FreeBSD 5.X&lt;br /&gt;
Uptime 33.120 days (since Fri Aug 31 11:41:04 2007)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Other non standard but useful tools are hping (www.hping.org) an IP packet assembler/analyzer and fping (fping.sourceforge.net). fping can check multiple hosts in a round-robin fashion.&lt;br /&gt;
&lt;br /&gt;
Traffic control (QoS)&lt;br /&gt;
&lt;br /&gt;
Traffic control manages the queuing, policing, scheduling, and other traffic parameters for a network. The following examples are simple practical uses of the Linux and FreeBSD capabilities to better use the available bandwidth.&lt;br /&gt;
Limit upload&lt;br /&gt;
&lt;br /&gt;
DSL or cable modems have a long queue to improve the upload throughput. However filling the queue with a fast device (e.g. ethernet) will dramatically decrease the interactivity. It is therefore useful to limit the device upload rate to match the physical capacity of the modem, this should greatly improve the interactivity. Set to about 90% of the modem maximal (cable) speed.&lt;br /&gt;
Linux&lt;br /&gt;
&lt;br /&gt;
For a 512 Kbit upload modem.&lt;br /&gt;
&lt;br /&gt;
# tc qdisc add dev eth0 root tbf rate 480kbit latency 50ms burst 1540&lt;br /&gt;
# tc -s qdisc ls dev eth0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Status&lt;br /&gt;
# tc qdisc del dev eth0 root&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Delete the queue&lt;br /&gt;
# tc qdisc change dev eth0 root tbf rate 220kbit latency 50ms burst 1540&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
FreeBSD&lt;br /&gt;
&lt;br /&gt;
FreeBSD uses the dummynet traffic shaper which is configured with ipfw. Pipes are used to set limits the bandwidth in units of [K|M]{bit/s|Byte/s}, 0 means unlimited bandwidth. Using the same pipe number will reconfigure it. For example limit the upload bandwidth to 500 Kbit.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# kldload dummynet&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # load the module if necessary&lt;br /&gt;
# ipfw pipe 1 config bw 500Kbit/s&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # create a pipe with limited bandwidth&lt;br /&gt;
# ipfw add pipe 1 ip from me to any&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # divert the full upload into the pipe&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Quality of service&lt;br /&gt;
&lt;br /&gt;
Linux&lt;br /&gt;
&lt;br /&gt;
Priority queuing with tc to optimize VoIP. See the full example on voip-info.org or www.howtoforge.com. Suppose VoIP uses udp on ports 10000:11024 and device eth0 (could also be ppp0 or so). The following commands define the QoS to three queues and force the VoIP traffic to queue 1 with QoS 0x1e (all bits set). The default traffic flows into queue 3 and QoS Minimize-Delay flows into queue 2.&lt;br /&gt;
&lt;br /&gt;
# tc qdisc add dev eth0 root handle 1: prio priomap 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 0&lt;br /&gt;
# tc qdisc add dev eth0 parent 1:1 handle 10: sfq&lt;br /&gt;
# tc qdisc add dev eth0 parent 1:2 handle 20: sfq&lt;br /&gt;
# tc qdisc add dev eth0 parent 1:3 handle 30: sfq&lt;br /&gt;
# tc filter add dev eth0 protocol ip parent 1: prio 1 u32 \&lt;br /&gt;
&amp;nbsp; match ip dport 10000 0x3C00 flowid 1:1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # use server port range&lt;br /&gt;
&amp;nbsp; match ip dst 123.23.0.1 flowid 1:1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # or/and use server IP&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Status and remove with&lt;br /&gt;
&lt;br /&gt;
# tc -s qdisc ls dev eth0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # queue status&lt;br /&gt;
# tc qdisc del dev eth0 root&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # delete all QoS&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Calculate port range and mask&lt;br /&gt;
&lt;br /&gt;
The tc filter defines the port range with port and mask which you have to calculate. Find the 2^N ending of the port range, deduce the range and convert to HEX. This is your mask. Example for 10000 -&amp;gt; 11024, the range is 1024.&lt;br /&gt;
&lt;br /&gt;
# 2^13 (8192) &amp;lt; 10000 &amp;lt; 2^14 (16384)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # ending is 2^14 = 16384&lt;br /&gt;
# echo "obase=16;(2^14)-1024" | bc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # mask is 0x3C00&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
FreeBSD&lt;br /&gt;
&lt;br /&gt;
The max link bandwidth is 500Kbit/s and we define 3 queues with priority 100:10:1 for VoIP:ssh:all the rest.&lt;br /&gt;
&lt;br /&gt;
# ipfw pipe 1 config bw 500Kbit/s &lt;br /&gt;
# ipfw queue 1 config pipe 1 weight 100&lt;br /&gt;
# ipfw queue 2 config pipe 1 weight 10&lt;br /&gt;
# ipfw queue 3 config pipe 1 weight 1&lt;br /&gt;
# ipfw add 10 queue 1 proto udp dst-port 10000-11024&lt;br /&gt;
# ipfw add 11 queue 1 proto udp dst-ip 123.23.0.1 # or/and use server IP&lt;br /&gt;
# ipfw add 20 queue 2 dsp-port ssh&lt;br /&gt;
# ipfw add 30 queue 3 from me to any&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # all the rest&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Status and remove with&lt;br /&gt;
&lt;br /&gt;
# ipfw list&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # rules status&lt;br /&gt;
# ipfw pipe list&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # pipe status&lt;br /&gt;
# ipfw flush&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # deletes all rules but default&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
NIS Debugging&lt;br /&gt;
&lt;br /&gt;
Some commands which should work on a well configured NIS client:&lt;br /&gt;
&lt;br /&gt;
# ypwhich&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # get the connected NIS server name&lt;br /&gt;
# domainname&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # The NIS domain name as configured&lt;br /&gt;
# ypcat group&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # should display the group from the NIS server&lt;br /&gt;
# cd /var/yp &amp;amp;&amp;amp; make&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Rebuild the yp database&lt;br /&gt;
# rpcinfo -p servername&amp;nbsp;&amp;nbsp;&amp;nbsp; # Report RPC services of the server&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Is ypbind running?&lt;br /&gt;
&lt;br /&gt;
# ps auxww | grep ypbind&lt;br /&gt;
/usr/sbin/ypbind -s -m -S servername1,servername2&amp;nbsp;&amp;nbsp; &amp;nbsp;# FreeBSD&lt;br /&gt;
/usr/sbin/ypbind&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Linux&lt;br /&gt;
# yppoll passwd.byname&lt;br /&gt;
Map passwd.byname has order number 1190635041. Mon Sep 24 13:57:21 2007&lt;br /&gt;
The master server is servername.domain.net.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Linux&lt;br /&gt;
&lt;br /&gt;
# cat /etc/yp.conf&lt;br /&gt;
ypserver servername&lt;br /&gt;
domain domain.net broadcast&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Netcat&lt;br /&gt;
&lt;br /&gt;
Netcathttp://netcat.sourceforge.net (nc) is better known as the "network Swiss Army Knife", it can manipulate, create or read/write TCP/IP connections. Here some useful examples, there are many more on the net, for example g-loaded.eu[...]http://www.g-loaded.eu/2006/11/06/netcat-a-couple-of-useful-examples and herehttp://www.terminally-incoherent.com/blog/2007/08/07/few-useful-netcat-tricks.&lt;br /&gt;
&amp;nbsp;You might need to use the command netcat instead of nc. Also see the similar command socat.&lt;br /&gt;
&lt;br /&gt;
File transfer&lt;br /&gt;
&lt;br /&gt;
Copy a large folder over a raw tcp connection. The transfer is very quick (no protocol overhead) and you don't need to mess up with NFS or SMB or FTP or so, simply make the file available on the server, and get it from the client. Here 192.168.1.1 is the server IP address.&lt;br /&gt;
&lt;br /&gt;
server# tar -cf - -C VIDEO_TS . | nc -l -p 4444&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Serve tar folder on port 4444&lt;br /&gt;
client# nc 192.168.1.1 4444 | tar xpf - -C VIDEO_TS&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Pull the file on port 4444&lt;br /&gt;
server# cat largefile | nc -l 5678&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Server a single file&lt;br /&gt;
client# nc 192.168.1.1 5678 &amp;gt; largefile&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Pull the single file&lt;br /&gt;
server# dd if=/dev/da0 | nc -l 4444&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Server partition image&lt;br /&gt;
client# nc 192.168.1.1 4444 | dd of=/dev/da0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Pull partition to clone&lt;br /&gt;
client# nc 192.168.1.1 4444 | dd of=da0.img&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Pull partition to file&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Other hacks&lt;br /&gt;
&lt;br /&gt;
Specially here, you must know what you are doing.&lt;br /&gt;
Remote shell&lt;br /&gt;
&lt;br /&gt;
Option -e only on the Windows version? Or use nc 1.10.&lt;br /&gt;
&lt;br /&gt;
# nc -lp 4444 -e /bin/bash&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Provide a remote shell (server backdoor)&lt;br /&gt;
# nc -lp 4444 -e cmd.exe&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # remote shell for Windows&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Emergency web server&lt;br /&gt;
&lt;br /&gt;
Serve a single file on port 80 in a loop.&lt;br /&gt;
&lt;br /&gt;
# while true; do nc -l -p 80 &amp;lt; unixtoolbox.xhtml; done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Chat&lt;br /&gt;
&lt;br /&gt;
Alice and Bob can chat over a simple TCP socket. The text is transferred with the enter key.&lt;br /&gt;
&lt;br /&gt;
alice# nc -lp 4444&lt;br /&gt;
bob&amp;nbsp; # nc 192.168.1.1 4444&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
SSH SCP&lt;br /&gt;
&lt;br /&gt;
Public key | Fingerprint | SCP | Tunneling&lt;br /&gt;
&lt;br /&gt;
See other tricks 25 ssh cmdhttp://blog.urfix.com/25-ssh-commands-tricks/&lt;br /&gt;
Public key authentication&lt;br /&gt;
&lt;br /&gt;
Connect to a host without password using public key authentication. The idea is to append your public key to the authorized_keys2 file on the remote host. For this example let's connect host-client to host-server, the key is generated on the client. With cygwin you might have to create your home directoy and the .ssh directory with # mkdir -p /home/USER/.ssh&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; Use ssh-keygen to generate a key pair. ~/.ssh/id_dsa is the private key, ~/.ssh/id_dsa.pub is the public key.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; Copy only the public key to the server and append it to the file ~/.ssh/authorized_keys2 on your home on the server.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# ssh-keygen -t dsa -N ''&lt;br /&gt;
# cat ~/.ssh/id_dsa.pub | ssh you@host-server "cat - &amp;gt;&amp;gt; ~/.ssh/authorized_keys2"&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Using the Windows client from ssh.com&lt;br /&gt;
&lt;br /&gt;
The non commercial version of the ssh.com client can be downloaded the main ftp site: ftp.ssh.com/pub/ssh/. Keys generated by the ssh.com client need to be converted for the OpenSSH server. This can be done with the ssh-keygen command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; Create a key pair with the ssh.com client: Settings - User Authentication - Generate New....&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; I use Key type DSA; key length 2048.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; Copy the public key generated by the ssh.com client to the server into the ~/.ssh folder.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; The keys are in C:\Documents and Settings\%USERNAME%\Application Data\SSH\UserKeys.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; Use the ssh-keygen command on the server to convert the key:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # cd ~/.ssh&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # ssh-keygen -i -f keyfilename.pub &amp;gt;&amp;gt; authorized_keys2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Notice: We used a DSA key, RSA is also possible. The key is not protected by a password.&lt;br /&gt;
Using putty for Windows&lt;br /&gt;
&lt;br /&gt;
Puttyhttp://www.chiark.greenend.org.uk/~sgtatham/putty/download.html is a simple and free ssh client for Windows. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; Create a key pair with the puTTYgen program.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; Save the public and private keys (for example into C:\Documents and Settings\%USERNAME%\.ssh).&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; Copy the public key to the server into the ~/.ssh folder:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # scp .ssh/puttykey.pub root@192.168.51.254:.ssh/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; Use the ssh-keygen command on the server to convert the key for OpenSSH:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # cd ~/.ssh&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # ssh-keygen -i -f puttykey.pub &amp;gt;&amp;gt; authorized_keys2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; * Point the private key location in the putty settings: Connection - SSH - Auth&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Check fingerprint&lt;br /&gt;
&lt;br /&gt;
At the first login, ssh will ask if the unknown host with the fingerprint has to be stored in the known hosts. To avoid a man-in-the-middle attack the administrator of the server can send you the server fingerprint which is then compared on the first login. Use ssh-keygen -l to get the fingerprint (on the server):&lt;br /&gt;
&lt;br /&gt;
# ssh-keygen -l -f /etc/ssh/ssh_host_rsa_key.pub&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # For RSA key&lt;br /&gt;
2048 61:33:be:9b:ae:6c:36:31:fd:83:98:b7:99:2d:9f:cd /etc/ssh/ssh_host_rsa_key.pub&lt;br /&gt;
# ssh-keygen -l -f /etc/ssh/ssh_host_dsa_key.pub&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # For DSA key (default)&lt;br /&gt;
2048 14:4a:aa:d9:73:25:46:6d:0a:48:35:c7:f4:16:d4:ee /etc/ssh/ssh_host_dsa_key.pub&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now the client connecting to this server can verify that he is connecting to the right server:&lt;br /&gt;
&lt;br /&gt;
# ssh linda&lt;br /&gt;
The authenticity of host 'linda (192.168.16.54)' can't be established.&lt;br /&gt;
DSA key fingerprint is 14:4a:aa:d9:73:25:46:6d:0a:48:35:c7:f4:16:d4:ee.&lt;br /&gt;
Are you sure you want to continue connecting (yes/no)? yes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Secure file transfer&lt;br /&gt;
&lt;br /&gt;
Some simple commands:&lt;br /&gt;
&lt;br /&gt;
# scp file.txt host-two:/tmp&lt;br /&gt;
# scp joe@host-two:/www/*.html /www/tmp&lt;br /&gt;
# scp -r joe@host-two:/www /www/tmp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In Konqueror or Midnight Commander it is possible to access a remote file system with the address fish://user@gate. However the implementation is very slow.&lt;br /&gt;
&lt;br /&gt;
Furthermore it is possible to mount a remote folder with sshfs a file system client based on SCP. See fuse sshfshttp://fuse.sourceforge.net/sshfs.html.&lt;br /&gt;
&lt;br /&gt;
ssh_exchange_identification: Connection closed by remote host&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
With this error try the following on the server:&lt;br /&gt;
&lt;br /&gt;
echo 'SSHD: ALL' &amp;gt;&amp;gt; /etc/hosts.allow&lt;br /&gt;
/etc/init.d/sshd restart&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tunneling&lt;br /&gt;
&lt;br /&gt;
SSH tunneling allows to forward or reverse forward a port over the SSH connection, thus securing the traffic and accessing ports which would otherwise be blocked. This only works with TCP. The general nomenclature for forward and reverse is (see also ssh and NAT example):&lt;br /&gt;
&lt;br /&gt;
# ssh -L localport:desthost:destport user@gate&amp;nbsp; # desthost as seen from the gate&lt;br /&gt;
# ssh -R destport:desthost:localport user@gate&amp;nbsp; # forwards your localport to destination&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; # desthost:localport as seen from the client initiating the tunnel&lt;br /&gt;
# ssh -X user@gate&amp;nbsp;&amp;nbsp; # To force X forwarding&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This will connect to gate and forward the local port to the host desthost:destport. Note desthost is the destination host as seen by the gate, so if the connection is to the gate, then desthost is localhost. More than one port forward is possible.&lt;br /&gt;
Direct forward on the gate&lt;br /&gt;
&lt;br /&gt;
Let say we want to access the CVS (port 2401) and http (port 80) which are running on the gate. This is the simplest example, desthost is thus localhost, and we use the port 8080 locally instead of 80 so we don't need to be root. Once the ssh session is open, both services are accessible on the local ports.&lt;br /&gt;
&lt;br /&gt;
# ssh -L 2401:localhost:2401 -L 8080:localhost:80 user@gate&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Netbios and remote desktop forward to a second server&lt;br /&gt;
&lt;br /&gt;
Let say a Windows smb server is behind the gate and is not running ssh. We need access to the smb share and also remote desktop to the server.&lt;br /&gt;
&lt;br /&gt;
# ssh -L 139:smbserver:139 -L 3388:smbserver:3389 user@gate&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The smb share can now be accessed with \\127.0.0.1\, but only if the local share is disabled, because the local share is listening on port 139.&lt;br /&gt;
&lt;br /&gt;
It is possible to keep the local share enabled, for this we need to create a new virtual device with a new IP address for the tunnel, the smb share will be connected over this address. Furthermore the local RDP is already listening on 3389, so we choose 3388. For this example let's use a virtual IP of 10.1.1.1.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; * With putty use Source port=10.1.1.1:139. It is possible to create multiple loop devices and tunnel. On Windows 2000, only putty worked for me. On Windows Vista also forward the port 445 in addition to the port 139. Also on Vista the patch KB942624 prevents the port 445 to be forwarded, so I had to uninstall this path in Vista.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; * With the ssh.com client, disable "Allow local connections only". Since ssh.com will bind to all addresses, only a single share can be connected.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now create the loopback interface with IP 10.1.1.1:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; * # System-&amp;gt;Control Panel-&amp;gt;Add Hardware # Yes, Hardware is already connected&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Add a new hardware device (at bottom).&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; * # Install the hardware that I manually select # Network adapters # Microsoft , Microsoft Loopback Adapter.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; * Configure the IP address of the fake device to 10.1.1.1 mask 255.255.255.0, no gateway.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; * advanced-&amp;gt;WINS, Enable LMHosts Lookup; Disable NetBIOS over TCP/IP.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; * # Enable Client for Microsoft Networks. # Disable File and Printer Sharing for Microsoft Networks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I HAD to reboot for this to work. Now connect to the smb share with \\10.1.1.1 and remote desktop to 10.1.1.1:3388.&lt;br /&gt;
Debug&lt;br /&gt;
&lt;br /&gt;
If it is not working:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; * Are the ports forwarded: netstat -an? Look at 0.0.0.0:139 or 10.1.1.1:139&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; * Does telnet 10.1.1.1 139 connect?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; * You need the checkbox "Local ports accept connections from other hosts".&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; * Is "File and Printer Sharing for Microsoft Networks" disabled on the loopback interface?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Connect two clients behind NAT&lt;br /&gt;
&lt;br /&gt;
Suppose two clients are behind a NAT gateway and client cliadmin has to connect to client cliuser (the destination), both can login to the gate with ssh and are running Linux with sshd. You don't need root access anywhere as long as the ports on gate are above 1024. We use 2022 on gate. Also since the gate is used locally, the option GatewayPorts is not necessary.&lt;br /&gt;
&lt;br /&gt;
On client cliuser (from destination to gate):&lt;br /&gt;
&lt;br /&gt;
# ssh -R 2022:localhost:22 user@gate&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # forwards client 22 to gate:2022&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On client cliadmin (from host to gate):&lt;br /&gt;
&lt;br /&gt;
# ssh -L 3022:localhost:2022 admin@gate&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # forwards client 3022 to gate:2022&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now the admin can connect directly to the client cliuser with:&lt;br /&gt;
&lt;br /&gt;
# ssh -p 3022 admin@localhost&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # local:3022 -&amp;gt; gate:2022 -&amp;gt; client:22&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Connect to VNC behind NAT&lt;br /&gt;
&lt;br /&gt;
Suppose a Windows client with VNC listening on port 5900 has to be accessed from behind NAT.&lt;br /&gt;
On client cliwin to gate:&lt;br /&gt;
&lt;br /&gt;
# ssh -R 15900:localhost:5900 user@gate&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On client cliadmin (from host to gate):&lt;br /&gt;
&lt;br /&gt;
# ssh -L 5900:localhost:15900 admin@gate&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now the admin can connect directly to the client VNC with:&lt;br /&gt;
&lt;br /&gt;
# vncconnect -display :0 localhost&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Dig a multi-hop ssh tunnel&lt;br /&gt;
&lt;br /&gt;
Suppose you can not reach a server directly with ssh, but only via multiple intermediate hosts (for example because of routing issues). Sometimes it is still necessary to get a direct client - server connection, for example to copy files with scp, or forward other ports like smb or vnc. One way to do this is to chain tunnels together to forward a port to the server along the hops. This "carrier" port only reaches its final destination on the last connection to the server.&lt;br /&gt;
&lt;br /&gt;
Suppose we want to forward the ssh port from a client to a server over two hops. Once the tunnel is build, it is possible to connect to the server directly from the client (and also add an other port forward).&lt;br /&gt;
Create tunnel in one shell&lt;br /&gt;
&lt;br /&gt;
client -&amp;gt; host1 -&amp;gt; host2 -&amp;gt; server and dig tunnel 5678&lt;br /&gt;
&lt;br /&gt;
client&amp;gt;# ssh -L5678:localhost:5678 host1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # 5678 is an arbitrary port for the tunnel&lt;br /&gt;
host_1&amp;gt;# ssh -L5678:localhost:5678 host2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # chain 5678 from host1 to host2&lt;br /&gt;
host_2&amp;gt;# ssh -L5678:localhost:22 server&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # end the tunnel on port 22 on the server&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Use tunnel with an other shell&lt;br /&gt;
&lt;br /&gt;
client -&amp;gt; server using tunnel 5678&lt;br /&gt;
&lt;br /&gt;
# ssh -p 5678 localhost&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # connect directly from client to&amp;nbsp; server&lt;br /&gt;
# scp -P 5678 myfile localhost:/tmp/&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # or copy a file directly using the tunnel&lt;br /&gt;
# rsync -e 'ssh -p 5678' myfile localhost:/tmp/ # or rsync a file directly to the server&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Autoconnect and keep alive script&lt;br /&gt;
&lt;br /&gt;
I use variations of the following script to keep a machine reacheable over a reverse ssh tunnel. The connection is automatically rebuilt if closed. You can add multiple -L or -R tunnels on one line.&lt;br /&gt;
&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
COMMAND="ssh -N -f -g -R 3022:localhost:22 colin@cb.vu"&lt;br /&gt;
pgrep -f -x "$COMMAND" &amp;gt; /dev/null 2&amp;gt;&amp;amp;1 || $COMMAND&lt;br /&gt;
exit 0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1 * * * * colin /home/colin/port_forward.sh&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # crontab entry (here hourly)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
VPN with SSH&lt;br /&gt;
&lt;br /&gt;
As of version 4.3, OpenSSH can use the tun/tap device to encrypt a tunnel. This is very similar to other TLS based VPN solutions like OpenVPN. One advantage with SSH is that there is no need to install and configure additional software. Additionally the tunnel uses the SSH authentication like pre shared keys. The drawback is that the encapsulation is done over TCP which might result in poor performance on a slow link. Also the tunnel is relying on a single (fragile) TCP connection.&amp;nbsp; This technique is very useful for a quick IP based VPN setup. There is no limitation as with the single TCP port forward, all layer 3/4 protocols like ICMP, TCP/UDP, etc. are forwarded over the VPN. In any case, the following options are needed in the sshd_conf file:&lt;br /&gt;
&lt;br /&gt;
PermitRootLogin yes&lt;br /&gt;
PermitTunnel yes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Single P2P connection&lt;br /&gt;
&lt;br /&gt;
Here we are connecting two hosts, hclient and hserver with a peer to peer tunnel. The connection is started from hclient to hserver and is done as root. The tunnel end points are 10.0.1.1 (server) and 10.0.1.2 (client) and we create a device tun5 (this could also be an other number). The procedure is very simple:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; Connect with SSH using the tunnel option -w&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; Configure the IP addresses of the tunnel. Once on the server and once on the client.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Connect to the server&lt;br /&gt;
&lt;br /&gt;
Connection started on the client and commands are executed on the server.&lt;br /&gt;
Server is on Linux&lt;br /&gt;
&lt;br /&gt;
cli&amp;gt;# ssh -w5:5 root@hserver&lt;br /&gt;
srv&amp;gt;# ifconfig tun5 10.0.1.1 netmask 255.255.255.252&amp;nbsp;&amp;nbsp; # Executed on the server shell&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Server is on FreeBSD&lt;br /&gt;
&lt;br /&gt;
cli&amp;gt;# ssh -w5:5 root@hserver&lt;br /&gt;
srv&amp;gt;# ifconfig tun5 10.0.1.1 10.0.1.2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Executed on the server shell&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Configure the client&lt;br /&gt;
&lt;br /&gt;
Commands executed on the client:&lt;br /&gt;
&lt;br /&gt;
cli&amp;gt;# ifconfig tun5 10.0.1.2 netmask 255.255.255.252&amp;nbsp;&amp;nbsp; # Client is on Linux&lt;br /&gt;
cli&amp;gt;# ifconfig tun5 10.0.1.2 10.0.1.1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Client is on FreeBSD&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The two hosts are now connected and can transparently communicate with any layer 3/4 protocol using the tunnel IP addresses.&lt;br /&gt;
&lt;br /&gt;
Connect two networks&lt;br /&gt;
&lt;br /&gt;
In addition to the p2p setup above, it is more useful to connect two private networks with an SSH VPN using two gates. Suppose for the example, netA is 192.168.51.0/24 and netB 192.168.16.0/24. The procedure is similar as above, we only need to add the routing. NAT must be activated on the private interface only if the gates are not the same as the default gateway of their network.&lt;br /&gt;
&lt;br /&gt;
192.168.51.0/24 (netA)|gateA &amp;lt;-&amp;gt; gateB|192.168.16.0/24 (netB)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; Connect with SSH using the tunnel option -w.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; Configure the IP addresses of the tunnel. Once on the server and once on the client.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; Add the routing for the two networks.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; If necessary, activate NAT on the private interface of the gate.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The setup is started from gateA in netA.&lt;br /&gt;
Connect from gateA to gateB&lt;br /&gt;
&lt;br /&gt;
Connection is started from gateA and commands are executed on gateB.&lt;br /&gt;
gateB is on Linux&lt;br /&gt;
&lt;br /&gt;
gateA&amp;gt;# ssh -w5:5 root@gateB&lt;br /&gt;
gateB&amp;gt;# ifconfig tun5 10.0.1.1 netmask 255.255.255.252 # Executed on the gateB shell&lt;br /&gt;
gateB&amp;gt;# route add -net 192.168.51.0 netmask 255.255.255.0 dev tun5&lt;br /&gt;
gateB&amp;gt;# echo 1 &amp;gt; /proc/sys/net/ipv4/ip_forward&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Only needed if not default gw&lt;br /&gt;
gateB&amp;gt;# iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
gateB is on FreeBSD&lt;br /&gt;
&lt;br /&gt;
gateA&amp;gt;# ssh -w5:5 root@gateB&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Creates the tun5 devices&lt;br /&gt;
gateB&amp;gt;# ifconfig tun5 10.0.1.1 10.0.1.2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Executed on the gateB shell&lt;br /&gt;
gateB&amp;gt;# route add 192.168.51.0/24 10.0.1.2&lt;br /&gt;
gateB&amp;gt;# sysctl net.inet.ip.forwarding=1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Only needed if not default gw&lt;br /&gt;
gateB&amp;gt;# natd -s -m -u -dynamic -n fxp0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # see NAT&lt;br /&gt;
gateA&amp;gt;# sysctl net.inet.ip.fw.enable=1&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Configure gateA&lt;br /&gt;
&lt;br /&gt;
Commands executed on gateA:&lt;br /&gt;
gateA is on Linux&lt;br /&gt;
&lt;br /&gt;
gateA&amp;gt;# ifconfig tun5 10.0.1.2 netmask 255.255.255.252&lt;br /&gt;
gateA&amp;gt;# route add -net 192.168.16.0 netmask 255.255.255.0 dev tun5&lt;br /&gt;
gateA&amp;gt;# echo 1 &amp;gt; /proc/sys/net/ipv4/ip_forward&lt;br /&gt;
gateA&amp;gt;# iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
gateA is on FreeBSD&lt;br /&gt;
&lt;br /&gt;
gateA&amp;gt;# ifconfig tun5 10.0.1.2 10.0.1.1&lt;br /&gt;
gateA&amp;gt;# route add 192.168.16.0/24 10.0.1.2&lt;br /&gt;
gateA&amp;gt;# sysctl net.inet.ip.forwarding=1&lt;br /&gt;
gateA&amp;gt;# natd -s -m -u -dynamic -n fxp0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # see NAT&lt;br /&gt;
gateA&amp;gt;# sysctl net.inet.ip.fw.enable=1&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The two private networks are now transparently connected via the SSH VPN. The IP forward and NAT settings are only necessary if the gates are not the default gateways. In this case the clients would not know where to forward the response, and nat must be activated.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
RSYNC&lt;br /&gt;
&lt;br /&gt;
Rsync can almost completely replace cp and scp, furthermore interrupted transfers are efficiently restarted. A trailing slash (and the absence thereof) has different meanings, the man page is good... Here some examples:&lt;br /&gt;
&lt;br /&gt;
Copy the directories with full content:&lt;br /&gt;
&lt;br /&gt;
# rsync -a /home/colin/ /backup/colin/&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # "archive" mode. e.g keep the same&lt;br /&gt;
# rsync -a /var/ /var_bak/&lt;br /&gt;
# rsync -aR --delete-during /home/user/ /backup/&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # use relative (see below)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Same as before but over the network and with compression. Rsync uses SSH for the transport per default and will use the ssh key if they are set. Use ":" as with SCP. A typical remote copy:&lt;br /&gt;
&lt;br /&gt;
# rsync -axSRzv /home/user/ user@server:/backup/user/ # Copy to remote&lt;br /&gt;
# rsync -a 'user@server:My\ Documents' My\ Documents&amp;nbsp; # Quote AND escape spaces for the remote shell&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Exclude any directory tmp within /home/user/ and keep the relative folders hierarchy, that is the remote directory will have the structure /backup/home/user/. This is typically used for backups.&lt;br /&gt;
&lt;br /&gt;
# rsync -azR --exclude=tmp/ /home/user/ user@server:/backup/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Use port 20022 for the ssh connection:&lt;br /&gt;
&lt;br /&gt;
# rsync -az -e 'ssh -p 20022' /home/colin/ user@server:/backup/colin/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Using the rsync daemon (used with "::") is much faster, but not encrypted over ssh. The location of /backup is defined by the configuration in /etc/rsyncd.conf. The variable RSYNC_PASSWORD can be set to avoid the need to enter the password manually.&lt;br /&gt;
&lt;br /&gt;
# rsync -axSRz /home/ ruser@hostname::rmodule/backup/&lt;br /&gt;
# rsync -axSRz ruser@hostname::rmodule/backup/ /home/&amp;nbsp;&amp;nbsp;&amp;nbsp; # To copy back&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Some important options:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; -a, --archive&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; archive mode; same as -rlptgoD (no -H)&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; -r, --recursive&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; recurse into directories&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; -R, --relative&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; use relative path names&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; -H, --hard-links&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; preserve hard links&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; -S, --sparse&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; handle sparse files efficiently&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; -x, --one-file-system&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; don't cross file system boundaries&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp;&amp;nbsp; --exclude=PATTERN&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; exclude files matching PATTERN&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp;&amp;nbsp; --delete-during&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; receiver deletes during xfer, not before&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp;&amp;nbsp; --delete-after&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; receiver deletes after transfer, not before&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Rsync on Windows&lt;br /&gt;
&lt;br /&gt;
Rsync is available for Windows through cygwin or as stand-alone packaged in cwrsynchttp://sourceforge.net/projects/sereds. This is very convenient for automated backups. Install one of them (not both) and add the path to the Windows system variables: # Control Panel -&amp;gt; System -&amp;gt; tab Advanced, button Environment Variables. Edit the "Path" system variable and add the full path to the installed rsync, e.g. C:\Program Files\cwRsync\bin or C:\cygwin\bin. This way the commands rsync and ssh are available in a Windows command shell.&lt;br /&gt;
Public key authentication&lt;br /&gt;
&lt;br /&gt;
Rsync is automatically tunneled over SSH and thus uses the SSH authentication on the server. Automatic backups have to avoid a user interaction, for this the SSH public key authentication can be used and the rsync command will run without a password.&lt;br /&gt;
&lt;br /&gt;
All the following commands are executed within a Windows console. In a console (Start -&amp;gt; Run -&amp;gt; cmd) create and upload the key as described in SSH, change "user" and "server" as appropriate. If the file authorized_keys2 does not exist yet, simply copy id_dsa.pub to authorized_keys2 and upload it.&lt;br /&gt;
&lt;br /&gt;
# ssh-keygen -t dsa -N ''&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Creates a public and a private key&lt;br /&gt;
# rsync user@server:.ssh/authorized_keys2 . # Copy the file locally from the server&lt;br /&gt;
# cat id_dsa.pub &amp;gt;&amp;gt; authorized_keys2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Or use an editor to add the key&lt;br /&gt;
# rsync authorized_keys2 user@server:.ssh/&amp;nbsp; # Copy the file back to the server&lt;br /&gt;
# del authorized_keys2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Remove the local copy&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now test it with (in one line):&lt;br /&gt;
&lt;br /&gt;
rsync -rv "/cygdrive/c/Documents and Settings/%USERNAME%/My Documents/" \&lt;br /&gt;
'user@server:My\ Documents/'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Automatic backup&lt;br /&gt;
&lt;br /&gt;
Use a batch file to automate the backup and add the file in the scheduled tasks (Programs -&amp;gt; Accessories -&amp;gt; System Tools -&amp;gt; Scheduled Tasks). For example create the file backup.bat and replace user@server.&lt;br /&gt;
&lt;br /&gt;
@ECHO OFF&lt;br /&gt;
REM rsync the directory My Documents&lt;br /&gt;
SETLOCAL&lt;br /&gt;
SET CWRSYNCHOME=C:\PROGRAM FILES\CWRSYNC&lt;br /&gt;
SET CYGWIN=nontsec&lt;br /&gt;
SET CWOLDPATH=%PATH%&lt;br /&gt;
REM uncomment the next line when using cygwin&lt;br /&gt;
SET PATH=%CWRSYNCHOME%\BIN;%PATH%&lt;br /&gt;
echo Press Control-C to abort&lt;br /&gt;
rsync -av "/cygdrive/c/Documents and Settings/%USERNAME%/My Documents/" \&lt;br /&gt;
'user@server:My\ Documents/'&lt;br /&gt;
pause&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
SUDO&lt;br /&gt;
&lt;br /&gt;
Sudo is a standard way to give users some administrative rights without giving out the root password. Sudo is very useful in a multi user environment with a mix of server and workstations. Simply call the command with sudo:&lt;br /&gt;
&lt;br /&gt;
# sudo /etc/init.d/dhcpd restart&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Run the rc script as root&lt;br /&gt;
# sudo -u sysadmin whoami&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Run cmd as an other user&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Configuration&lt;br /&gt;
&lt;br /&gt;
Sudo is configured in /etc/sudoers and must only be edited with visudo. The basic syntax is (the lists are comma separated):&lt;br /&gt;
&lt;br /&gt;
user hosts = (runas) commands&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # In /etc/sudoers&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; users one or more users or %group (like %wheel) to gain the rights&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; hosts list of hosts (or ALL)&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; runas list of users (or ALL) that the command rule can be run as. It is enclosed in ( )!&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; commands list of commands (or ALL) that will be run as root or as (runas)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Additionally those keywords can be defined as alias, they are called User_Alias, Host_Alias, Runas_Alias and Cmnd_Alias. This is useful for larger setups. Here a sudoers example:&lt;br /&gt;
&lt;br /&gt;
# cat /etc/sudoers&lt;br /&gt;
# Host aliases are subnets or hostnames.&lt;br /&gt;
Host_Alias&amp;nbsp;&amp;nbsp; DMZ&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = 212.118.81.40/28&lt;br /&gt;
Host_Alias&amp;nbsp;&amp;nbsp; DESKTOP = work1, work2&lt;br /&gt;
&lt;br /&gt;
# User aliases are a list of users which can have the same rights&lt;br /&gt;
User_Alias&amp;nbsp;&amp;nbsp; ADMINS&amp;nbsp; = colin, luca, admin&lt;br /&gt;
User_Alias&amp;nbsp;&amp;nbsp; DEVEL&amp;nbsp;&amp;nbsp; = joe, jack, julia&lt;br /&gt;
Runas_Alias&amp;nbsp; DBA&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = oracle,pgsql&lt;br /&gt;
&lt;br /&gt;
# Command aliases define the full path of a list of commands&lt;br /&gt;
Cmnd_Alias&amp;nbsp;&amp;nbsp; SYSTEM&amp;nbsp; = /sbin/reboot,/usr/bin/kill,/sbin/halt,/sbin/shutdown,/etc/init.d/&lt;br /&gt;
Cmnd_Alias&amp;nbsp;&amp;nbsp; PW&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = /usr/bin/passwd [A-z]*, !/usr/bin/passwd root # Not root pwd!&lt;br /&gt;
Cmnd_Alias&amp;nbsp;&amp;nbsp; DEBUG&amp;nbsp;&amp;nbsp; = /usr/sbin/tcpdump,/usr/bin/wireshark,/usr/bin/nmap&lt;br /&gt;
&lt;br /&gt;
# The actual rules&lt;br /&gt;
root,ADMINS&amp;nbsp; ALL&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = (ALL) NOPASSWD: ALL&amp;nbsp;&amp;nbsp;&amp;nbsp; # ADMINS can do anything w/o a password.&lt;br /&gt;
DEVEL&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DESKTOP = (ALL) NOPASSWD: ALL&amp;nbsp;&amp;nbsp;&amp;nbsp; # Developers have full right on desktops&lt;br /&gt;
DEVEL&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DMZ&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = (ALL) NOPASSWD: DEBUG&amp;nbsp; # Developers can debug the DMZ servers.&lt;br /&gt;
&lt;br /&gt;
# User sysadmin can mess around in the DMZ servers with some commands.&lt;br /&gt;
sysadmin&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DMZ&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = (ALL) NOPASSWD: SYSTEM,PW,DEBUG&lt;br /&gt;
sysadmin&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ALL,!DMZ = (ALL) NOPASSWD: ALL&amp;nbsp;&amp;nbsp; # Can do anything outside the DMZ.&lt;br /&gt;
%dba&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ALL&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = (DBA) ALL&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Group dba can run as database user.&lt;br /&gt;
&lt;br /&gt;
# anyone can mount/unmount a cd-rom on the desktop machines&lt;br /&gt;
ALL&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DESKTOP = NOPASSWD: /sbin/mount /cdrom,/sbin/umount /cdrom&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Encrypt Files&lt;br /&gt;
&lt;br /&gt;
OpenSSL&lt;br /&gt;
&lt;br /&gt;
A single file&lt;br /&gt;
&lt;br /&gt;
Encrypt and decrypt:&lt;br /&gt;
&lt;br /&gt;
# openssl aes-128-cbc -salt -in file -out file.aes&lt;br /&gt;
# openssl aes-128-cbc -d -salt -in file.aes -out file&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note that the file can of course be a tar archive.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &lt;br /&gt;
tar and encrypt a whole directory&lt;br /&gt;
&lt;br /&gt;
# tar -cf - directory | openssl aes-128-cbc -salt -out directory.tar.aes&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Encrypt&lt;br /&gt;
# openssl aes-128-cbc -d -salt -in directory.tar.aes | tar -x -f -&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Decrypt&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &lt;br /&gt;
tar zip and encrypt a whole directory&lt;br /&gt;
&lt;br /&gt;
# tar -zcf - directory | openssl aes-128-cbc -salt -out directory.tar.gz.aes&amp;nbsp; # Encrypt&lt;br /&gt;
# openssl aes-128-cbc -d -salt -in directory.tar.gz.aes | tar -xz -f -&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Decrypt&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; * Use -k mysecretpassword after aes-128-cbc to avoid the interactive password request. However note that this is highly insecure.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; * Use aes-256-cbc instead of aes-128-cbc to get even stronger encryption. This uses also more CPU.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
GPG&lt;br /&gt;
&lt;br /&gt;
GnuPG is well known to encrypt and sign emails or any data. Furthermore gpg and also provides an advanced key management system. This section only covers files encryption, not email usage, signing or the Web-Of-Trust.&lt;br /&gt;
&lt;br /&gt;
The simplest encryption is with a symmetric cipher. In this case the file is encrypted with a password and anyone who knows the password can decrypt it, thus the keys are not needed. Gpg adds an extention ".gpg" to the encrypted file names.&lt;br /&gt;
&lt;br /&gt;
# gpg -c file&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Encrypt file with password&lt;br /&gt;
# gpg file.gpg&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Decrypt file (optionally -o otherfile)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Using keys&lt;br /&gt;
&lt;br /&gt;
For more details see GPG Quick Starthttp://www.madboa.com/geek/gpg-quickstart and GPG/PGP Basicshttp://aplawrence.com/Basics/gpg.html and the gnupg documentationhttp://gnupg.org/documentation among others.&lt;br /&gt;
&lt;br /&gt;
The private and public keys are the heart of asymmetric cryptography. What is important to remember:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; * Your public key is used by others to encrypt files that only you as the receiver can decrypt (not even the one who encrypted the file can decrypt it). The public key is thus meant to be distributed.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; * Your private key is encrypted with your passphrase and is used to decrypt files which were encrypted with your public key. The private key must be kept secure. Also if the key or passphrase is lost, so are all the files encrypted with your public key.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; * The key files are called keyrings as they can contain more than one key.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
First generate a key pair. The defaults are fine, however you will have to enter at least your full name and email and optionally a comment. The comment is useful to create more than one key with the same name and email. Also you should use a "passphrase", not a simple password.&lt;br /&gt;
&lt;br /&gt;
# gpg --gen-key&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # This can take a long time&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The keys are stored in ~/.gnupg/ on Unix, on Windows they are typically stored in&lt;br /&gt;
&lt;br /&gt;
C:/Documents and Settings/%USERNAME%/Application Data/gnupg/.&lt;br /&gt;
&lt;br /&gt;
~/.gnupg/pubring.gpg&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Contains your public keys and all others imported&lt;br /&gt;
~/.gnupg/secring.gpg&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Can contain more than one private key&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Short reminder on most used options:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; -e encrypt data&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; -d decrypt data&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; -r NAME encrypt for recipient NAME (or 'Full Name' or 'email@domain')&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; -a create ascii armored output of a key&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; -o use as output file&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The examples use 'Your Name' and 'Alice' as the keys are referred to by the email or full name or partial name. For example I can use 'Colin' or 'c@cb.vu' for my key [Colin Barschel (cb.vu) &amp;lt;c@cb.vu&amp;gt;].&lt;br /&gt;
Encrypt for personal use only&lt;br /&gt;
&lt;br /&gt;
No need to export/import any key for this. You have both already.&lt;br /&gt;
&lt;br /&gt;
# gpg -e -r 'Your Name' file&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Encrypt with your public key&lt;br /&gt;
# gpg -o file -d file.gpg&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Decrypt. Use -o or it goes to stdout&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Encrypt - Decrypt with keys&lt;br /&gt;
&lt;br /&gt;
First you need to export your public key for someone else to use it. And you need to import the public say from Alice to encrypt a file for her. You can either handle the keys in simple ascii files or use a public key server.&lt;br /&gt;
&lt;br /&gt;
For example Alice export her public key and you import it, you can then encrypt a file for her. That is only Alice will be able to decrypt it.&lt;br /&gt;
&lt;br /&gt;
# gpg -a -o alicekey.asc --export 'Alice'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Alice exported her key in ascii file.&lt;br /&gt;
# gpg --send-keys --keyserver subkeys.pgp.net KEYID&amp;nbsp;&amp;nbsp; # Alice put her key on a server.&lt;br /&gt;
# gpg --import alicekey.asc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # You import her key into your pubring.&lt;br /&gt;
# gpg --search-keys --keyserver subkeys.pgp.net 'Alice' # or get her key from a server.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Once the keys are imported it is very easy to encrypt or decrypt a file:&lt;br /&gt;
&lt;br /&gt;
# gpg -e -r 'Alice' file&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Encrypt the file for Alice.&lt;br /&gt;
# gpg -d file.gpg -o file&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Decrypt a file encrypted by Alice for you.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Key administration&lt;br /&gt;
&lt;br /&gt;
# gpg --list-keys&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # list public keys and see the KEYIDS&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; The KEYID follows the '/' e.g. for: pub&amp;nbsp;&amp;nbsp; 1024D/D12B77CE the KEYID is D12B77CE&lt;br /&gt;
# gpg --gen-revoke 'Your Name'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # generate revocation certificate&lt;br /&gt;
# gpg --list-secret-keys&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # list private keys&lt;br /&gt;
# gpg --delete-keys NAME&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # delete a public key from local key ring&lt;br /&gt;
# gpg --delete-secret-key NAME&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # delete a secret key from local key ring&lt;br /&gt;
# gpg --fingerprint KEYID&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Show the fingerprint of the key&lt;br /&gt;
# gpg --edit-key KEYID&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Edit key (e.g sign or add/del email)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Encrypt Partitions&lt;br /&gt;
&lt;br /&gt;
Linux with LUKS | Linux dm-crypt only | FreeBSD GELI | FBSD pwd only | OS X image&lt;br /&gt;
&lt;br /&gt;
There are (many) other alternative methods to encrypt disks, I only show here the methods I know and use. Keep in mind that the security is only good as long the OS has not been tempered with. An intruder could easily record the password from the keyboard events. Furthermore the data is freely accessible when the partition is attached and will not prevent an intruder to have access to it in this state.&lt;br /&gt;
Linux&lt;br /&gt;
&lt;br /&gt;
Those instructions use the Linux dm-crypt (device-mapper) facility available on the 2.6 kernel. In this example, lets encrypt the partition /dev/sdc1, it could be however any other partition or disk, or USB or a file based partition created with losetup. In this case we would use /dev/loop0. See file image partition. The device mapper uses labels to identify a partition. We use sdc1 in this example, but it could be any string.&lt;br /&gt;
dm-crypt with LUKS&lt;br /&gt;
&lt;br /&gt;
LUKS with dm-crypt has better encryption and makes it possible to have multiple passphrase for the same partition or to change the password easily. To test if LUKS is available, simply type # cryptsetup --help, if nothing about LUKS shows up, use the instructions below Without LUKS. First create a partition if necessary: fdisk /dev/sdc.&lt;br /&gt;
Create encrypted partition&lt;br /&gt;
&lt;br /&gt;
# dd if=/dev/urandom of=/dev/sdc1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Optional. For paranoids only (takes days)&lt;br /&gt;
# cryptsetup -y luksFormat /dev/sdc1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # This destroys any data on sdc1&lt;br /&gt;
# cryptsetup luksOpen /dev/sdc1 sdc1&lt;br /&gt;
# mkfs.ext3 /dev/mapper/sdc1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # create ext3 file system&lt;br /&gt;
# mount -t ext3 /dev/mapper/sdc1 /mnt&lt;br /&gt;
# umount /mnt&lt;br /&gt;
# cryptsetup luksClose sdc1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Detach the encrypted partition&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Attach&lt;br /&gt;
&lt;br /&gt;
# cryptsetup luksOpen /dev/sdc1 sdc1&lt;br /&gt;
# mount -t ext3 /dev/mapper/sdc1 /mnt&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Detach&lt;br /&gt;
&lt;br /&gt;
# umount /mnt&lt;br /&gt;
# cryptsetup luksClose sdc1&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
dm-crypt without LUKS&lt;br /&gt;
&lt;br /&gt;
# cryptsetup -y create sdc1 /dev/sdc1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # or any other partition like /dev/loop0&lt;br /&gt;
# dmsetup ls&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # check it, will display: sdc1 (254, 0)&lt;br /&gt;
# mkfs.ext3 /dev/mapper/sdc1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # This is done only the first time!&lt;br /&gt;
# mount -t ext3 /dev/mapper/sdc1 /mnt&lt;br /&gt;
# umount /mnt/&lt;br /&gt;
# cryptsetup remove sdc1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Detach the encrypted partition&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Do exactly the same (without the mkfs part!) to re-attach the partition. If the password is not correct, the mount command will fail. In this case simply remove the map sdc1 (cryptsetup remove sdc1) and create it again.&lt;br /&gt;
FreeBSD&lt;br /&gt;
&lt;br /&gt;
The two popular FreeBSD disk encryption modules are gbde and geli. I now use geli because it is faster and also uses the crypto device for hardware acceleration. See The FreeBSD handbook Chapter 18.6http://www.freebsd.org/handbook/disks-encrypting.html for all the details. The geli module must be loaded or compiled into the kernel:&lt;br /&gt;
&lt;br /&gt;
options GEOM_ELI&lt;br /&gt;
device crypto&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # or as module:&lt;br /&gt;
# echo 'geom_eli_load="YES"' &amp;gt;&amp;gt; /boot/loader.conf&amp;nbsp;&amp;nbsp; # or do: kldload geom_eli&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Use password and key&lt;br /&gt;
&lt;br /&gt;
I use those settings for a typical disk encryption, it uses a passphrase AND a key to encrypt the master key. That is you need both the password and the generated key /root/ad1.key to attach the partition. The master key is stored inside the partition and is not visible. See below for typical USB or file based image.&lt;br /&gt;
Create encrypted partition&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# dd if=/dev/random of=/root/ad1.key bs=64 count=1&amp;nbsp; # this key encrypts the mater key&lt;br /&gt;
# geli init -s 4096 -K /root/ad1.key /dev/ad1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # -s 8192 is also OK for disks&lt;br /&gt;
# geli attach -k /root/ad1.key /dev/ad1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # DO make a backup of /root/ad1.key&lt;br /&gt;
# dd if=/dev/random of=/dev/ad1.eli bs=1m&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Optional and takes a long time&lt;br /&gt;
# newfs /dev/ad1.eli&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Create file system&lt;br /&gt;
# mount /dev/ad1.eli /mnt&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Attach&lt;br /&gt;
&lt;br /&gt;
# geli attach -k /root/ad1.key /dev/ad1&lt;br /&gt;
# fsck -ny -t ffs /dev/ad1.eli&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # In doubt check the file system&lt;br /&gt;
# mount /dev/ad1.eli /mnt&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Detach&lt;br /&gt;
&lt;br /&gt;
The detach procedure is done automatically on shutdown.&lt;br /&gt;
&lt;br /&gt;
# umount /mnt&lt;br /&gt;
# geli detach /dev/ad1.eli&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/etc/fstab&lt;br /&gt;
&lt;br /&gt;
The encrypted partition can be configured to be mounted with /etc/fstab. The password will be prompted when booting. The following settings are required for this example:&lt;br /&gt;
&lt;br /&gt;
# grep geli /etc/rc.conf&lt;br /&gt;
geli_devices="ad1"&lt;br /&gt;
geli_ad1_flags="-k /root/ad1.key"&lt;br /&gt;
# grep geli /etc/fstab&lt;br /&gt;
/dev/ad1.eli&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /home/private&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ufs&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rw&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Use password only&lt;br /&gt;
&lt;br /&gt;
It is more convenient to encrypt a USB stick or file based image with a passphrase only and no key. In this case it is not necessary to carry the additional key file around. The procedure is very much the same as above, simply without the key file. Let's encrypt a file based image /cryptedfile of 1 GB.&lt;br /&gt;
&lt;br /&gt;
# dd if=/dev/zero of=/cryptedfile bs=1M count=1000&amp;nbsp; # 1 GB file&lt;br /&gt;
# mdconfig -at vnode -f /cryptedfile&lt;br /&gt;
# geli init /dev/md0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # encrypts with password only&lt;br /&gt;
# geli attach /dev/md0&lt;br /&gt;
# newfs -U -m 0 /dev/md0.eli&lt;br /&gt;
# mount /dev/md0.eli /mnt&lt;br /&gt;
# umount /dev/md0.eli&lt;br /&gt;
# geli detach md0.eli&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It is now possible to mount this image on an other system with the password only.&lt;br /&gt;
&lt;br /&gt;
# mdconfig -at vnode -f /cryptedfile&lt;br /&gt;
# geli attach /dev/md0&lt;br /&gt;
# mount /dev/md0.eli /mnt&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
OS X Encrypted Disk Image&lt;br /&gt;
&lt;br /&gt;
Don't know by command line only. See OS X Encrypted Disk Imagehttps://wiki.thayer.dartmouth.edu/display/computing/Creating+a+Mac+OS+X+Encrypted+Disk+Image and Apple supporthttp://support.apple.com/kb/ht1578&lt;br /&gt;
&lt;br /&gt;
SSL Certificates&lt;br /&gt;
&lt;br /&gt;
So called SSL/TLS certificates are cryptographic public key certificates and are composed of a public and a private key. The certificates are used to authenticate the endpoints and encrypt the data. They are used for example on a web server (https) or mail server (imaps).&lt;br /&gt;
Procedure&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; * We need a certificate authority to sign our certificate. This step is&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; usually provided by a vendor like Thawte, Verisign, etc., however we can also create our own.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; * Create a certificate signing request. This request is like an unsigned certificate (the public part) and already contains all necessary information. The certificate request is normally sent to the authority vendor for signing. This step also creates the private key on the local machine.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; * Sign the certificate with the certificate authority.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; * If necessary join the certificate and the key in a single file to be used by the application (web server, mail server etc.).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Configure OpenSSL&lt;br /&gt;
&lt;br /&gt;
We use /usr/local/certs as directory for this example check or edit /etc/ssl/openssl.cnf accordingly to your settings so you know where the files will be created. Here are the relevant part of openssl.cnf:&lt;br /&gt;
&lt;br /&gt;
[ CA_default ]&lt;br /&gt;
dir&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = /usr/local/certs/CA&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Where everything is kept&lt;br /&gt;
certs&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = $dir/certs&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Where the issued certs are kept&lt;br /&gt;
crl_dir&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = $dir/crl&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Where the issued crl are kept&lt;br /&gt;
database&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = $dir/index.txt&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # database index file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Make sure the directories exist or create them&lt;br /&gt;
&lt;br /&gt;
# mkdir -p /usr/local/certs/CA&lt;br /&gt;
# cd /usr/local/certs/CA&lt;br /&gt;
# mkdir certs crl newcerts private&lt;br /&gt;
# echo "01" &amp;gt; serial&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Only if serial does not exist&lt;br /&gt;
# touch index.txt&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you intend to get a signed certificate from a vendor, you only need a certificate signing request (CSR). This CSR will then be signed by the vendor for a limited time (e.g. 1 year).&lt;br /&gt;
Create a certificate authority&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you do not have a certificate authority from a vendor, you'll have to create your own. This step is not necessary if one intend to use a vendor to sign the request. To make a certificate authority (CA):&lt;br /&gt;
&lt;br /&gt;
# openssl req -new -x509 -days 730 -config /etc/ssl/openssl.cnf \&lt;br /&gt;
-keyout CA/private/cakey.pem -out CA/cacert.pem&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Create a certificate signing request&lt;br /&gt;
&lt;br /&gt;
To make a new certificate (for mail server or web server for example), first create a request certificate with its private key. If your application do not support encrypted private key (for example UW-IMAP does not), then disable encryption with -nodes.&lt;br /&gt;
&lt;br /&gt;
# openssl req -new -keyout newkey.pem -out newreq.pem \&lt;br /&gt;
-config /etc/ssl/openssl.cnf&lt;br /&gt;
# openssl req -nodes -new -keyout newkey.pem -out newreq.pem \&lt;br /&gt;
-config /etc/ssl/openssl.cnf&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # No encryption for the key&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Keep this created CSR (newreq.pem) as it can be signed again at the next renewal, the signature onlt will limit the validity of the certificate. This process also created the private key newkey.pem.&lt;br /&gt;
&lt;br /&gt;
Sign the certificate&lt;br /&gt;
&lt;br /&gt;
The certificate request has to be signed by the CA to be valid, this step is usually done by the vendor. Note: replace "servername" with the name of your server in the next commands.&lt;br /&gt;
&lt;br /&gt;
# cat newreq.pem newkey.pem &amp;gt; new.pem&lt;br /&gt;
# openssl ca -policy policy_anything -out servernamecert.pem \&lt;br /&gt;
-config /etc/ssl/openssl.cnf -infiles new.pem&lt;br /&gt;
# mv newkey.pem servernamekey.pem&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now servernamekey.pem is the private key and servernamecert.pem is the server certificate.&lt;br /&gt;
&lt;br /&gt;
Create united certificate&lt;br /&gt;
&lt;br /&gt;
The IMAP server wants to have both private key and server certificate in the same file. And in general, this is also easier to handle, but the file has to be kept securely!. Apache also can deal with it well. Create a file servername.pem containing both the certificate and key.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; Open the private key (servernamekey.pem) with a text editor and copy the private key into the "servername.pem" file.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; Do the same with the server certificate (servernamecert.pem).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The final servername.pem file should look like this:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-----BEGIN RSA PRIVATE KEY-----&lt;br /&gt;
MIICXQIBAAKBgQDutWy+o/XZ/[...]qK5LqQgT3c9dU6fcR+WuSs6aejdEDDqBRQ&lt;br /&gt;
-----END RSA PRIVATE KEY-----&lt;br /&gt;
-----BEGIN CERTIFICATE-----&lt;br /&gt;
MIIERzCCA7CgAwIBAgIBBDANB[...]iG9w0BAQQFADCBxTELMAkGA1UEBhMCREUx&lt;br /&gt;
-----END CERTIFICATE-----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What we have now in the directory /usr/local/certs/:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; CA/private/cakey.pem (CA server private key)&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; CA/cacert.pem (CA server public key)&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; certs/servernamekey.pem (server private key)&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; certs/servernamecert.pem (server signed certificate)&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; certs/servername.pem (server certificate with private key)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Keep the private key secure!&lt;br /&gt;
&lt;br /&gt;
View certificate information&lt;br /&gt;
&lt;br /&gt;
To view the certificate information simply do:&lt;br /&gt;
&lt;br /&gt;
# openssl x509 -text -in servernamecert.pem&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # View the certificate info&lt;br /&gt;
# openssl req -noout -text -in server.csr&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # View the request info&lt;br /&gt;
# openssl s_client -connect cb.vu:443&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Check a web server certificate&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CVS&lt;br /&gt;
&lt;br /&gt;
Server setup | CVS test | SSH tunneling | CVS usage&lt;br /&gt;
&lt;br /&gt;
Server setup&lt;br /&gt;
&lt;br /&gt;
Initiate the CVS&lt;br /&gt;
&lt;br /&gt;
Decide where the main repository will rest and create a root cvs. For example /usr/local/cvs (as root):&lt;br /&gt;
&lt;br /&gt;
# mkdir -p /usr/local/cvs&lt;br /&gt;
# setenv CVSROOT /usr/local/cvs&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Set CVSROOT to the new location (local)&lt;br /&gt;
# cvs init&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Creates all internal CVS config files&lt;br /&gt;
# cd /root&lt;br /&gt;
# cvs checkout CVSROOT&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Checkout the config files to modify them&lt;br /&gt;
# cd CVSROOT&lt;br /&gt;
edit config ( fine as it is)&lt;br /&gt;
# cvs commit config&lt;br /&gt;
cat &amp;gt;&amp;gt; writers&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Create a writers file (optionally also readers)&lt;br /&gt;
colin&lt;br /&gt;
^D&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Use [Control][D] to quit the edit&lt;br /&gt;
# cvs add writers&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Add the file writers into the repository&lt;br /&gt;
# cvs edit checkoutlist&lt;br /&gt;
# cat &amp;gt;&amp;gt; checkoutlist&lt;br /&gt;
writers&lt;br /&gt;
^D&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Use [Control][D] to quit the edit&lt;br /&gt;
# cvs commit&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Commit all the configuration changes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Add a readers file if you want to differentiate read and write permissions Note: Do not (ever) edit files directly into the main cvs, but rather checkout the file, modify it and check it in. We did this with the file writers to define the write access.&lt;br /&gt;
&lt;br /&gt;
There are three popular ways to access the CVS at this point. The first two don't need any further configuration. See the examples on CVSROOT below for how to use them:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; Direct local access to the file system. The user(s) need sufficient file permission to access the CS directly and there is no further authentication in addition to the OS login. However this is only useful if the repository is local.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; Remote access with ssh with the ext protocol. Any use with an ssh shell account and read/write permissions on the CVS server can access the CVS directly with ext over ssh without any additional tunnel. There is no server process running on the CVS for this to work. The ssh login does the authentication.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; Remote access with pserver (default port: 2401/tcp). This is the preferred use for larger user base as the users are authenticated by the CVS pserver with a dedicated password database, there is therefore no need for local users accounts. This setup is explained below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Network setup with inetd&lt;br /&gt;
&lt;br /&gt;
The CVS can be run locally only if a network access is not needed. For a remote access, the daemon inetd can start the pserver with the following line in /etc/inetd.conf (/etc/xinetd.d/cvs on SuSE):&lt;br /&gt;
&lt;br /&gt;
cvspserver&amp;nbsp;&amp;nbsp; &amp;nbsp;stream&amp;nbsp; tcp&amp;nbsp; nowait&amp;nbsp; cvs&amp;nbsp; /usr/bin/cvs&amp;nbsp;&amp;nbsp; &amp;nbsp;cvs \&lt;br /&gt;
--allow-root=/usr/local/cvs pserver&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It is a good idea to block the cvs port from the Internet with the firewall and use an ssh tunnel to access the repository remotely.&lt;br /&gt;
&lt;br /&gt;
Separate authentication&lt;br /&gt;
&lt;br /&gt;
It is possible to have cvs users which are not part of the OS (no local users). This is actually probably wanted too from the security point of view. Simply add a file named passwd (in the CVSROOT directory) containing the users login and password in the crypt format. This is can be done with the apache htpasswd tool.&lt;br /&gt;
&lt;br /&gt;
Note: This passwd file is the only file which has to be edited directly in the CVSROOT directory. Also it won't be checked out. More info with htpasswd --help&lt;br /&gt;
&lt;br /&gt;
# htpasswd -cb passwd user1 password1&amp;nbsp; # -c creates the file&lt;br /&gt;
# htpasswd -b passwd user2 password2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now add :cvs at the end of each line to tell the cvs server to change the user to cvs (or whatever your cvs server is running under). It looks like this:&lt;br /&gt;
&lt;br /&gt;
# cat passwd&lt;br /&gt;
user1:xsFjhU22u8Fuo:cvs&lt;br /&gt;
user2:vnefJOsnnvToM:cvs&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Test it&lt;br /&gt;
&lt;br /&gt;
Test the login as normal user (for example here me)&lt;br /&gt;
&lt;br /&gt;
# cvs -d :pserver:colin@192.168.50.254:/usr/local/cvs login&lt;br /&gt;
Logging in to :pserver:colin@192.168.50.254:2401/usr/local/cvs&lt;br /&gt;
CVS password:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CVSROOT variable&lt;br /&gt;
&lt;br /&gt;
This is an environment variable used to specify the location of the repository we're doing operations on. For local use, it can be just set to the directory of the repository. For use over the network, the transport protocol must be specified. Set the CVSROOT variable with setenv CVSROOT string on a csh, tcsh shell, or with export CVSROOT=string on a sh, bash shell.&lt;br /&gt;
&lt;br /&gt;
# setenv CVSROOT :pserver:&amp;lt;username&amp;gt;@&amp;lt;host&amp;gt;:/cvsdirectory&lt;br /&gt;
For example:&lt;br /&gt;
# setenv CVSROOT /usr/local/cvs&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Used locally only&lt;br /&gt;
# setenv CVSROOT :local:/usr/local/cvs&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Same as above&lt;br /&gt;
# setenv CVSROOT :ext:user@cvsserver:/usr/local/cvs&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Direct access with SSH&lt;br /&gt;
# setenv CVS_RSH ssh&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # for the ext access&lt;br /&gt;
# setenv CVSROOT :pserver:user@cvsserver.254:/usr/local/cvs&amp;nbsp;&amp;nbsp; # network with pserver&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When the login succeeded one can import a new project into the repository:&lt;br /&gt;
cd into your project root directory&lt;br /&gt;
&lt;br /&gt;
cvs import &amp;lt;module name&amp;gt; &amp;lt;vendor tag&amp;gt; &amp;lt;initial tag&amp;gt;&lt;br /&gt;
cvs -d :pserver:colin@192.168.50.254:/usr/local/cvs import MyProject MyCompany START&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Where MyProject is the name of the new project in the repository (used later to checkout). Cvs will import the current directory content into the new project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To checkout:&lt;br /&gt;
&lt;br /&gt;
# cvs -d :pserver:colin@192.168.50.254:/usr/local/cvs checkout MyProject&lt;br /&gt;
or&lt;br /&gt;
# setenv CVSROOT :pserver:colin@192.168.50.254:/usr/local/cvs&lt;br /&gt;
# cvs checkout MyProject&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
SSH tunneling for CVS&lt;br /&gt;
&lt;br /&gt;
We need 2 shells for this. On the first shell we connect to the cvs server with ssh and port-forward the cvs connection. On the second shell we use the cvs normally as if it where running locally.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
on shell 1:&lt;br /&gt;
&lt;br /&gt;
# ssh -L2401:localhost:2401 colin@cvs_server&amp;nbsp;&amp;nbsp; # Connect directly to the CVS server. Or:&lt;br /&gt;
# ssh -L2401:cvs_server:2401 colin@gateway&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Use a gateway to reach the CVS&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
on shell 2:&lt;br /&gt;
&lt;br /&gt;
# setenv CVSROOT :pserver:colin@localhost:/usr/local/cvs&lt;br /&gt;
# cvs login&lt;br /&gt;
Logging in to :pserver:colin@localhost:2401/usr/local/cvs&lt;br /&gt;
CVS password:&lt;br /&gt;
# cvs checkout MyProject/src&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CVS commands and usage&lt;br /&gt;
&lt;br /&gt;
Import&lt;br /&gt;
&lt;br /&gt;
The import command is used to add a whole directory, it must be run from within the directory to be imported. Say the directory /devel/ contains all files and subdirectories to be imported. The directory name on the CVS (the module) will be called "myapp".&lt;br /&gt;
&lt;br /&gt;
# cvs import [options] directory-name vendor-tag release-tag&lt;br /&gt;
# cd /devel&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Must be inside the project to import it&lt;br /&gt;
# cvs import myapp Company R1_0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Release tag can be anything in one word&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After a while a new directory "/devel/tools/" was added and it has to be imported too.&lt;br /&gt;
&lt;br /&gt;
# cd /devel/tools&lt;br /&gt;
# cvs import myapp/tools Company R1_0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Checkout update add commit&lt;br /&gt;
&lt;br /&gt;
# cvs co myapp/tools&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Will only checkout the directory tools&lt;br /&gt;
# cvs co -r R1_1 myapp&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Checkout myapp at release R1_1 (is sticky)&lt;br /&gt;
# cvs -q -d update -P&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # A typical CVS update&lt;br /&gt;
# cvs update -A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Reset any sticky tag (or date, option)&lt;br /&gt;
# cvs add newfile&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Add a new file&lt;br /&gt;
# cvs add -kb newfile&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Add a new binary file&lt;br /&gt;
# cvs commit file1 file2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Commit the two files only&lt;br /&gt;
# cvs commit -m "message"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Commit all changes done with a message&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Create a patch&lt;br /&gt;
&lt;br /&gt;
It is best to create and apply a patch from the working development directory related to the project, or from within the source directory.&lt;br /&gt;
&lt;br /&gt;
# cd /devel/project&lt;br /&gt;
# diff -Naur olddir newdir &amp;gt; patchfile # Create a patch from a directory or a file&lt;br /&gt;
# diff -Naur oldfile newfile &amp;gt; patchfile&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Apply a patch&lt;br /&gt;
&lt;br /&gt;
Sometimes it is necessary to strip a directory level from the patch, depending how it was created. In case of difficulties, simply look at the first lines of the patch and try -p0, -p1 or -p2.&lt;br /&gt;
&lt;br /&gt;
# cd /devel/project&lt;br /&gt;
# patch --dry-run -p0 &amp;lt; patchfile&amp;nbsp;&amp;nbsp;&amp;nbsp; # Test the path without applying it&lt;br /&gt;
# patch -p0 &amp;lt; patchfile&lt;br /&gt;
# patch -p1 &amp;lt; patchfile&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # strip off the 1st level from the path&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
SVN&lt;br /&gt;
&lt;br /&gt;
Server setup | SVN+SSH | SVN over http | SVN usage&lt;br /&gt;
&lt;br /&gt;
Subversion (SVN)http://subversion.tigris.org/ is a version control system designed to be the successor of CVS (Concurrent Versions System). The concept is similar to CVS, but many shortcomings where improved. See also the SVN bookhttp://svnbook.red-bean.com/en/1.4/.&lt;br /&gt;
Server setup&lt;br /&gt;
&lt;br /&gt;
The initiation of the repository is fairly simple (here for example /home/svn/ must exist):&lt;br /&gt;
&lt;br /&gt;
# svnadmin create --fs-type fsfs /home/svn/project1&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now the access to the repository is made possible with:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; file:// Direct file system access with the svn client with. This requires local permissions on the file system.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; svn:// or svn+ssh:// Remote access with the svnserve server (also over SSH). This requires local permissions on the file system (default port: 2690/tcp).&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; http:// Remote access with webdav using apache. No local users are necessary for this method.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Using the local file system, it is now possible to import and then check out an existing project. Unlike with CVS it is not necessary to cd into the project directory, simply give the full path:&lt;br /&gt;
&lt;br /&gt;
# svn import /project1/ file:///home/svn/project1/trunk -m 'Initial import'&lt;br /&gt;
# svn checkout file:///home/svn/project1&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The new directory "trunk" is only a convention, this is not required.&lt;br /&gt;
Remote access with ssh&lt;br /&gt;
&lt;br /&gt;
No special setup is required to access the repository via ssh, simply replace file:// with svn+ssh/hostname. For example:&lt;br /&gt;
&lt;br /&gt;
# svn checkout svn+ssh://hostname/home/svn/project1&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As with the local file access, every user needs an ssh access to the server (with a local account) and also read/write access. This method might be suitable for a small group. All users could belong to a subversion group which owns the repository, for example:&lt;br /&gt;
&lt;br /&gt;
# groupadd subversion&lt;br /&gt;
# groupmod -A user1 subversion&lt;br /&gt;
# chown -R root:subversion /home/svn&lt;br /&gt;
# chmod -R 770 /home/svn&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Remote access with http (apache)&lt;br /&gt;
&lt;br /&gt;
Remote access over http (https) is the only good solution for a larger user group. This method uses the apache authentication, not the local accounts. This is a typical but small apache configuration:&lt;br /&gt;
&lt;br /&gt;
LoadModule dav_module&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; modules/mod_dav.so&lt;br /&gt;
LoadModule dav_svn_module&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; modules/mod_dav_svn.so&lt;br /&gt;
LoadModule authz_svn_module&amp;nbsp;&amp;nbsp; modules/mod_authz_svn.so&amp;nbsp;&amp;nbsp;&amp;nbsp; # Only for access control&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Location /svn&amp;gt;&lt;br /&gt;
&amp;nbsp; DAV svn&lt;br /&gt;
&amp;nbsp; # any "/svn/foo" URL will map to a repository /home/svn/foo&lt;br /&gt;
&amp;nbsp; SVNParentPath /home/svn&lt;br /&gt;
&amp;nbsp; AuthType Basic&lt;br /&gt;
&amp;nbsp; AuthName "Subversion repository"&lt;br /&gt;
&amp;nbsp; AuthzSVNAccessFile /etc/apache2/svn.acl&lt;br /&gt;
&amp;nbsp; AuthUserFile /etc/apache2/svn-passwd&lt;br /&gt;
&amp;nbsp; Require valid-user&lt;br /&gt;
&amp;lt;/Location&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The apache server needs full access to the repository:&lt;br /&gt;
&lt;br /&gt;
# chown -R www:www /home/svn&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Create a user with htpasswd2:&lt;br /&gt;
&lt;br /&gt;
# htpasswd -c /etc/svn-passwd user1&amp;nbsp; # -c creates the file&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Access control svn.acl example&lt;br /&gt;
&lt;br /&gt;
# Default it read access. "* =" would be default no access&lt;br /&gt;
[/]&lt;br /&gt;
* = r&lt;br /&gt;
[groups]&lt;br /&gt;
project1-developers = joe, jack, jane&lt;br /&gt;
# Give write access to the developers&lt;br /&gt;
[project1:]&lt;br /&gt;
@project1-developers = rw&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
SVN commands and usage&lt;br /&gt;
&lt;br /&gt;
See also the Subversion Quick Reference Cardhttp://www.cs.put.poznan.pl/csobaniec/Papers/svn-refcard.pdf. Tortoise SVNhttp://tortoisesvn.tigris.org is a nice Windows interface.&lt;br /&gt;
Import&lt;br /&gt;
&lt;br /&gt;
A new project, that is a directory with some files, is imported into the repository with the import command. Import is also used to add a directory with its content to an existing project.&lt;br /&gt;
&lt;br /&gt;
# svn help import&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Get help for any command&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Add a new directory (with content) into the src dir on project1&lt;br /&gt;
# svn import /project1/newdir http://host.url/svn/project1/trunk/src -m 'add newdir'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Typical SVN commands&lt;br /&gt;
&lt;br /&gt;
# svn co http://host.url/svn/project1/trunk&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Checkout the most recent version&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Tags and branches are created by copying&lt;br /&gt;
# svn mkdir http://host.url/svn/project1/tags/&amp;nbsp;&amp;nbsp; # Create the tags directory&lt;br /&gt;
# svn copy -m "Tag rc1 rel." http://host.url/svn/project1/trunk \&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; http://host.url/svn/project1/tags/1.0rc1&lt;br /&gt;
# svn status [--verbose]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Check files status into working dir&lt;br /&gt;
# svn add src/file.h src/file.cpp&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Add two files&lt;br /&gt;
# svn commit -m 'Added new class file'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Commit the changes with a message&lt;br /&gt;
# svn ls http://host.url/svn/project1/tags/&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # List all tags&lt;br /&gt;
# svn move foo.c bar.c&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Move (rename) files&lt;br /&gt;
# svn delete some_old_file&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Delete files&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Useful Commands&lt;br /&gt;
&lt;br /&gt;
less | vi | mail | tar | dd | screen | find | Miscellaneous&lt;br /&gt;
&lt;br /&gt;
less&lt;br /&gt;
&lt;br /&gt;
The less command displays a text document on the console. It is present on most installation.&lt;br /&gt;
&lt;br /&gt;
# less unixtoolbox.xhtml&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Some important commands are (^N stands for [control]-[N]):&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; h&amp;nbsp; H&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; good help on display&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; f&amp;nbsp; ^F&amp;nbsp; ^V&amp;nbsp; SPACE&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Forward&amp;nbsp; one window (or N lines).&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; b&amp;nbsp; ^B&amp;nbsp; ESC-v&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Backward one window (or N lines).&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; F&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Forward forever; like "tail -f".&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; /pattern&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Search forward for (N-th) matching line.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; ?pattern&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Search backward for (N-th) matching line.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; n&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Repeat previous search (for N-th occurrence).&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; N&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Repeat previous search in reverse direction.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; q&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; quit&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
vi&lt;br /&gt;
&lt;br /&gt;
Vi is present on ANY Linux/Unix installation (not gentoo?) and it is therefore useful to know some basic commands. There are two modes: command mode and insertion mode. The commands mode is accessed with [ESC], the insertion mode with i. Use : help if you are lost.&lt;br /&gt;
&lt;br /&gt;
The editors nano and pico are usually available too and are easier (IMHO) to use.&lt;br /&gt;
Quit&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; :w newfilename&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; save the file to newfilename&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; :wq or :x&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; save and quit&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; :q!&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; quit without saving&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Search and move&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; /string&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Search forward for string&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; ?string&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Search back for string&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; n&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Search for next instance of string&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; N&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Search for previous instance of string&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Move a paragraph back&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Move a paragraph forward&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; 1G&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Move to the first line of the file&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; nG&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Move to the n th line of the file&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; G&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Move to the last line of the file&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; :%s/OLD/NEW/g&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Search and replace every occurrence&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Delete copy paste text&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; dd (dw)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Cut current line (word)&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; D&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Cut to the end of the line&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; x&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Delete (cut) character&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; yy (yw)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Copy line (word) after cursor&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; P&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Paste after cursor&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; u&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Undo last modification&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; U&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Undo all changes to current line&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
mail&lt;br /&gt;
&lt;br /&gt;
The mail command is a basic application to read and send email, it is usually installed. To send an email simply type "mail user@domain". The first line is the subject, then the mail content. Terminate and send the email with a single dot (.) in a new line. Example:&lt;br /&gt;
&lt;br /&gt;
# mail c@cb.vu&lt;br /&gt;
Subject: Your text is full of typos&lt;br /&gt;
"For a moment, nothing happened. Then, after a second or so, &lt;br /&gt;
nothing continued to happen."&lt;br /&gt;
.&lt;br /&gt;
EOT&lt;br /&gt;
#&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is also working with a pipe:&lt;br /&gt;
&lt;br /&gt;
# echo "This is the mail body" | mail c@cb.vu&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is also a simple way to test the mail server.&lt;br /&gt;
&lt;br /&gt;
tar&lt;br /&gt;
&lt;br /&gt;
The command tar (tape archive) creates and extracts archives of file and directories. The archive .tar is uncompressed, a compressed archive has the extension .tgz or .tar.gz (zip) or .tbz (bzip2). Do not use absolute path when creating an archive, you probably want to unpack it somewhere else. Some typical commands are:&lt;br /&gt;
Create&lt;br /&gt;
&lt;br /&gt;
# cd /&lt;br /&gt;
# tar -cf home.tar home/&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # archive the whole /home directory (c for create)&lt;br /&gt;
# tar -czf home.tgz home/&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # same with zip compression&lt;br /&gt;
# tar -cjf home.tbz home/&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # same with bzip2 compression&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Only include one (or two) directories from a tree, but keep the relative structure. For example archive /usr/local/etc and /usr/local/www and the first directory in the archive should be local/.&lt;br /&gt;
&lt;br /&gt;
# tar -C /usr -czf local.tgz local/etc local/www&lt;br /&gt;
# tar -C /usr -xzf local.tgz&amp;nbsp;&amp;nbsp;&amp;nbsp; # To untar the local dir into /usr&lt;br /&gt;
# cd /usr; tar -xzf local.tgz&amp;nbsp;&amp;nbsp; # Is the same as above&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Extract&lt;br /&gt;
&lt;br /&gt;
# tar -tzf home.tgz&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # look inside the archive without extracting (list)&lt;br /&gt;
# tar -xf home.tar&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # extract the archive here (x for extract)&lt;br /&gt;
# tar -xzf home.tgz&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # same with zip compression (-xjf for bzip2 compression)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # remove leading path gallery2 and extract into gallery&lt;br /&gt;
# tar --strip-components 1 -zxvf gallery2.tgz -C gallery/ &lt;br /&gt;
# tar -xjf home.tbz home/colin/file.txt&amp;nbsp;&amp;nbsp;&amp;nbsp; # Restore a single file&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
More advanced&lt;br /&gt;
&lt;br /&gt;
# tar c dir/ | gzip | ssh user@remote 'dd of=dir.tgz' # arch dir/ and store remotely.&lt;br /&gt;
# tar cvf - `find . -print` &amp;gt; backup.tar&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # arch the current directory.&lt;br /&gt;
# tar -cf - -C /etc . | tar xpf - -C /backup/etc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Copy directories&lt;br /&gt;
# tar -cf - -C /etc . | ssh user@remote tar xpf - -C /backup/etc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Remote copy.&lt;br /&gt;
# tar -czf home.tgz --exclude '*.o' --exclude 'tmp/' home/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
dd&lt;br /&gt;
&lt;br /&gt;
The program dd (disk dump or destroy disk or see the meaning of dd) is used to copy partitions and disks and for other copy tricks. Typical usage:&lt;br /&gt;
&lt;br /&gt;
# dd if=&amp;lt;source&amp;gt; of=&amp;lt;target&amp;gt; bs=&amp;lt;byte size&amp;gt; conv=&amp;lt;conversion&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Important conv options:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; notrunc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do not truncate the output file, all zeros will be written as zeros.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; noerror&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; continue after read errors (e.g. bad blocks)&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; sync&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pad every input block with Nulls to ibs-size&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The default byte size is 512 (one block). The MBR, where the partition table is located, is on the first block, the first 63 blocks of a disk are empty. Larger byte sizes are faster to copy but require also more memory.&lt;br /&gt;
Backup and restore&lt;br /&gt;
&lt;br /&gt;
# dd if=/dev/hda of=/dev/hdc bs=16065b&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Copy disk to disk (same size)&lt;br /&gt;
# dd if=/dev/sda7 of=/home/root.img bs=4096 conv=notrunc,noerror # Backup /&lt;br /&gt;
# dd if=/home/root.img of=/dev/sda7 bs=4096 conv=notrunc,noerror # Restore /&lt;br /&gt;
# dd bs=1M if=/dev/ad4s3e | gzip -c &amp;gt; ad4s3e.gz&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Zip the backup&lt;br /&gt;
# gunzip -dc ad4s3e.gz | dd of=/dev/ad0s3e bs=1M&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Restore the zip&lt;br /&gt;
# dd bs=1M if=/dev/ad4s3e | gzip | ssh eedcoba@fry 'dd of=ad4s3e.gz' # also remote&lt;br /&gt;
# gunzip -dc ad4s3e.gz | ssh eedcoba@host 'dd of=/dev/ad0s3e bs=1M'&lt;br /&gt;
# dd if=/dev/ad0 of=/dev/ad2 skip=1 seek=1 bs=4k conv=noerror&amp;nbsp;&amp;nbsp;&amp;nbsp; # Skip MBR&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; # This is necessary if the destination (ad2) is smaller.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Recover&lt;br /&gt;
&lt;br /&gt;
The command dd will read every single block of the partition. In case of problems it is better to use the option conv=sync,noerror so dd will skip the bad block and write zeros at the destination. Accordingly it is important to set the block size equal or smaller than the disk block size. A 1k size seems safe, set it with bs=1k. If a disk has bad sectors and the data should be recovered from a partition, create an image file with dd, mount the image and copy the content to a new disk. With the option noerror, dd will skip the bad sectors and write zeros instead, thus only the data contained in the bad sectors will be lost.&lt;br /&gt;
&lt;br /&gt;
# dd if=/dev/hda of=/dev/null bs=1m&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Check for bad blocks&lt;br /&gt;
# dd bs=1k if=/dev/hda1 conv=sync,noerror,notrunc | gzip | ssh \ # Send to remote&lt;br /&gt;
root@fry 'dd of=hda1.gz bs=1k'&lt;br /&gt;
# dd bs=1k if=/dev/hda1 conv=sync,noerror,notrunc of=hda1.img&amp;nbsp;&amp;nbsp;&amp;nbsp; # Store into an image&lt;br /&gt;
# mount -o loop /hda1.img /mnt&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Mount the image&lt;br /&gt;
# rsync -ax /mnt/ /newdisk/&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Copy on a new disk&lt;br /&gt;
# dd if=/dev/hda of=/dev/hda&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Refresh the magnetic state&lt;br /&gt;
&amp;nbsp; # The above is useful to refresh a disk. It is perfectly safe, but must be unmounted.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Delete&lt;br /&gt;
&lt;br /&gt;
# dd if=/dev/zero of=/dev/hdc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Delete full disk&lt;br /&gt;
# dd if=/dev/urandom of=/dev/hdc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Delete full disk better&lt;br /&gt;
# kill -USR1 PID&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # View dd progress (Linux)&lt;br /&gt;
# kill -INFO PID&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # View dd progress (FreeBSD)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
MBR tricks&lt;br /&gt;
&lt;br /&gt;
The MBR contains the boot loader and the partition table and is 512 bytes small. The first 446 are for the boot loader, the bytes 446 to 512 are for the partition table.&lt;br /&gt;
&lt;br /&gt;
# dd if=/dev/sda of=/mbr_sda.bak bs=512 count=1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Backup the full MBR&lt;br /&gt;
# dd if=/dev/zero of=/dev/sda bs=512 count=1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Delete MBR and partition table&lt;br /&gt;
# dd if=/mbr_sda.bak of=/dev/sda bs=512 count=1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Restore the full MBR&lt;br /&gt;
# dd if=/mbr_sda.bak of=/dev/sda bs=446 count=1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Restore only the boot loader&lt;br /&gt;
# dd if=/mbr_sda.bak of=/dev/sda bs=1 count=64 skip=446 seek=446 # Restore partition table&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
screen&lt;br /&gt;
&lt;br /&gt;
Screen (a must have) has two main functionalities:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; * Run multiple terminal session within a single terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; * A started program is decoupled from the real terminal and can thus run in the background. The real terminal can be closed and reattached later.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Short start example&lt;br /&gt;
&lt;br /&gt;
start screen with:&lt;br /&gt;
&lt;br /&gt;
# screen&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Within the screen session we can start a long lasting program (like top).&lt;br /&gt;
&lt;br /&gt;
# top&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now detach with Ctrl-a Ctrl-d. Reattach the terminal with:&lt;br /&gt;
&lt;br /&gt;
# screen -R -D&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In detail this means: If a session is running, then reattach. If&amp;nbsp; necessary detach and logout remotely first. If it was not running create it and notify the user. Or:&lt;br /&gt;
&lt;br /&gt;
# screen -x&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Attach to a running screen in a multi display mode. The console is thus shared among multiple users. Very useful for team work/debug!&lt;br /&gt;
&lt;br /&gt;
Screen commands (within screen)&lt;br /&gt;
&lt;br /&gt;
All screen commands start with Ctrl-a.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; Ctrl-a ? help and summary of functions&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; Ctrl-a c create an new window (terminal)&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; Ctrl-a Ctrl-n and Ctrl-a Ctrl-p to switch to the next or previous&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; window in the list, by number.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; Ctrl-a Ctrl-N where N is a number from 0 to 9, to switch to the corresponding window.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; Ctrl-a " to get a navigable list of running windows&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; Ctrl-a a to clear a missed Ctrl-a&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; Ctrl-a Ctrl-d to disconnect and leave the session running in the background&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; Ctrl-a x lock the screen terminal with a password&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; Ctrl-a [ enter into scrollback mode, exit with esc.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Use echo "defscrollback 5000" &amp;gt; ~/.screenrc to increase buffer (default is 100)&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; o&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; C-u Scrolls a half page up&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; o&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; C-b Scroll a full page up&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; o&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; C-d Scroll a half page down&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; o&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; C-f Scroll a full page down&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; o&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; / Search forward&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; o&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ? Search backward&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The screen session is terminated when the program within the running terminal is closed and you logout from the terminal.&lt;br /&gt;
&lt;br /&gt;
Find&lt;br /&gt;
&lt;br /&gt;
Some important options:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; -x (on BSD) -xdev (on Linux)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Stay on the same file system (dev in fstab).&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; -exec cmd {} \;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Execute the command and replace {} with the full path&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; -iname&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Like -name but is case insensitive&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; -ls&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Display information about the file (like ls -la)&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; -size n&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; n is +-n (k M G T P)&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; -cmin n&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; File's status was last changed n minutes ago.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# find . -type f ! -perm -444&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Find files not readable by all&lt;br /&gt;
# find . -type d ! -perm -111&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Find dirs not accessible by all&lt;br /&gt;
# find /home/user/ -cmin 10 -print&amp;nbsp;&amp;nbsp; # Files created or modified in the last 10 min.&lt;br /&gt;
# find . -name '*.[ch]' | xargs grep -E 'expr' # Search 'expr' in this dir and below.&lt;br /&gt;
# find / -name "*.core" | xargs rm&amp;nbsp;&amp;nbsp; # Find core dumps and delete them (also try core.*)&lt;br /&gt;
# find / -name "*.core" -print -exec rm {} \;&amp;nbsp; # Other syntax&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Find images and create an archive, iname is not case sensitive. -r for append&lt;br /&gt;
# find . \( -iname "*.png" -o -iname "*.jpg" \) -print -exec tar -rf images.tar {} \;&lt;br /&gt;
# find . -type f -name "*.txt" ! -name README.txt -print&amp;nbsp; # Exclude README.txt files&lt;br /&gt;
# find /var/ -size +10M -exec ls -lh {} \;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Find large files &amp;gt; 10 MB&lt;br /&gt;
# find /var/ -size +10M -ls&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # This is simpler&lt;br /&gt;
# find . -size +10M -size -50M -print&lt;br /&gt;
# find /usr/ports/ -name work -type d -print -exec rm -rf {} \;&amp;nbsp; # Clean the ports&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Find files with SUID; those file are vulnerable and must be kept secure&lt;br /&gt;
# find / -type f -user root -perm -4000 -exec ls -l {} \; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Be careful with xarg or exec as it might or might not honor quotings and can return wrong results when files or directories contain spaces. In doubt use "-print0 | xargs -0" instead of "| xargs". The option -print0 must be the last in the find command. See this nice mini tutorial for findhttp://www.hccfl.edu/pollock/Unix/FindCmd.htm.&lt;br /&gt;
&lt;br /&gt;
# find . -type f | xargs ls -l&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Will not work with spaces in names&lt;br /&gt;
# find . -type f -print0 | xargs -0 ls -l&amp;nbsp; # Will work with spaces in names&lt;br /&gt;
# find . -type f -exec ls -l '{}' \; # Or use quotes '{}' with -exec&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Miscellaneous&lt;br /&gt;
&lt;br /&gt;
# which command&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Show full path name of command&lt;br /&gt;
# time command&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # See how long a command takes to execute&lt;br /&gt;
# time cat&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Use time as stopwatch. Ctrl-c to stop&lt;br /&gt;
# set | grep $USER&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # List the current environment&lt;br /&gt;
# cal -3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Display a three month calendar&lt;br /&gt;
# date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]&lt;br /&gt;
# date 10022155&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Set date and time&lt;br /&gt;
# whatis grep&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Display a short info on the command or word&lt;br /&gt;
# whereis java&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Search path and standard directories for word&lt;br /&gt;
# setenv varname value&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Set env. variable varname to value (csh/tcsh)&lt;br /&gt;
# export varname="value"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # set env. variable varname to value (sh/ksh/bash)&lt;br /&gt;
# pwd&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Print working directory&lt;br /&gt;
# mkdir -p /path/to/dir&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # no error if existing, make parent dirs as needed&lt;br /&gt;
# mkdir -p project/{bin,src,obj,doc/{html,man,pdf},debug/some/more/dirs}&lt;br /&gt;
# rmdir /path/to/dir&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Remove directory&lt;br /&gt;
# rm -rf /path/to/dir&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Remove directory and its content (force)&lt;br /&gt;
# rm -- -badchar.txt&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Remove file whitch starts with a dash (-)&lt;br /&gt;
# cp -la /dir1 /dir2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Archive and hard link files instead of copy&lt;br /&gt;
# cp -lpR /dir1 /dir2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Same for FreeBSD&lt;br /&gt;
# cp unixtoolbox.xhtml{,.bak}&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Short way to copy the file with a new extension&lt;br /&gt;
# mv /dir1 /dir2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Rename a directory&lt;br /&gt;
# ls -1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # list one file per line&lt;br /&gt;
# history | tail -50&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Display the last 50 used commands&lt;br /&gt;
# cd -&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # cd to previous ($OLDPWD) directory&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Check file hashes with openssl. This is a nice alternative to the commands md5sum or sha1sum (FreeBSD uses md5 and sha1) which are not always installed.&lt;br /&gt;
&lt;br /&gt;
# openssl md5 file.tar.gz&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Generate an md5 checksum from file&lt;br /&gt;
# openssl sha1 file.tar.gz&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Generate an sha1 checksum from file&lt;br /&gt;
# openssl rmd160 file.tar.gz&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Generate a RIPEMD-160 checksum from file&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install Software&lt;br /&gt;
&lt;br /&gt;
Usually the package manager uses the proxy variable for http/ftp requests. In .bashrc:&lt;br /&gt;
&lt;br /&gt;
export http_proxy=http://proxy_server:3128&lt;br /&gt;
export ftp_proxy=http://proxy_server:3128&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
List installed packages&lt;br /&gt;
&lt;br /&gt;
# rpm -qa&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # List installed packages (RH, SuSE, RPM based)&lt;br /&gt;
# dpkg -l&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Debian, Ubuntu&lt;br /&gt;
# pkg_info&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # FreeBSD list all installed packages&lt;br /&gt;
# pkg_info -W smbd&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # FreeBSD show which package smbd belongs to&lt;br /&gt;
# pkginfo&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Solaris&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Add/remove software&lt;br /&gt;
&lt;br /&gt;
Front ends: yast2/yast for SuSE, redhat-config-packages for Red Hat.&lt;br /&gt;
&lt;br /&gt;
# rpm -i pkgname.rpm&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # install the package (RH, SuSE, RPM based)&lt;br /&gt;
# rpm -e pkgname&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Remove package&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
SuSE zypper (see doc and cheet sheet)http://en.opensuse.org/Zypper/Usage&lt;br /&gt;
&lt;br /&gt;
# zypper refresh&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Refresh repositorie&lt;br /&gt;
# zypper install vim&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Install the package vim&lt;br /&gt;
# zypper remove vim&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Remove the package vim&lt;br /&gt;
# zypper search vim&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Search packages with vim&lt;br /&gt;
# zypper update vim&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Search packages with vim&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Debian&lt;br /&gt;
&lt;br /&gt;
# apt-get update&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # First update the package lists&lt;br /&gt;
# apt-get install emacs&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Install the package emacs&lt;br /&gt;
# dpkg --remove emacs&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Remove the package emacs&lt;br /&gt;
# dpkg -S file&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # find what package a file belongs to&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Gentoo&lt;br /&gt;
&lt;br /&gt;
Gentoo uses emerge as the heart of its "Portage" package management system.&lt;br /&gt;
&lt;br /&gt;
# emerge --sync&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # First sync the local portage tree&lt;br /&gt;
# emerge -u packagename&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Install or upgrade a package&lt;br /&gt;
# emerge -C packagename&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Remove the package&lt;br /&gt;
# revdep-rebuild&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Repair dependencies&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Solaris&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;cdrom&amp;gt; path is usually /cdrom/cdrom0.&lt;br /&gt;
&lt;br /&gt;
# pkgadd -d &amp;lt;cdrom&amp;gt;/Solaris_9/Product SUNWgtar&lt;br /&gt;
# pkgadd -d SUNWgtar&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Add downloaded package (bunzip2 first)&lt;br /&gt;
# pkgrm SUNWgtar&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Remove the package&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
FreeBSD&lt;br /&gt;
&lt;br /&gt;
# pkg_add -r rsync&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Fetch and install rsync.&lt;br /&gt;
# pkg_delete /var/db/pkg/rsync-xx&amp;nbsp;&amp;nbsp;&amp;nbsp; # Delete the rsync package&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Set where the packages are fetched from with the PACKAGESITE variable. For example:&lt;br /&gt;
&lt;br /&gt;
# export PACKAGESITE=ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages/Latest/ &lt;br /&gt;
# or ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-6-stable/Latest/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
FreeBSD portshttp://www.freebsd.org/handbook/ports.html&lt;br /&gt;
&lt;br /&gt;
The port tree /usr/ports/ is a collection of software ready to compile and install (see man ports). The ports are updated with the program portsnap.&lt;br /&gt;
&lt;br /&gt;
# portsnap fetch extract&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Create the tree when running the first time&lt;br /&gt;
# portsnap fetch update&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Update the port tree&lt;br /&gt;
# cd /usr/ports/net/rsync/&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Select the package to install&lt;br /&gt;
# make install distclean&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Install and cleanup (also see man ports)&lt;br /&gt;
# make package&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Make a binary package of this port&lt;br /&gt;
# pkgdb -F&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Fix the package registry database&lt;br /&gt;
# portsclean -C -DD&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Clean workdir and distdir (part of portupgrade)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
OS X MacPortshttp://guide.macports.org/ (use sudo for all commands)&lt;br /&gt;
&lt;br /&gt;
# port selfupdate&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Update the port tree (safe)&lt;br /&gt;
# port installed&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # List installed ports&lt;br /&gt;
# port deps apache2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # List dependencies for this port&lt;br /&gt;
# port search pgrep&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Search for string&lt;br /&gt;
# port install proctools&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Install this package&lt;br /&gt;
# port variants ghostscript&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # List variants of this port&lt;br /&gt;
# port -v install ghostscript +no_x11# -no_x11 for negative value&lt;br /&gt;
# port clean --all ghostscript&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Clean workdir of port&lt;br /&gt;
# port upgrade ghostscript&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Upgrade this port&lt;br /&gt;
# port uninstall ghostscript&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Uninstall this port&lt;br /&gt;
# port -f uninstall installed&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Uninstall everything&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Library path&lt;br /&gt;
&lt;br /&gt;
Due to complex dependencies and runtime linking, programs are difficult to copy to an other system or distribution. However for small programs with little dependencies, the missing libraries can be copied over. The runtime libraries (and the missing one) are checked with ldd and managed with ldconfig.&lt;br /&gt;
&lt;br /&gt;
# ldd /usr/bin/rsync&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # List all needed runtime libraries&lt;br /&gt;
# otool -L /usr/bin/rsync&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # OS X equivalent to ldd&lt;br /&gt;
# ldconfig -n /path/to/libs/&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Add a path to the shared libraries directories&lt;br /&gt;
# ldconfig -m /path/to/libs/&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # FreeBSD&lt;br /&gt;
# LD_LIBRARY_PATH&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # The variable set the link library path&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Convert Media&lt;br /&gt;
&lt;br /&gt;
Sometimes one simply need to convert a video, audio file or document to another format.&lt;br /&gt;
Text encoding&lt;br /&gt;
&lt;br /&gt;
Text encoding can get totally wrong, specially when the language requires&lt;br /&gt;
special characters like àäç. The command iconv can convert from&lt;br /&gt;
one encoding to an other.&lt;br /&gt;
&lt;br /&gt;
# iconv -f &amp;lt;from_encoding&amp;gt; -t &amp;lt;to_encoding&amp;gt; &amp;lt;input_file&amp;gt;&lt;br /&gt;
# iconv -f ISO8859-1 -t UTF-8 -o file.input &amp;gt; file_utf8&lt;br /&gt;
# iconv -l&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # List known coded character sets&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Without the -f option, iconv will use the local char-set, which is usually fine&lt;br /&gt;
if the document displays well.&lt;br /&gt;
Unix - DOS newlines&lt;br /&gt;
&lt;br /&gt;
Convert DOS (CR/LF) to Unix (LF) newlines and back within a Unix shell. See also dos2unix and unix2dos if you have them.&lt;br /&gt;
&lt;br /&gt;
# sed 's/.$//' dosfile.txt &amp;gt; unixfile.txt&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # DOS to UNIX&lt;br /&gt;
# awk '{sub(/\r$/,"");print}' dosfile.txt &amp;gt; unixfile.txt&amp;nbsp;&amp;nbsp; # DOS to UNIX&lt;br /&gt;
# awk '{sub(/$/,"\r");print}' unixfile.txt &amp;gt; dosfile.txt&amp;nbsp;&amp;nbsp; # UNIX to DOS&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Convert Unix to DOS newlines within a Windows environment. Use sed or awk from mingw or cygwin.&lt;br /&gt;
&lt;br /&gt;
# sed -n p unixfile.txt &amp;gt; dosfile.txt&lt;br /&gt;
# awk 1 unixfile.txt &amp;gt; dosfile.txt&amp;nbsp;&amp;nbsp; # UNIX to DOS (with a cygwin shell)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
PDF to Jpeg and concatenate PDF files&lt;br /&gt;
&lt;br /&gt;
Convert a PDF document with gs (GhostScript) to jpeg (or png) images for each page. Also much shorter with convert and mogrify (from ImageMagick or GraphicsMagick).&lt;br /&gt;
&lt;br /&gt;
# gs -dBATCH -dNOPAUSE -sDEVICE=jpeg -r150 -dTextAlphaBits=4 -dGraphicsAlphaBits=4 \&lt;br /&gt;
&amp;nbsp;-dMaxStripSize=8192 -sOutputFile=unixtoolbox_%d.jpg unixtoolbox.pdf&lt;br /&gt;
# convert unixtoolbox.pdf unixtoolbox-%03d.png&lt;br /&gt;
# convert *.jpeg images.pdf&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Create a simple PDF with all pictures&lt;br /&gt;
# convert image000* -resample 120x120 -compress JPEG -quality 80 images.pdf&lt;br /&gt;
# mogrify -format png *.ppm&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # convert all ppm images to png format&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ghostscript can also concatenate multiple pdf files into a single one. This only works well if the PDF files are "well behaved".&lt;br /&gt;
&lt;br /&gt;
# gs -q -sPAPERSIZE=a4 -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=all.pdf \&lt;br /&gt;
file1.pdf file2.pdf ...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # On Windows use '#' instead of '='&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Convert video&lt;br /&gt;
&lt;br /&gt;
Compress the Canon digicam video with an mpeg4 codec and repair the crappy sound.&lt;br /&gt;
&lt;br /&gt;
# mencoder -o videoout.avi -oac mp3lame -ovc lavc -srate 11025 \&lt;br /&gt;
-channels 1 -af-adv force=1 -lameopts preset=medium -lavcopts \&lt;br /&gt;
vcodec=msmpeg4v2:vbitrate=600 -mc 0 vidoein.AVI&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
See sox for sound processing.&lt;br /&gt;
&lt;br /&gt;
Copy an audio cd&lt;br /&gt;
&lt;br /&gt;
The program cdparanoiahttp://xiph.org/paranoia/ can save the audio tracks (FreeBSD port in audio/cdparanoia/), oggenc can encode in Ogg Vorbis format, lame converts to mp3.&lt;br /&gt;
&lt;br /&gt;
# cdparanoia -B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Copy the tracks to wav files in current dir&lt;br /&gt;
# lame -b 256 in.wav out.mp3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Encode in mp3 256 kb/s&lt;br /&gt;
# for i in *.wav; do lame -b 256 $i `basename $i .wav`.mp3; done&lt;br /&gt;
# oggenc in.wav -b 256 out.ogg&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Encode in Ogg Vorbis 256 kb/s&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Printing&lt;br /&gt;
&lt;br /&gt;
Print with lpr&lt;br /&gt;
&lt;br /&gt;
# lpr unixtoolbox.ps&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Print on default printer&lt;br /&gt;
# export PRINTER=hp4600&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Change the default printer&lt;br /&gt;
# lpr -Php4500 #2 unixtoolbox.ps&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Use printer hp4500 and print 2 copies&lt;br /&gt;
# lpr -o Duplex=DuplexNoTumble ...&amp;nbsp;&amp;nbsp; # Print duplex along the long side&lt;br /&gt;
# lpr -o PageSize=A4,Duplex=DuplexNoTumble ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# lpq&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Check the queue on default printer&lt;br /&gt;
# lpq -l -Php4500&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Queue on printer hp4500 with verbose&lt;br /&gt;
# lprm -&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Remove all users jobs on default printer&lt;br /&gt;
# lprm -Php4500 3186&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Remove job 3186. Find job nbr with lpq&lt;br /&gt;
# lpc status&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # List all available printers&lt;br /&gt;
# lpc status hp4500&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Check if printer is online and queue length&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Some devices are not postscript and will print garbage when fed with a pdf file. This might be solved with:&lt;br /&gt;
&lt;br /&gt;
# gs -dSAFER -dNOPAUSE -sDEVICE=deskjet -sOutputFile=\|lpr file.pdf&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Print to a PDF file even if the application does not support it. Use gs on the print command instead of lpr.&lt;br /&gt;
&lt;br /&gt;
# gs -q -sPAPERSIZE=a4 -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=/path/file.pdf&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Databases&lt;br /&gt;
&lt;br /&gt;
PostgreSQL&lt;br /&gt;
&lt;br /&gt;
Change root or a username password&lt;br /&gt;
&lt;br /&gt;
# psql -d template1 -U pgsql&lt;br /&gt;
&amp;gt; alter user pgsql with password 'pgsql_password';&amp;nbsp; # Use username instead of "pgsql"&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Create user and database&lt;br /&gt;
&lt;br /&gt;
The commands createuser, dropuser, createdb and dropdb are convenient shortcuts equivalent to the SQL commands. The new user is bob with database bobdb ; use as root with pgsql the database super user:&lt;br /&gt;
&lt;br /&gt;
# createuser -U pgsql -P bob&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # -P will ask for password&lt;br /&gt;
# createdb -U pgsql -O bob bobdb&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # new bobdb is owned by bob&lt;br /&gt;
# dropdb bobdb&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Delete database bobdb&lt;br /&gt;
# dropuser bob&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Delete user bob&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The general database authentication mechanism is configured in pg_hba.conf&lt;br /&gt;
Grant remote access&lt;br /&gt;
&lt;br /&gt;
The file $PGSQL_DATA_D/postgresql.conf specifies the address to bind to. Typically listen_addresses = '*' for Postgres 8.x.&lt;br /&gt;
&lt;br /&gt;
The file $PGSQL_DATA_D/pg_hba.conf defines the access control. Examples:&lt;br /&gt;
&lt;br /&gt;
# TYPE&amp;nbsp; DATABASE&amp;nbsp;&amp;nbsp;&amp;nbsp; USER&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IP-ADDRESS&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IP-MASK&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; METHOD&lt;br /&gt;
host&amp;nbsp;&amp;nbsp;&amp;nbsp; bobdb&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bob&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 212.117.81.42&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 255.255.255.255&amp;nbsp;&amp;nbsp; password&lt;br /&gt;
host&amp;nbsp;&amp;nbsp;&amp;nbsp; all&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; all&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.0.0.0/0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; password&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Backup and restore&lt;br /&gt;
&lt;br /&gt;
The backups and restore are done with the user pgsql or postgres. Backup and restore a single database:&lt;br /&gt;
&lt;br /&gt;
# pg_dump --clean dbname &amp;gt; dbname_sql.dump&lt;br /&gt;
# psql dbname &amp;lt; dbname_sql.dump&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Backup and restore all databases (including users):&lt;br /&gt;
&lt;br /&gt;
# pg_dumpall --clean &amp;gt; full.dump&lt;br /&gt;
# psql -f full.dump postgres&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this case the restore is started with the database postgres which is better when reloading an empty cluster.&lt;br /&gt;
&lt;br /&gt;
MySQL&lt;br /&gt;
&lt;br /&gt;
Change mysql root or username password&lt;br /&gt;
&lt;br /&gt;
Method 1&lt;br /&gt;
&lt;br /&gt;
# /etc/init.d/mysql stop&lt;br /&gt;
or&lt;br /&gt;
# killall mysqld&lt;br /&gt;
# mysqld --skip-grant-tables&lt;br /&gt;
# mysqladmin -u root password 'newpasswd'&lt;br /&gt;
# /etc/init.d/mysql start&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Method 2&lt;br /&gt;
&lt;br /&gt;
# mysql -u root mysql&lt;br /&gt;
mysql&amp;gt; UPDATE USER SET PASSWORD=PASSWORD("newpassword") where user='root';&lt;br /&gt;
mysql&amp;gt; FLUSH PRIVILEGES;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Use username instead of "root"&lt;br /&gt;
mysql&amp;gt; quit&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Create user and database (see MySQL dochttp://dev.mysql.com/doc/refman/5.1/en/adding-users.html)&lt;br /&gt;
&lt;br /&gt;
# mysql -u root mysql&lt;br /&gt;
mysql&amp;gt; CREATE USER 'bob'@'localhost' IDENTIFIED BY 'pwd'; # create only a user&lt;br /&gt;
mysql&amp;gt; CREATE DATABASE bobdb;&lt;br /&gt;
mysql&amp;gt; GRANT ALL ON *.* TO 'bob'@'%' IDENTIFIED BY 'pwd'; # Use localhost instead of %&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # to restrict the network access&lt;br /&gt;
mysql&amp;gt; DROP DATABASE bobdb;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Delete database&lt;br /&gt;
mysql&amp;gt; DROP USER bob;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Delete user&lt;br /&gt;
mysql&amp;gt; DELETE FROM mysql.user WHERE user='bob and host='hostname'; # Alt. command&lt;br /&gt;
mysql&amp;gt; FLUSH PRIVILEGES;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Grant remote access&lt;br /&gt;
&lt;br /&gt;
Remote access is typically permitted for a database, and not all databases. The file /etc/my.cnf contains the IP address to bind to. (On FreeBSD my.cnf not created per fedault, copy one .cnf file from /usr/local/share/mysql to /usr/local/etc/my.cnf) Typically comment the line bind-address = out.&lt;br /&gt;
&lt;br /&gt;
# mysql -u root mysql&lt;br /&gt;
mysql&amp;gt; GRANT ALL ON bobdb.* TO bob@'xxx.xxx.xxx.xxx' IDENTIFIED BY 'PASSWORD';&lt;br /&gt;
mysql&amp;gt; REVOKE GRANT OPTION ON foo.* FROM bar@'xxx.xxx.xxx.xxx';&lt;br /&gt;
mysql&amp;gt; FLUSH PRIVILEGES;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Use 'hostname' or also '%' for full access&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Backup and restore&lt;br /&gt;
&lt;br /&gt;
Backup and restore a single database:&lt;br /&gt;
&lt;br /&gt;
# mysqldump -u root -psecret --add-drop-database dbname &amp;gt; dbname_sql.dump&lt;br /&gt;
# mysql -u root -psecret -D dbname &amp;lt; dbname_sql.dump&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Backup and restore all databases:&lt;br /&gt;
&lt;br /&gt;
# mysqldump -u root -psecret --add-drop-database --all-databases &amp;gt; full.dump&lt;br /&gt;
# mysql -u root -psecret &amp;lt; full.dump&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here is "secret" the mysql root password, there is no space after -p. When the -p option is used alone (w/o password), the password is asked at the command prompt.&lt;br /&gt;
&lt;br /&gt;
SQLite&lt;br /&gt;
&lt;br /&gt;
SQLitehttp://www.sqlite.org is a small powerful self-contained, serverless, zero-configuration SQL database.&lt;br /&gt;
Dump and restore&lt;br /&gt;
&lt;br /&gt;
It can be useful to dump and restore an SQLite database. For example you can edit the dump file to change a column attribute or type and then restore the database. This is easier than messing with SQL commands. Use the command sqlite3 for a 3.x database.&lt;br /&gt;
&lt;br /&gt;
# sqlite database.db .dump &amp;gt; dump.sql&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # dump&lt;br /&gt;
# sqlite database.db &amp;lt; dump.sql&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # restore&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Convert 2.x to 3.x database&lt;br /&gt;
&lt;br /&gt;
sqlite database_v2.db .dump | sqlite3 database_v3.db&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Disk Quota&lt;br /&gt;
&lt;br /&gt;
A disk quota allows to limit the amount of disk space and/or the number of files a user or (or member of group) can use. The quotas are allocated on a per-file system basis and are enforced by the kernel.&lt;br /&gt;
Linux setup&lt;br /&gt;
&lt;br /&gt;
The quota tools package usually needs to be installed, it contains the command line tools.&lt;br /&gt;
&lt;br /&gt;
Activate the user quota in the fstab and remount the partition. If the partition is busy, either all locked files must be closed, or the system must be rebooted. Add usrquota to the fstab mount options, for example:&lt;br /&gt;
&lt;br /&gt;
/dev/sda2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /home&amp;nbsp;&amp;nbsp;&amp;nbsp; reiserfs&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rw,acl,user_xattr,usrquota 1 1&lt;br /&gt;
# mount -o remount /home&lt;br /&gt;
# mount&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Check if usrquota is active, otherwise reboot&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Initialize the quota.user file with quotacheck.&lt;br /&gt;
&lt;br /&gt;
# quotacheck -vum /home&lt;br /&gt;
# chmod 644 /home/aquota.user&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # To let the users check their own quota&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Activate the quota either with the provided script (e.g. /etc/init.d/quotad on SuSE) or with quotaon:&lt;br /&gt;
&lt;br /&gt;
quotaon -vu /home&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Check that the quota is active with:&lt;br /&gt;
&lt;br /&gt;
quota -v&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
FreeBSD setup&lt;br /&gt;
&lt;br /&gt;
The quota tools are part of the base system, however the kernel needs the option quota. If it is not there, add it and recompile the kernel.&lt;br /&gt;
&lt;br /&gt;
options QUOTA&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As with Linux, add the quota to the fstab options (userquota, not usrquota):&lt;br /&gt;
&lt;br /&gt;
/dev/ad0s1d&amp;nbsp;&amp;nbsp;&amp;nbsp; /home&amp;nbsp;&amp;nbsp;&amp;nbsp; ufs&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rw,noatime,userquota&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp; 2&lt;br /&gt;
# mount /home&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # To remount the partition&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Enable disk quotas in /etc/rc.conf and start the quota.&lt;br /&gt;
&lt;br /&gt;
# grep quotas /etc/rc.conf&lt;br /&gt;
enable_quotas="YES"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # turn on quotas on startup (or NO).&lt;br /&gt;
check_quotas="YES"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Check quotas on startup (or NO).&lt;br /&gt;
# /etc/rc.d/quota start&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Assign quota limits&lt;br /&gt;
&lt;br /&gt;
The quotas are not limited per default (set to 0). The limits are set with edquota for single users. A quota can be also duplicated to many users. The file structure is different between the quota implementations, but the principle is the same: the values of blocks and inodes can be limited. Only change the values of soft and hard. If not specified, the blocks are 1k. The grace period is set with edquota -t. For example:&lt;br /&gt;
&lt;br /&gt;
# edquota -u colin&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Linux&lt;br /&gt;
&lt;br /&gt;
Disk quotas for user colin (uid 1007):&lt;br /&gt;
&amp;nbsp; Filesystem&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; blocks&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; soft&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; hard&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inodes&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; soft&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; hard&lt;br /&gt;
&amp;nbsp; /dev/sda8&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 108&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
FreeBSD&lt;br /&gt;
&lt;br /&gt;
Quotas for user colin:&lt;br /&gt;
/home: kbytes in use: 504184, limits (soft = 700000, hard = 800000)&lt;br /&gt;
&amp;nbsp;&amp;nbsp; inodes in use: 1792, limits (soft = 0, hard = 0)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For many users&lt;br /&gt;
&lt;br /&gt;
The command edquota -p is used to duplicate a quota to other users. For example to duplicate a reference quota to all users:&lt;br /&gt;
&lt;br /&gt;
# edquota -p refuser `awk -F: '$3 &amp;gt; 499 {print $1}' /etc/passwd`&lt;br /&gt;
# edquota -p refuser user1 user2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Duplicate to 2 users&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Checks&lt;br /&gt;
&lt;br /&gt;
Users can check their quota by simply typing quota (the file quota.user must be readable). Root can check all quotas.&lt;br /&gt;
&lt;br /&gt;
# quota -u colin&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Check quota for a user&lt;br /&gt;
# repquota /home&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Full report for the partition for all users&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Shells&lt;br /&gt;
&lt;br /&gt;
Most Linux distributions use the bash shell while the BSDs use tcsh, the bourne shell is only used for scripts. Filters are very useful and can be piped:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; grep&amp;nbsp;&amp;nbsp; Pattern matching&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; sed&amp;nbsp;&amp;nbsp; Search and Replace strings or characters&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; cut&amp;nbsp;&amp;nbsp; Print specific columns from a marker&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; sort&amp;nbsp;&amp;nbsp; Sort alphabetically or numerically&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; uniq&amp;nbsp;&amp;nbsp; Remove duplicate lines from a file&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For example used all at once:&lt;br /&gt;
&lt;br /&gt;
# ifconfig | sed 's/&amp;nbsp; / /g' | cut -d" " -f1 | uniq | grep -E "[a-z0-9]+" | sort -r&lt;br /&gt;
# ifconfig | sed '/.*inet addr:/!d;s///;s/ .*//'|sort -t. -k1,1n -k2,2n -k3,3n -k4,4n&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The first character in the sed pattern is a tab. To write a tab on the console, use ctrl-v ctrl-tab.&lt;br /&gt;
&lt;br /&gt;
bash&lt;br /&gt;
&lt;br /&gt;
Redirects and pipes for bash and sh:&lt;br /&gt;
&lt;br /&gt;
# cmd 1&amp;gt; file&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Redirect stdout to file.&lt;br /&gt;
# cmd 2&amp;gt; file&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Redirect stderr to file.&lt;br /&gt;
# cmd 1&amp;gt;&amp;gt; file&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Redirect and append stdout to file.&lt;br /&gt;
# cmd &amp;amp;&amp;gt; file&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Redirect both stdout and stderr to file.&lt;br /&gt;
# cmd &amp;gt;file 2&amp;gt;&amp;amp;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Redirects stderr to stdout and then to file.&lt;br /&gt;
# cmd1 | cmd2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # pipe stdout to cmd2&lt;br /&gt;
# cmd1 2&amp;gt;&amp;amp;1 | cmd2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # pipe stdout and stderr to cmd2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Modify your configuration in ~/.bashrc (it can also be ~/.bash_profile). The following entries are useful, reload with ". .bashrc". With cygwin use ~/.bash_profile; with rxvt past with shift + left-click.&lt;br /&gt;
&lt;br /&gt;
# in .bashrc&lt;br /&gt;
bind '"\e[A"':history-search-backward # Use up and down arrow to search&lt;br /&gt;
bind '"\e[B"':history-search-forward&amp;nbsp; # the history. Invaluable!&lt;br /&gt;
set -o emacs&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Set emacs mode in bash (see below)&lt;br /&gt;
set bell-style visible&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Do not beep, inverse colors&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Set a nice prompt like [user@host]/path/todir&amp;gt;&lt;br /&gt;
PS1="\[\033[1;30m\][\[\033[1;34m\]\u\[\033[1;30m\]"&lt;br /&gt;
PS1="$PS1@\[\033[0;33m\]\h\[\033[1;30m\]]\[\033[0;37m\]"&lt;br /&gt;
PS1="$PS1\w\[\033[1;30m\]&amp;gt;\[\033[0m\]"&lt;br /&gt;
&lt;br /&gt;
# To check the currently active aliases, simply type alias&lt;br /&gt;
alias&amp;nbsp; ls='ls -aF'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Append indicator (one of */=&amp;gt;@|)&lt;br /&gt;
alias&amp;nbsp; ll='ls -aFls'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Listing&lt;br /&gt;
alias&amp;nbsp; la='ls -all'&lt;br /&gt;
alias ..='cd ..'&lt;br /&gt;
alias ...='cd ../..'&lt;br /&gt;
export HISTFILESIZE=5000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Larger history&lt;br /&gt;
export CLICOLOR=1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Use colors (if possible)&lt;br /&gt;
export LSCOLORS=ExGxFxdxCxDxDxBxBxExEx&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
tcsh&lt;br /&gt;
&lt;br /&gt;
Redirects and pipes for tcsh and csh (simple &amp;gt; and &amp;gt;&amp;gt; are the same as sh):&lt;br /&gt;
&lt;br /&gt;
# cmd &amp;gt;&amp;amp; file&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Redirect both stdout and stderr to file.&lt;br /&gt;
# cmd &amp;gt;&amp;gt;&amp;amp; file&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Append both stdout and stderr to file.&lt;br /&gt;
# cmd1 | cmd2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # pipe stdout to cmd2&lt;br /&gt;
# cmd1 |&amp;amp; cmd2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # pipe stdout and stderr to cmd2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The settings for csh/tcsh are set in ~/.cshrc, reload with "source .cshrc". Examples:&lt;br /&gt;
&lt;br /&gt;
# in .cshrc&lt;br /&gt;
alias&amp;nbsp; ls&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'ls -aF'&lt;br /&gt;
alias&amp;nbsp; ll&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'ls -aFls'&lt;br /&gt;
alias&amp;nbsp; la&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'ls -all'&lt;br /&gt;
alias&amp;nbsp; ..&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'cd ..'&lt;br /&gt;
alias&amp;nbsp; ...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'cd ../..'&lt;br /&gt;
set&amp;nbsp;&amp;nbsp; prompt&amp;nbsp;&amp;nbsp;&amp;nbsp; = "%B%n%b@%B%m%b%/&amp;gt; " # like user@host/path/todir&amp;gt;&lt;br /&gt;
set&amp;nbsp;&amp;nbsp; history&amp;nbsp;&amp;nbsp; =&amp;nbsp; 5000&lt;br /&gt;
set&amp;nbsp;&amp;nbsp; savehist&amp;nbsp; = ( 6000 merge )&lt;br /&gt;
set&amp;nbsp;&amp;nbsp; autolist&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Report possible completions with tab&lt;br /&gt;
set&amp;nbsp;&amp;nbsp; visiblebell&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Do not beep, inverse colors&lt;br /&gt;
&lt;br /&gt;
# Bindkey and colors&lt;br /&gt;
bindkey -e&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Select Emacs bindings&amp;nbsp; # Use emacs keys to edit the command prompt&lt;br /&gt;
bindkey -k up history-search-backward # Use up and down arrow to search&lt;br /&gt;
bindkey -k down history-search-forward&lt;br /&gt;
setenv CLICOLOR 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Use colors (if possible)&lt;br /&gt;
setenv LSCOLORS ExGxFxdxCxDxDxBxBxExEx&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The emacs mode enables to use the emacs keys shortcuts to modify the command prompt line. This is extremely useful (not only for emacs users). The most used commands are:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; C-a&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Move cursor to beginning of line&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; C-e&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Move cursor to end of line&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; M-b&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Move cursor back one word&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; M-f&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Move cursor forward one word&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; M-d&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Cut the next word&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; C-w&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Cut the last word&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; C-u&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Cut everything before the cursor&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; C-k&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Cut everything after the cursor (rest of the line)&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; C-y&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Paste the last thing to be cut (simply paste)&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp; C-_&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Undo&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note: C- = hold control, M- = hold meta (which is usually the alt or escape key).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Scripting&lt;br /&gt;
&lt;br /&gt;
Basics | Script example | awk | sed | Regular Expressions | useful commands&lt;br /&gt;
&lt;br /&gt;
The Bourne shell (/bin/sh) is present on all Unix installations and scripts written in this language are (quite) portable; man 1 sh is a good reference.&lt;br /&gt;
&lt;br /&gt;
Basics&lt;br /&gt;
&lt;br /&gt;
Variables and arguments&lt;br /&gt;
&lt;br /&gt;
Assign with variable=value and get content with $variable&lt;br /&gt;
&lt;br /&gt;
MESSAGE="Hello World"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Assign a string&lt;br /&gt;
PI=3.1415&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Assign a decimal number&lt;br /&gt;
N=8&lt;br /&gt;
TWON=`expr $N * 2`&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Arithmetic expression (only integers)&lt;br /&gt;
TWON=$(($N * 2))&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Other syntax&lt;br /&gt;
TWOPI=`echo "$PI * 2" | bc -l`&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Use bc for floating point operations&lt;br /&gt;
ZERO=`echo "c($PI/4)-sqrt(2)/2" | bc -l`&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The command line arguments are&lt;br /&gt;
&lt;br /&gt;
$0, $1, $2, ...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # $0 is the command itself &lt;br /&gt;
$#&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # The number of arguments&lt;br /&gt;
$*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # All arguments (also $@)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Special Variables&lt;br /&gt;
&lt;br /&gt;
$$&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # The current process ID&lt;br /&gt;
$?&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # exit status of last command&lt;br /&gt;
&amp;nbsp; command&lt;br /&gt;
&amp;nbsp; if [ $? != 0 ]; then&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; echo "command failed"&lt;br /&gt;
&amp;nbsp; fi&lt;br /&gt;
mypath=`pwd`&lt;br /&gt;
mypath=${mypath}/file.txt&lt;br /&gt;
echo ${mypath##*/}&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Display the filename only&lt;br /&gt;
echo ${mypath%%.*}&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Full path without extention&lt;br /&gt;
var2=${var:=string}&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Use var if set, otherwise use string&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # assign string to var and then to var2.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Constructs&lt;br /&gt;
&lt;br /&gt;
for file in `ls`&lt;br /&gt;
do&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; echo $file&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
count=0&lt;br /&gt;
while [ $count -lt 5 ]; do&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; echo $count&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; sleep 1&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; count=$(($count + 1))&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
myfunction() {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; find . -type f -name "*.$1" -print&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # $1 is first argument of the function&lt;br /&gt;
}&lt;br /&gt;
myfunction "txt"&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Generate a file&lt;br /&gt;
&lt;br /&gt;
MYHOME=/home/colin&lt;br /&gt;
cat &amp;gt; testhome.sh &amp;lt;&amp;lt; _EOF&lt;br /&gt;
# All of this goes into the file testhome.sh&lt;br /&gt;
if [ -d "$MYHOME" ] ; then&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; echo $MYHOME exists&lt;br /&gt;
else&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; echo $MYHOME does not exist&lt;br /&gt;
fi&lt;br /&gt;
_EOF&lt;br /&gt;
sh testhome.sh&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Bourne script example&lt;br /&gt;
&lt;br /&gt;
As a small example, the script used to create a PDF booklet from this xhtml document:&lt;br /&gt;
&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
# This script creates a book in pdf format ready to print on a duplex printer&lt;br /&gt;
if [ $# -ne 1 ]; then&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Check the argument&lt;br /&gt;
&amp;nbsp; echo 1&amp;gt;&amp;amp;2 "Usage: $0 HtmlFile"&lt;br /&gt;
&amp;nbsp; exit 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # non zero exit if error&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
file=$1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Assign the filename&lt;br /&gt;
fname=${file%.*}&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Get the name of the file only&lt;br /&gt;
fext=${file#*.}&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Get the extension of the file&lt;br /&gt;
&lt;br /&gt;
prince $file -o $fname.pdf&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # from www.princexml.com&lt;br /&gt;
pdftops -paper A4 -noshrink $fname.pdf $fname.ps # create postscript booklet&lt;br /&gt;
cat $fname.ps |psbook|psnup -Pa4 -2 |pstops -b "2:0,1U(21cm,29.7cm)" &amp;gt; $fname.book.ps&lt;br /&gt;
&lt;br /&gt;
ps2pdf13 -sPAPERSIZE=a4 -sAutoRotatePages=None $fname.book.ps $fname.book.pdf&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # use #a4 and #None on Windows!&lt;br /&gt;
exit 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # exit 0 means successful&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Some awk commands&lt;br /&gt;
&lt;br /&gt;
Awk is useful for field stripping, like cut in a more powerful way. Search this document for other examples. See for example gnulamp.com and&amp;nbsp; one-liners for awk for some nice examples.&lt;br /&gt;
&lt;br /&gt;
awk '{ print $2, $1 }' file&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Print and inverse first two columns&lt;br /&gt;
awk '{printf("%5d : %s\n", NR,$0)}' file&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Add line number left aligned&lt;br /&gt;
awk '{print FNR "\t" $0}' files&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Add line number right aligned&lt;br /&gt;
awk NF test.txt&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # remove blank lines (same as grep '.')&lt;br /&gt;
awk 'length &amp;gt; 80'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # print line longer than 80 char)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Some sed commands&lt;br /&gt;
&lt;br /&gt;
Here is the one liner gold minehttp://student.northpark.edu/pemente/sed/sed1line.txt. And a good introduction and tutorial to sedhttp://www.grymoire.com/Unix/Sed.html.&lt;br /&gt;
&lt;br /&gt;
sed 's/string1/string2/g'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Replace string1 with string2&lt;br /&gt;
sed -i 's/wroong/wrong/g' *.txt&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Replace a recurring word with g&lt;br /&gt;
sed 's/\(.*\)1/\12/g'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Modify anystring1 to anystring2&lt;br /&gt;
sed '/&amp;lt;p&amp;gt;/,/&amp;lt;\/p&amp;gt;/d' t.xhtml&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Delete lines that start with &amp;lt;p&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # and end with &amp;lt;/p&amp;gt;&lt;br /&gt;
sed '/ *#/d; /^ *$/d'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Remove comments and blank lines&lt;br /&gt;
sed 's/[ \t]*$//'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Remove trailing spaces (use tab as \t)&lt;br /&gt;
sed 's/^[ \t]*//;s/[ \t]*$//'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Remove leading and trailing spaces&lt;br /&gt;
sed 's/[^*]/[&amp;amp;]/'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Enclose first char with [] top-&amp;gt;[t]op&lt;br /&gt;
sed = file | sed 'N;s/\n/\t/' &amp;gt; file.num&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Number lines on a file&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Regular Expressions&lt;br /&gt;
&lt;br /&gt;
Some basic regular expression useful for sed too. See Basic Regex Syntaxhttp://www.regular-expressions.info/reference.html for a good primer.&lt;br /&gt;
&lt;br /&gt;
[\^$.|?*+()&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # special characters any other will match themselves&lt;br /&gt;
\&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # escapes special characters and treat as literal&lt;br /&gt;
*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # repeat the previous item zero or more times&lt;br /&gt;
.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # single character except line break characters&lt;br /&gt;
.*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # match zero or more characters&lt;br /&gt;
^&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # match at the start of a line/string&lt;br /&gt;
$&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # match at the end of a line/string&lt;br /&gt;
.$&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # match a single character at the end of line/string&lt;br /&gt;
^ $&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # match line with a single space&lt;br /&gt;
[^A-Z]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # match any line beginning with any char from A to Z&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Some useful commands&lt;br /&gt;
&lt;br /&gt;
The following commands are useful to include in a script or as one liners.&lt;br /&gt;
&lt;br /&gt;
sort -t. -k1,1n -k2,2n -k3,3n -k4,4n&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Sort IPv4 ip addresses&lt;br /&gt;
echo 'Test' | tr '[:lower:]' '[:upper:]'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Case conversion&lt;br /&gt;
echo foo.bar | cut -d . -f 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Returns foo&lt;br /&gt;
PID=$(ps | grep script.sh | grep bin | awk '{print $1}')&amp;nbsp;&amp;nbsp;&amp;nbsp; # PID of a running script&lt;br /&gt;
PID=$(ps axww | grep [p]ing | awk '{print $1}')&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # PID of ping (w/o grep pid)&lt;br /&gt;
IP=$(ifconfig $INTERFACE | sed '/.*inet addr:/!d;s///;s/ .*//')&amp;nbsp;&amp;nbsp; # Linux&lt;br /&gt;
IP=$(ifconfig $INTERFACE | sed '/.*inet /!d;s///;s/ .*//')&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # FreeBSD&lt;br /&gt;
if [ `diff file1 file2 | wc -l` != 0 ]; then [...] fi&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # File changed?&lt;br /&gt;
cat /etc/master.passwd | grep -v root | grep -v \*: | awk -F":" \ # Create http passwd&lt;br /&gt;
'{ printf("%s:%s\n", $1, $2) }' &amp;gt; /usr/local/etc/apache2/passwd&lt;br /&gt;
&lt;br /&gt;
testuser=$(cat /usr/local/etc/apache2/passwd | grep -v \&amp;nbsp;&amp;nbsp;&amp;nbsp; # Check user in passwd&lt;br /&gt;
root | grep -v \*: | awk -F":" '{ printf("%s\n", $1) }' | grep ^user$)&lt;br /&gt;
:(){ :|:&amp;amp; };:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # bash fork bomb. Will kill your machine&lt;br /&gt;
tail +2 file &amp;gt; file2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # remove the first line from file&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I use this little trick to change the file extension for many files at once. For example from .cxx to .cpp. Test it first without the | sh at the end. You can also do this with the command rename if installed. Or with bash builtins.&lt;br /&gt;
&lt;br /&gt;
# ls *.cxx | awk -F. '{print "mv "$0" "$1".cpp"}' | sh&lt;br /&gt;
# ls *.c | sed "s/.*/cp &amp;amp; &amp;amp;.$(date "+%Y%m%d")/" | sh # e.g. copy *.c to *.c.20080401&lt;br /&gt;
# rename .cxx .cpp *.cxx&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Rename all .cxx to cpp&lt;br /&gt;
# for i in *.cxx; do mv $i ${i%%.cxx}.cpp; done&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # with bash builtins&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Programming&lt;br /&gt;
&lt;br /&gt;
C basics&lt;br /&gt;
&lt;br /&gt;
strcpy(newstr,str)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* copy str to newstr */&lt;br /&gt;
expr1 ? expr2 : expr3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* if (expr1) expr2 else expr3 */&lt;br /&gt;
x = (y &amp;gt; z) ? y : z;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* if (y &amp;gt; z) x = y; else x = z; */&lt;br /&gt;
int a[]={0,1,2};&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Initialized array (or a[3]={0,1,2}; */&lt;br /&gt;
int a[2][3]={{1,2,3},{4,5,6}};&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Array of array of ints */&lt;br /&gt;
int i = 12345;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Convert in i to char str */&lt;br /&gt;
char str[10];&lt;br /&gt;
sprintf(str, "%d", i);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
C example&lt;br /&gt;
&lt;br /&gt;
A minimal c program simple.c:&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
main() {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; int number=42;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("The answer is %i\n", number); &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Compile with:&lt;br /&gt;
&lt;br /&gt;
# gcc simple.c -o simple&lt;br /&gt;
# ./simple&lt;br /&gt;
The answer is 42&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
C++ basics&lt;br /&gt;
&lt;br /&gt;
*pointer&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Object pointed to by pointer&lt;br /&gt;
&amp;amp;obj&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Address of object obj&lt;br /&gt;
obj.x&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Member x of class obj (object obj)&lt;br /&gt;
pobj-&amp;gt;x&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Member x of class pointed to by pobj&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // (*pobj).x and pobj-&amp;gt;x are the same&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
C++ example&lt;br /&gt;
&lt;br /&gt;
As a slightly more realistic program in C++: a class in its own header (IPv4.h) and implementation (IPv4.cpp) and a program which uses the class functionality. The class converts an IP address in integer format to the known quad format.&lt;br /&gt;
IPv4 class&lt;br /&gt;
&lt;br /&gt;
IPv4.h:&lt;br /&gt;
&lt;br /&gt;
#ifndef IPV4_H&lt;br /&gt;
#define IPV4_H&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
&lt;br /&gt;
namespace GenericUtils {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // create a namespace&lt;br /&gt;
class IPv4 {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // class definition&lt;br /&gt;
public:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; IPv4(); ~IPv4();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; std::string IPint_to_IPquad(unsigned long ip);// member interface&lt;br /&gt;
};&lt;br /&gt;
} //namespace GenericUtils&lt;br /&gt;
#endif // IPV4_H&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
IPv4.cpp:&lt;br /&gt;
&lt;br /&gt;
#include "IPv4.h"&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
#include &amp;lt;sstream&amp;gt;&lt;br /&gt;
using namespace std;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // use the namespaces&lt;br /&gt;
using namespace GenericUtils;&lt;br /&gt;
&lt;br /&gt;
IPv4::IPv4() {}&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // default constructor/destructor&lt;br /&gt;
IPv4::~IPv4() {}&lt;br /&gt;
string IPv4::IPint_to_IPquad(unsigned long ip) {&amp;nbsp; // member implementation&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ostringstream ipstr;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // use a stringstream&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ipstr &amp;lt;&amp;lt; ((ip &amp;amp;0xff000000) &amp;gt;&amp;gt; 24)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Bitwise right shift&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&amp;lt; "." &amp;lt;&amp;lt; ((ip &amp;amp;0x00ff0000) &amp;gt;&amp;gt; 16)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&amp;lt; "." &amp;lt;&amp;lt; ((ip &amp;amp;0x0000ff00) &amp;gt;&amp;gt; 8)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&amp;lt; "." &amp;lt;&amp;lt; ((ip &amp;amp;0x000000ff));&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; return ipstr.str();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The program simplecpp.cpp&lt;br /&gt;
&lt;br /&gt;
#include "IPv4.h"&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
int main (int argc, char* argv[]) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; string ipstr;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // define variables&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned long ipint = 1347861486;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // The IP in integer form&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; GenericUtils::IPv4 iputils;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // create an object of the class&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ipstr = iputils.IPint_to_IPquad(ipint);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // call the class member&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; cout &amp;lt;&amp;lt; ipint &amp;lt;&amp;lt; " = " &amp;lt;&amp;lt; ipstr &amp;lt;&amp;lt; endl;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // print the result&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Compile and execute with:&lt;br /&gt;
&lt;br /&gt;
# g++ -c IPv4.cpp simplecpp.cpp&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Compile in objects&lt;br /&gt;
# g++ IPv4.o simplecpp.o -o simplecpp.exe&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Link the objects to final executable&lt;br /&gt;
# ./simplecpp.exe &lt;br /&gt;
1347861486 = 80.86.187.238&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Use ldd to check which libraries are used by the executable and where they are located. Also used to check if a shared library is missing or if the executable is static.&lt;br /&gt;
&lt;br /&gt;
# ldd /sbin/ifconfig&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # list dynamic object dependencies&lt;br /&gt;
# ar rcs staticlib.a *.o&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # create static archive&lt;br /&gt;
# ar t staticlib.a&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # print the objects list from the archive&lt;br /&gt;
# ar x /usr/lib/libc.a version.o&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # extract an object file from the archive&lt;br /&gt;
# nm version.o&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # show function members provided by object&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Simple Makefile&lt;br /&gt;
&lt;br /&gt;
The minimal Makefile for the multi-source program is shown below. The lines with instructions must begin with a tab! The back slash "\" can be used to cut long lines.&lt;br /&gt;
&lt;br /&gt;
CC = g++&lt;br /&gt;
CFLAGS = -O&lt;br /&gt;
OBJS = IPv4.o simplecpp.o&lt;br /&gt;
&lt;br /&gt;
simplecpp: ${OBJS}&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;${CC} -o simplecpp ${CFLAGS} ${OBJS}&lt;br /&gt;
clean:&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;rm -f ${TARGET} ${OBJS}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Online Help&lt;br /&gt;
&lt;br /&gt;
Documentation&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; Linux Documentation &amp;nbsp;&amp;nbsp; &amp;nbsp;en.tldp.org&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; Linux Man Pages &amp;nbsp;&amp;nbsp; &amp;nbsp;www.linuxmanpages.com&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; Linux commands directory &amp;nbsp;&amp;nbsp; &amp;nbsp;www.oreillynet.com/linux/cmd&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; Linux doc man howtos &amp;nbsp;&amp;nbsp; &amp;nbsp;linux.die.net&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; FreeBSD Handbook &amp;nbsp;&amp;nbsp; &amp;nbsp;www.freebsd.org/handbook&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; FreeBSD Man Pages &amp;nbsp;&amp;nbsp; &amp;nbsp;www.freebsd.org/cgi/man.cgi&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; FreeBSD user wiki &amp;nbsp;&amp;nbsp; &amp;nbsp;www.freebsdwiki.net&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; Solaris Man Pages &amp;nbsp;&amp;nbsp; &amp;nbsp;docs.sun.com/app/docs/coll/40.10&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Other Unix/Linux references&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; Rosetta Stone for Unix &amp;nbsp;&amp;nbsp; &amp;nbsp;bhami.com/rosetta.html (a Unix command translator)&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; Unix guide cross reference &amp;nbsp;&amp;nbsp; &amp;nbsp;unixguide.net/unixguide.shtml&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; Linux commands line list &amp;nbsp;&amp;nbsp; &amp;nbsp;www.linuxcmd.org&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; Short Linux reference &amp;nbsp;&amp;nbsp; &amp;nbsp;www.pixelbeat.org/cmdline.html&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; Little command line goodies &amp;nbsp;&amp;nbsp; &amp;nbsp;www.shell-fu.org&lt;br /&gt;
&lt;br /&gt;
http://cb.vu/unixtoolbox.xhtml#network &lt;br /&gt;
&lt;br /&gt;</description><author>emaknyus@gmail.com (tamvan &amp;amp; verani)</author></item><item><title>squid hardware</title><link>http://emaknyus.blogspot.com/2011/09/squid-hardware.html</link><category>hardware</category><category>squid</category><pubDate>Thu, 8 Sep 2011 08:42:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3787219161379371544.post-8011750714065769004</guid><description>Squid has a lot of parameters that are set in a file called squid.conf. 
These should be tuned according to the application. What I am describing
 below are changes to the default parameters that we needed for the 
Frontier application. The normal application for squid is to cache 
internet web pages, which is a bit different. For web pages there are 
lots and lots of rather small objects. In our applications there are 
relatively few objects, but they are much, much bigger.   You should use
 a squid of at least version squid-2.6.X to get collapsed_forwarding 
(see below).
Warning:  All versions of squid before September 2009 have a bug that 
affects Frontier performance, so you should use squid version 
squid-2.7.STABLE7 or later. If your squid might be feeding other squids 
then we highly recommend using &lt;a class="twikiLink" href="https://twiki.cern.ch/twiki/bin/view/CMS/SquidForCMS"&gt;our version&lt;/a&gt;
 as we have patches that have not yet (as of September 2010 at least) 
been incorporated by the squid project.  UNDER NO CIRCUMSTANCES use 
version squid-3.X as it is missing features and bug fixes essential to 
Frontier.&lt;br /&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
So for our application: 
&lt;br /&gt;
Basically, you have: 
&lt;br /&gt;
1) Essential changes for squid-2.6.X or earlier are:
&lt;br /&gt;
&lt;pre&gt;hierarchy stoplist cgi-bin
acl QUERY urlpath_regex cgi-bin&lt;/pre&gt;
These two changes allow queries with ? in the URL to be cached. By 
default squid does not cache dynamic web pages. Since the Frontier 
information is generated by TOMCAT, technically they are dynamic web 
pages. Without these two changes, Frontier won't work. (The default 
values of these two lines are: 
&lt;br /&gt;
&lt;pre&gt;hierarchy stoplist cgi-bin ?
acl QUERY urlpath_regex cgi-bin \?&lt;/pre&gt;
so it's not much.) 
&lt;br /&gt;
Things have changed a little starting from squid-2.7.X.
The "hierarchy stoplist" line still needs to be changed, but instead of the 
&lt;br /&gt;
&lt;pre&gt;acl QUERY urlpath_regex cgi-bin \?&lt;/pre&gt;
line there is a line:
&lt;br /&gt;
&lt;pre&gt;refresh_pattern -i (/cgi-bin/|\?) 0    0%      0&lt;/pre&gt;
that needs to be changed to:
&lt;br /&gt;
&lt;pre&gt;refresh_pattern -i /cgi-bin/    0       0%      0&lt;/pre&gt;
2) Hardware dependent changes 

&lt;br /&gt;
&lt;pre&gt;cache_mem
cache_dir&lt;/pre&gt;
You have to define a parameter cache_dir which tells the squid where to 
keep the information on disk and how large it should be. This should be 
at least 20000 megabytes but probably no more than 70% of the partition 
size (to allow room for log files and other uses).  The other hardware 
parameter is cache_mem.  The default cache_mem is only 8 MB and is 
probably a very old default and should be increased some, but we have 
found that squid performs better for large objects out of the disk cache
 than the memory cache.   We recommend at most 1/8 of the physical RAM 
and no more than 128 MB, leaving a lot of memory for disk buffering. 
&lt;br /&gt;
3) Tuning changes 
&lt;br /&gt;
&lt;pre&gt;maximum_object_size 1048576 KB              !or whatever is necessary
maximum_object_size_in_memory 128 KB

icp_port 0                              !this just disables icp &lt;/pre&gt;
The first item lets us cache objects up to 1 GB in size (which is a lot 
more than most web pages - the default is only 4 MB). To date, we have 
often cached tarballs up to 300 MB in size, and more might be needed. 
The second item lets us use the cache_mem we gave it above (the default 
is only 8 KB). 

icp is used to have peer caches communicate. If you have just one squid, it is safer just to turn it off. 
&lt;br /&gt;
An important option for squid-2.6 and later is: 
&lt;br /&gt;
&lt;pre&gt;collapsed_forwarding on &lt;/pre&gt;
This option combines requests agressively so that a file is retrieved 
only once from the origin server. This is a very good idea for computer 
farms so make sure it is on.

Finally, if your squid might possibly feed other squids then set this:
&lt;br /&gt;
&lt;pre&gt;ignore_ims_on_miss on&lt;/pre&gt;
The default for that option prevents caching when an upstream squid 
sends an If-Modified-Since request and the object isn't already cached.

4) Log file changes 
&lt;br /&gt;
&lt;pre&gt;strip_query_terms off
cache_store_log none&lt;/pre&gt;
we do this for Frontier, but not essential 
&lt;br /&gt;
Since the log files can get very big, we run a cron job every night to 
rotate the log files, keeping 10 days worth. The cron job runs a script 
that looks like: 
&lt;br /&gt;
&lt;pre&gt;#!/bin/bash 

SQUID_DIR=/nthome/bjb/frontier/frontier-cache/squid
FNCRON_DIR=/nthome/bjb/frontier/frontier-cache/utils/cron

$SQUID_DIR/sbin/squid -k rotate 2&amp;gt;&amp;amp;1 &amp;gt;&amp;gt; $FNCRON_DIR/daily.log &lt;/pre&gt;
You could also use a logrotate.d script.
&lt;br /&gt;
Daily might not be enough, however.  On heavily used squids we run 
another cron hourly that checks to see if access.log is greater than a 
chosen size and if so does an extra rotation.
&lt;br /&gt;
&lt;br /&gt;
&lt;hr /&gt;
That's basically it, except for one thing. For Frontier we monitor our 
squids remotely using SNMP. This is not turned on by default in squid, 
so to use it you have to turn it on at compilation time. If you want to 
use SNMP there are a few more settings needed in the squid.conf, 
especially the ACL access for whatever machines are allowed to read the 
SNMP information.  Scientific Linux/Redhat Enterprise Linux squid rpms 
should already have SNMP enabled at compilation time. Therefore, it 
should be possible to enable monitoring by adding something like the 
following to your squid.conf: 
&lt;br /&gt;
&lt;pre&gt;snmp_port 3401

acl HOST_MONITOR src 131.225.240.232/32 127.0.0.1/32 frontier.cern.ch
acl HOST_MONITOR_NAME srcdomain cmsdbsfrontier.cern.ch
acl snmppublic snmp_community public

snmp_access allow snmppublic HOST_MONITOR
snmp_access allow snmppublic HOST_MONITOR_NAME
snmp_access deny all&lt;/pre&gt;
all in the appropriate places in squid.conf. 
You may also need to open firewall and/or iptables holes for the 
addresses on the HOST_MONITOR line above.  The 131.* address is for the 
monitor at Fermilab and the cern.ch names are for the monitor at CERN.
&lt;br /&gt;
One thing you can do, is make a dummy installation of our tarball. It 
can be installed anywhere by any user. Then do a diff of your squid.conf
 with our squid.conf. For startup and shutdown procedures, you are on 
your own. 
&lt;br /&gt;
The compilation options we currently use are (Squid-2.6STABLE18 or later): 
&lt;br /&gt;
--disable-wccp --enable-snmp --disable-ident-lookups --with-large-files 
&lt;br /&gt;
(If you have a 64-bit OS, don't use --with-large-files)&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;

Hardware &lt;/h2&gt;
The first step is to decide what hardware you want to run the squid cache server on. These are some FAQ's
&lt;br /&gt;
1) Do I need to dedicate a node to squid and only squid?
&lt;br /&gt;
This is up to you. It is a good idea. It depends on how many jobs try to
 access the squid simultaneously and what else the machine is used for 
(see question 2). Large sites may need more than one squid(see question 
4). The node needs to have network access to the internet, and be 
visible to the worker nodes.
&lt;br /&gt;
2) What hardware specs (CPU, memory, diskcache)?
&lt;br /&gt;
For most purposes 2GHZ, 2GB, 100 GB should be adequate. This excludes 
the space needed for log files which is determined by how heavily the 
system is used and what the clean up schedule is. We assume something 
like rotate the logs every day and remove after 10 days. From what we 
have seen, the most critical resource is the memory. If the machine 
serves other purposes, make sure the other tasks don't use up all the 
memory. We see 5-10 % performance gains when using a 64-bit 
architecture. Scientific Linux 4 should have better IO than Scientific 
Linux 3. Squid runs as a single thread, so if that is the only use of 
the machine, having more than 2 cores is a waste. You should also avoid 
AFS, NFS and RAID for the cache_dir.
&lt;br /&gt;
Here is a description of squid memory usage: If you have a decent amount
 of spare memory, the kernel will use that as page cache, so it's a good
 chance that frequenty-requested items will, in fact, be served from RAM
 (via the page cache) even if it's not squid's RAM. There's also a 
design bottleneck in squid that limits cpu efficiency of large cache_mem
 objects, so resist the urge to give squid all your available memory. 
Let cache_mem handle your small objects and the kernel handle the larger
 ones.
&lt;br /&gt;
3) What network specs (Gigabit if you have it)?
&lt;br /&gt;
The latencies will be lower to the worker nodes if you have a large 
bandwidth. The network is always the bottleneck for this system, so "Gb 
if you got it" is the motto, but not an absolute requirement.  If you 
have many job slots, 2 bonded gigabit network connections is even 
better, and squid on one core of a modern CPU can pretty much keep up 
with 2 gigabits.  Squid is single-threaded so if you're able to supply 
more than 2 gigabits, multiple squid processes need to be used (consult 
with CMS frontier support for details if you want to try).
&lt;br /&gt;
4) How many squids do I need?
&lt;br /&gt;
Sites with over 500 job slots should have at least 2 squids for 
reliability.  We currently estimate that sites should have one gigabit 
on a squid per 500-1000 CMS job slots.  A lot depends on how quickly 
jobs start; an empty batch queue that suddenly fills up will need more 
squids.  If you don't have gigabit ethernet you will be able to handle 
fewer job slots.  The number of job slots that can be safely handled per
 gigabit increases as the number of slots increase because the chances 
that they all start at once tends to go down. 
&lt;br /&gt;
5) How should squids be load-balanced?
&lt;br /&gt;
There are many ways to configure multiple squids: round-robin DNS, 
load-balancing networking hardware, LVS, etc. The simplest thing to do 
is just set up two or more squids independently and let Frontier handle 
it by making a small addition to site-local-config.xml (see below under 
Multiple Squid Servers).  If there are many thousands of job slots, 
hardware-based load balancers can be easily overloaded so DNS-based or 
client-based load balancing will probably be called for.
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Responsible: &lt;a class="twikiLink" href="https://twiki.cern.ch/twiki/bin/view/Main/BarryBlumenfeld"&gt;BarryBlumenfeld&lt;/a&gt; </description><author>emaknyus@gmail.com (tamvan &amp;amp; verani)</author></item><item><title>linux network tune</title><link>http://emaknyus.blogspot.com/2011/09/linux-network-tune.html</link><category>conf</category><category>parameter</category><category>sysctl</category><pubDate>Thu, 8 Sep 2011 08:07:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3787219161379371544.post-1761119671929984500</guid><description>Don't try this yourself, you might break something.
These recommendations were from Pete Vogel, who runs a bigger site than 
you
do (can you do 85Mb/s on just one server? .. and he has many!!).
Don't change these params unless you understand them.  I am working
on adding explainations.  Amongst other things (like breaking your 
network connectivity), you might actually make your machine slower if 
you just blindly use them. In fact, I only set a couple of them. And 
always best to set one at
a time to see if you notice the improvement you are looking for.&lt;br /&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
&lt;pre&gt;echo 65534 &amp;gt; /proc/sys/fs/file-max
echo 1 &amp;gt; /proc/sys/net/ipv4/tcp_tw_recycle
echo 0 &amp;gt; /proc/sys/net/ipv4/tcp_window_scaling
echo 0 &amp;gt; /proc/sys/net/ipv4/tcp_timestamps
echo 0 &amp;gt; /proc/sys/net/ipv4/tcp_sack
echo 0 &amp;gt; /proc/sys/net/ipv4/tcp_ecn
echo 2 &amp;gt; /proc/sys/net/ipv4/tcp_orphan_retries
echo 1 &amp;gt; /proc/sys/net/ipv4/tcp_syncookies&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt; &lt;b&gt;/proc/sys/fs/file-max:&lt;/b&gt;
This is basically the number of file descriptors available in the kernel.
Which also effects the number of fd's a process can have open.
For large sites you will definately need to upgrade this, and for
some os'es you will need to use &lt;b&gt;ulimit&lt;/b&gt;
to increase the number of fd's available for that process.

For red-hat (and other linux's) you can use:
&lt;br /&gt;
&lt;pre&gt;echo 32767 &amp;gt; /proc/sys/fs/file-max&lt;/pre&gt;
which I put into /etc/rc.d/rc.local (at/near the end).
You can check your current usage using:
&lt;pre&gt;[cameron@jack cameron]$ &lt;b&gt;cat /proc/sys/fs/file-nr&lt;/b&gt;
5941	2844	32767
[cameron@jack cameron]$ &lt;/pre&gt;
and what this means is that since the kernel has been running the max number
of fd's in use was 5941, the current number is 2844, and the max available is
32767.

&lt;/li&gt;
&lt;li&gt; &lt;b&gt;/proc/sys/net/ipv4/tcp_tw_recycle:&lt;/b&gt;
&lt;pre&gt;BOOLEAN
	Enable fast recycling TIME-WAIT sockets. Default value is 1.
	It should not be changed without advice/request of technical
	experts.&lt;/pre&gt;
The definition of TIME_WAIT in "man netstat" is
&lt;pre&gt;       TIME_WAIT
              The socket is waiting after close to handle packets
              still in the network.&lt;/pre&gt;
On Red Hat, the default is 0, so I checked on
one of the loaded machines to see 2500 sockets in the TIME_WAIT state
&lt;pre&gt;[cameron@jack cameron]$ netstat -n | grep TIME_WAIT | wc
   2446   14676  198126
[cameron@jack cameron]$ netstat -n | wc
   2847   17104  230009&lt;/pre&gt;
As you can see, for me, this takes up a lot of the network resources.
By turning this on, I saw a slight drop in the number of connections 
(about 200), and a definate drop in the number of TIME_WAIT connections.
  I figured
that this was good.  I see that machine  handling slightly more traffic,
but my measuring mechanism is "poor". This is the next day after I made 
the change (at a busier time of the day).
&lt;pre&gt;[cameron@jack httpd-2.0.35]$ &lt;b&gt;netstat -n | grep TIME_WAIT | wc ; netstat -n | wc&lt;/b&gt;
   2291   13746  185571
   2905   17452  234696
[cameron@jack httpd-2.0.35]$ &lt;/pre&gt;
&lt;br /&gt;
So by turning it on, you should see a reduction in the number of FD's used
in the kernel, but you might get some extra junk traffic??

&lt;/li&gt;
&lt;li&gt; &lt;b&gt;/proc/sys/net/ipv4/tcp_window_scaling:&lt;/b&gt;
&lt;pre&gt;BOOLEN
	Enable window scaling as defined in &lt;a href="http://www.rfc-editor.org/rfc/rfc1323.txt" target="_blank"&gt;RFC1323&lt;/a&gt;&lt;/pre&gt;
These are recommendations to make TCP/IP work over very high speeds. 
I left the default at 1.

&lt;/li&gt;
&lt;li&gt; &lt;b&gt;/proc/sys/net/ipv4/tcp_timestamps:&lt;/b&gt; Todo
&lt;pre&gt;BOOLEAN
	Enable timestamps as defined in &lt;a href="http://www.rfc-editor.org/rfc/rfc1323.txt" target="_blank"&gt;RFC1323&lt;/a&gt;&lt;/pre&gt;
an except:
&lt;pre&gt;      On the other hand, a Timestamps option may appear in any data or
      ACK segment, adding 12 bytes to the 20-byte TCP header.  We
      believe that the bandwidth saved by reducing unnecessary
      retransmissions will more than pay for the extra header bandwidth.&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt; &lt;b&gt;/proc/sys/net/ipv4/tcp_sack:&lt;/b&gt;
&lt;pre&gt;BOOLEAN
	Enable select acknowledgments (SACKS).&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt; &lt;b&gt;/proc/sys/net/ipv4/tcp_ecn:&lt;/b&gt;
&lt;pre&gt;BOOLEAN
	Enable Explicit Congestion Notification in TCP.&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt; &lt;b&gt;/proc/sys/net/ipv4/tcp_orphan_retries:&lt;/b&gt;
&lt;pre&gt;INTEGER
	How may times to retry before killing TCP connection, closed
	by our side. Default value 7 corresponds to ~50sec-16min
	depending on RTO. If you machine is loaded WEB server,
	you should think about lowering this value, such sockets
	may consume significant resources. Cf. tcp_max_orphans.&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt; &lt;b&gt;/proc/sys/net/ipv4/tcp_syncookies:&lt;/b&gt;
&lt;pre&gt;BOOLEAN
	Only valid when the kernel was compiled with CONFIG_SYNCOOKIES
	Send out syncookies when the syn backlog queue of a socket 
	overflows. This is to prevent against the common 'syn flood attack'
	Default: FALSE

	Note, that syncookies is fallback facility.
	It MUST NOT be used to help highly loaded servers to stand
	against legal connection rate. If you see synflood warnings
	in your logs, but investigation	shows that they occur
	because of overload with legal connections, you should tune
	another parameters until this warning disappear.
	See: tcp_max_syn_backlog, tcp_synack_retries, tcp_abort_on_overflow.

	syncookies seriously violate TCP protocol, do not allow
	to use TCP extensions, can result in serious degradation
	of some services (f.e. SMTP relaying), visible not by you,
	but your clients and relays, contacting you. While you see
	synflood warnings in logs not being really flooded, your server
	is seriously misconfigured.&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;b&gt;MTU on DSL lines&lt;/b&gt;
&lt;br /&gt;
It is said that DSL wraps packets in it's own packet.  So for some DSL
connections decreasing your MTU (Maximum Transfer Unit), from 1500 to 1490 is
advantagous. You can do this using:
&lt;br /&gt;
&lt;pre&gt; ifconfig eth0 mtu 1490&lt;/pre&gt;
Which I then added to /etc/rc.d/rc.local (for red hat 7.2)


&lt;b&gt;Links:&lt;/b&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt; &lt;a href="http://hr.uoregon.edu/davidrl/Documentation/networking/ip-sysctl.txt"&gt;http://hr.uoregon.edu/davidrl/Documentation/networking/ip-sysctl.txt&lt;/a&gt; - &lt;a href="http://www.bloke.com/linux/kernel/ip-sysctl.txt"&gt;local copy&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
Last Change: Sunday, 06-Dec-2009 20:07:29 EST&lt;br /&gt;
http://www.bloke.com/linux/kernel/network.html </description><author>emaknyus@gmail.com (tamvan &amp;amp; verani)</author></item><item><title>mikrotik hardcoded</title><link>http://emaknyus.blogspot.com/2011/09/mikrotik-hardcoded.html</link><category>mikrotik</category><category>script</category><category>security</category><pubDate>Wed, 7 Sep 2011 18:38:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3787219161379371544.post-8111378032515282935</guid><description>&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN" style="font-size: 100%;"&gt;1. Lan card ada 2&lt;br /&gt;2. Alokasi IP address pada Mikrotik Hotspot Gateway :&lt;br /&gt;- to_hotspot ip public&lt;br /&gt;- to_hotspot 10.10.0.1/16&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-forward action=accept protocol=icmp icmp-options=8:0 limit=1,0 comment=”Allow ICMP”&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip
 firewall filter add chain=block-forward action=log tcp-flags=syn 
protocol=tcp limit=5/1m,0 log-prefix=”Firewalled packet:” comment=”# Log
 Forward”&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip
 firewall filter add chain=block-forward action=log protocol=icmp 
icmp-options=8:0 limit=10/1h,0 log-prefix=”PING of Death ???” comment=”#
 Log PING of Death”&lt;/span&gt;&lt;br /&gt;
&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-forward action=drop src-address=169.254.0.0/16 comment=”# Block bad IP address”&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-forward action=drop src-address=224.0.0.0/3&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-forward action=drop src-address=224.0.0.0/4&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-forward action=drop src-address=240.0.0.0/5&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-forward action=drop src-address=248.0.0.0/5&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-forward action=drop src-address=255.255.255.255&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-forward action=drop connection-state=invalid comment=”# Drop invalid connections”&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-input action=accept protocol=icmp icmp-options=8:0 limit=5,0 comment=”# Allow ICMP”&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip
 firewall filter add chain=block-input action=log protocol=icmp 
icmp-options=8:0 limit=10/1h,0 log-prefix=”PING of Death ???” comment=”#
 Log PING of Death”&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip
 firewall filter add chain=block-input action=log tcp-flags=syn 
protocol=tcp limit=5/1m,0 log-prefix=”Firewalled packet:” comment=”# Log
 input”&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-input action=drop protocol=icmp comment=”# Block PING of Death”&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip
 firewall filter add chain=block-input action=drop 
in-interface=to_internet src-address=10.0.0.0/8 comment=”# Interface 
facing Public Internet Inbound Section RFC 1918″&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-input action=drop in-interface=to_internet src-address=202.91.11.6&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-input action=drop in-interface=to_internet src-address=192.168.0.0/16&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-input action=drop in-interface=to_internet src-address=202.91.8.160/29&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-input action=drop src-address=0.0.0.0/8&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=input action=jump jump-target=block-input comment=”# Jump to block-input”&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=forward action=jump jump-target=block-forward comment=”# Jump to block-forward”&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=forward action=jump jump-target=block-ddos protocol=udp comment=”# Jump to block-ddos”&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=forward action=jump jump-target=block-service comment=”# Jump to block-service”&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip
 firewall filter add chain=block-service action=drop p2p=all-p2p 
comment=”# Block ports you don’t want it insert here ..:: drop p2p ::..”&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip
 firewall filter add chain=block-service action=drop 
out-interface=to_internet dst-port=5050 protocol=tcp comment=”..:: drop 
yahoo messenger ::..”&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip
 firewall filter add chain=block-service action=drop 
out-interface=to_internet dst-port=6666-7000 protocol=tcp comment=”..:: 
drop irc ::..”&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-input action=drop src-address=127.0.0.0/8&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-input action=drop src-address=169.254.0.0/16&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-input action=drop src-address=172.16.0.0/12&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-input action=drop src-address=192.0.2.0/24&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-input action=drop src-address=204.152.64.0/23&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-input action=drop src-address=224.0.0.0/3&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-input action=drop src-address=224.0.0.0/4&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-input action=drop src-address=240.0.0.0/5&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-input action=drop src-address=248.0.0.0/5&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-input action=drop src-address=255.255.255.255&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip
 firewall filter add chain=block-input action=drop 
in-interface=to_internet src-address=202.91.8.167 comment=”# Block Smurf
 Attack on all interface”&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-input action=drop in-interface=to_internet src-address=202.91.11.7&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-input action=drop in-interface=to_hotspot src-address=10.10.255.255&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-input action=drop in-interface=to_proxy src-address=192.168.100.255&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-input action=drop dst-port=113 protocol=tcp comment=”# Block Ident”&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-input action=drop fragment=yes comment=”# Block IP Frags”&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip
 firewall filter add chain=block-input action=drop 
ipv4-options=loose-source-routing comment=”# Blocked source routed 
packets lsrr and ssrr”&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-input action=drop ipv4-options=strict-source-routing&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip
 firewall filter add chain=block-input action=reject 
reject-with=tcp-reset in-interface=to_internet dst-port=80 protocol=tcp 
comment=”# Reject connection from internet to port 80”&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip
 firewall filter add chain=block-forward action=reject 
reject-with=tcp-reset tcp-flags=syn,ack connection-state=new 
protocol=tcp comment=”# Reject Bad TCP”&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-forward action=drop protocol=icmp comment=”# Block PING of Death”&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip
 firewall filter add chain=block-input action=drop 
in-interface=to_internet dst-port=23 protocol=tcp comment=”# Block 
Telnet come from Internet”&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip
 firewall filter add chain=block-input action=drop 
in-interface=to_hotspot dst-port=23 protocol=tcp comment=”# Block Telnet
 come from Hotspot”&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-forward action=drop dst-port=137-139 protocol=tcp comment=”# Block Netbios Sessions tcp”&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-input action=drop dst-port=137-139 protocol=tcp comment=”# Block Netbios Sessions tcp”&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-input action=drop dst-port=137-139 protocol=udp comment=”# Block Netbios Sessions udp”&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-forward action=drop dst-port=135-139 protocol=udp comment=”# Block Netbios Sessions udp”&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-ddos action=return limit=16,32&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-ddos action=log log-prefix=”DDOS ATTACK:”&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-ddos action=drop limit=16,32&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=input action=jump jump-target=block-ddos protocol=udp comment=”# Jump to block-ddos”&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip
 firewall filter add chain=tcp-flags action=jump jump-target=bad-flags 
tcp-flags=fin,!ack protocol=tcp comment=”# tcp-flags jumpt to bad-flags”&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=tcp-flags action=jump jump-target=bad-flags tcp-flags=psh,!ack protocol=tcp&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=tcp-flags action=jump jump-target=bad-flags tcp-flags=urg,!ack protocol=tcp&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=tcp-flags action=jump jump-target=bad-flags tcp-flags=fin,rst protocol=tcp&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=tcp-flags action=jump jump-target=bad-flags tcp-flags=fin,syn protocol=tcp&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=tcp-flags action=jump jump-target=bad-flags tcp-flags=syn,rst protocol=tcp&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=tcp-flags action=jump jump-target=bad-flags tcp-flags=fin,syn,rst,psh,ack,urg,ece,cwr protocol=tcp&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip
 firewall filter add chain=tcp-flags protocol=tcp action=jump 
jump-target=bad-flags tcp-flags=!fin,!syn,!rst,!psh,!ack,!urg,!ece,!cwr&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip
 firewall filter add chain=tcp-flags protocol=tcp action=jump 
jump-target=bad-flags tcp-flags=fin,psh,urg,!syn,!rst,!ack,!ece,!cwr&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip
 firewall filter add chain=tcp-flags action=jump jump-target=bad-flags 
tcp-flags=fin,syn,psh,urg,!rst,!ack,!ece,!cwr protocol=tcp&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip
 firewall filter add chain=tcp-flags action=jump jump-target=bad-flags 
tcp-flags=fin,syn,rst,ack,urg,!psh,!ece,!cwr protocol=tcp&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=input action=jump jump-target=tcp-flags protocol=tcp comment=”# Jump to tcp-flags”&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=bad-flags action=log log-prefix=”TCP BAD FLAGS:”&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=bad-flags action=drop&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=syn-flood action=return tcp-flags=syn,!fin,!rst,!ack protocol=tcp limit=5,10&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=syn-flood action=return protocol=!tcp&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=syn-flood action=return tcp-flags=!,syn,!fin,!rst,!ack protocol=tcp&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=syn-flood action=log log-prefix=”SYN FLOOD:”&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=syn-flood action=drop&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip
 firewall filter add chain=input action=jump jump-target=syn-flood 
tcp-flags=syn,!fin,!rst,!ack protocol=tcp comment=”# Jump to syn-flood”&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-forward action=drop dst-port=445 protocol=tcp comment=”# Block CIFS tcp”&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-forward action=drop dst-port=135 protocol=tcp comment=”# Block RPC Portmapper”&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-forward action=drop dst-port=135 protocol=udp&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-forward action=drop dst-port=111 protocol=tcp&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-input action=drop dst-port=135 protocol=tcp comment=”# Block RPC Portmapper”&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-input action=drop dst-port=135 protocol=udp&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-input action=drop dst-port=111 protocol=tcp&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-input action=drop dst-port=111 protocol=udp&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-input action=drop dst-port=445 protocol=tcp comment=”# Block CIFS tcp”&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-forward action=drop dst-port=111 protocol=udp&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-forward action=drop dst-port=69 protocol=tcp comment=”# Block TFTP”&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-input action=drop dst-port=69 protocol=tcp comment=”# Block TFTP”&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-input action=drop dst-port=69 protocol=udp&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-input action=drop dst-port=20034 protocol=tcp comment=”# Block Netbus”&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-input action=drop dst-port=20034 protocol=udp&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-input action=drop dst-port=3133 protocol=tcp comment=”# Block Back0riffice”&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-input action=drop dst-port=3133 protocol=udp&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-forward action=drop dst-port=69 protocol=udp&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-forward action=drop dst-port=20034 protocol=tcp comment=”# Block Netbus”&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-forward action=drop dst-port=20034 protocol=udp&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-forward action=drop dst-port=3133 protocol=tcp comment=”# Block Back0riffice”&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-forward action=drop dst-port=3133 protocol=udp&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-input action=drop dst-port=2049 protocol=udp comment=”# Block NFS”&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-input action=drop dst-port=2049 protocol=tcp&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-forward action=drop dst-port=2049 protocol=udp comment=”# Block NFS”&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip firewall filter add chain=block-forward action=drop dst-port=2049 protocol=tcp&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-family: verdana;"&gt;
&lt;span lang="IN"&gt;/ip
 firewall filter add chain=block-service action=drop 
out-interface=to_internet dst-port=1818 protocol=tcp comment=”# Block 
Game online”&lt;/span&gt;&lt;/div&gt;
&lt;span lang="IN" style="font-family: verdana;"&gt;/ip firewall filter add chain=block-service action=drop out-interface=to_internet dst-port=6112 protocol=tcp&lt;/span&gt;</description><author>emaknyus@gmail.com (tamvan &amp;amp; verani)</author></item><item><title>Stop Denial of Service attacks</title><link>http://emaknyus.blogspot.com/2011/09/stop-denial-of-service-attacks.html</link><category>ddos</category><category>ddos mitigation</category><category>security</category><category>type attack</category><pubDate>Wed, 7 Sep 2011 18:37:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3787219161379371544.post-5064535821662709921</guid><description>
Taking advantage of a known problem with the Operating System or any 
running services on the target, a good programmer can build an 
application that sends some data that causes the targeted system to 
crash.
&lt;br /&gt;
&lt;br /&gt;
The worst case scenario is not when a hacker crashes a service, but when
 it finds a way to maximize the CPU usage causing a total malfunction on
 the system.
&lt;br /&gt;
&lt;br /&gt;
Of course most of the attacks are not initiated by these kind of 
programmers, but by "script kiddies" who only read about it, find the 
program's source over the web and just use it without knowing the 
mechanisms it uses.
&lt;br /&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
Usually, DoS attacks are closely related to brute force attacks. The 
brute force attack uses all combinations of possible characters or 
dictionary word lists to try find out any passwords on the system (eg 
root accounts). When a root account in a network is found out, any DoS 
attacks can be done easily over the specific network.&lt;br /&gt;
&lt;br /&gt;
Here are some of the most known DoS attacks:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;

&lt;h2&gt;
1. SYN Floods&lt;/h2&gt;
You should know that when a client and a server want to transmit data over the TCP protocol, a three-way handshake occurs:&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;The client asks for a connection with a SYN (synchronize) package&lt;/li&gt;
&lt;li&gt;The server replies to the client with a SYN-ACK (syn-acknowledgments)&lt;/li&gt;
&lt;li&gt;The client sends a third packages as a ACK and the transmission of the data starts.&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
The SYN flood works by sending SYN packets from false IP addresses (IP 
spoofing). The server replies to that false IP address with an SYN-ACK 
and then waits for ACK. Doing this many times will cause the server to 
end up in the impossibility of opening new connection, creating a 
network congestion.&lt;br /&gt;
&lt;br /&gt;
Another SYN flood attack involves sending a packet to the server, 
spoofed with the server's address (let's say the server's IP is 
192.168.1.20 then you send a SYN packet from 192.168.1.20 to 
192.168.1.20). Repeating this many times will make the server sending 
SYN-ACK and ACK to itself, blocking it.
&lt;br /&gt;
&lt;br /&gt;
Patches to this kind of attack used a connection number limit from the 
same source/timeframe. SYN cookies also hold down the handling of the 
packets until the sender's IP address is verified.&lt;br /&gt;
&lt;h2&gt;
2. SMURF attacks&lt;/h2&gt;
In this kind of attacks a massive amount of ping traffic (ICMP echos) is
 sent to the broadcast address of the network. The source IP address is 
spoofed to look like the target's. If this traffic is forwarded to the 
network, all hosts will reply with an echo to the target, believing that
 they receive an echo request (PING) from it. In a large networks, a 
targeted server for example can be flooded by hundreds of replies at 
once. By sending the spoofed packet several times, the server will be 
flooded until it crashes from the overload.
&lt;br /&gt;
&lt;br /&gt;
This kind of attacks were mostly patched by making the routers not forwarding broadcast directed traffic to the network.&lt;br /&gt;
&lt;h2&gt;
3. LAND attacks&lt;/h2&gt;
LAND attacks take advantage of opened network services on the target. By
 using a port sniffer, opened ports and services are found out. Then 
spoofed packages are sent with IP address source the same as IP address 
destination (server's address) to make it reply to itself. Let's say for
 example that it uses SNMP (simple network management protocol - service
 used to report network and system's usage). By making a SNMP service to
 reply to itself continuously it finally crashes.&lt;br /&gt;
&lt;h2&gt;
4. Ping of death&lt;/h2&gt;
This type of DoS attack takes advantage of a known issue with Windows 9x
 and older NT stations, as well as Linux prior to 2.0.32. Many routers 
and printers older then 1998 are vulnerable to this too.&lt;br /&gt;
It works by sending a malformed format of a ping packet. Usually, ping 
packets are small-sized (like 32bytes or 64bytes by default). Older 
Operating Systems and other devices could not handle ping larger than 
the maximum IP packet size of 65535 bytes (defined by RFC 791). By 
sending a large packet or a malformed one, any system that doesn't know 
how to handle it crashes (eg. in Windows 9x a blue screen of death was 
generated).&lt;br /&gt;
Patches are available on the web for any old operating systems or devices.&lt;br /&gt;
&lt;h2&gt;
5. Ping flooding&lt;/h2&gt;
This is probably the simplest DoS attack that exists. It is also the 
most used. It works by overwhelming the target with echo requests 
(pings) having large packets. The target has it's bandwidth occupied by 
these requests already and floods itself by starting to reply back. Of 
course, the attacker must have a larger bandwidth than the target (for 
example flooding a dial-up user from a 1Mbps connection).&lt;br /&gt;
With the increase of the servers' bandwidth, this type of attacks became useless for an ADSL user for instance. &lt;br /&gt;
The "problem" was solved by using multiple hosts, creating the first DDoS attacks (distributed denial of service).&lt;br /&gt;
DDoS attacks work by owning let's say 50 boxes each with 1Mbps 
bandwidth. Then the attacker uses all of them to ping flood the target, 
creating a great amount of traffic on the host.&lt;br /&gt;
Stacheldraht for example is a console that connects to owned boxes 
running Stacheldraht server. It then coordinates the attacks from a 
single point.&lt;br /&gt;
The solution to this type of attacks is the firewall, which filters any 
echo replies from being sent. Of course, firewalls can be crashed as 
well.&lt;br /&gt;
&lt;h2&gt;
6. Fraggle attacks&lt;/h2&gt;
A fraggle attack takes place when an attacker send massive amount of UDP
 echo data to network broadcast addresses, using a the target's IP as 
the packet's source. All hosts reply to the target, flooding it. It 
usually uses UDP PORT 7 (echo). This code was written by the same person
 who written the smurf attack.&lt;br /&gt;
&lt;h2&gt;
7. Teardrop attacks&lt;/h2&gt;
This attack involves packets sent by the attacker to the target with 
oversized payloads. This exploits a bug in the TCP/IP protocol stack, 
crashing the system. Only Windows 3.11, 95 and Linux prior to 2.0.32 
were vulnerable to this kind of attack.&lt;br /&gt;
&lt;h2&gt;
8. Other type of attacks&lt;/h2&gt;
Other type of attacks involve application flooding, like IRC bot raw 
line which usually crash Windows boxes running mIRC or any other client.
 These attacks are based on a greater number of raw socket transactions 
than a computer can handle.&lt;br /&gt;
&lt;br /&gt;
http://www.tutorial5.com/content/view/80/79/ </description><author>emaknyus@gmail.com (tamvan &amp;amp; verani)</author></item><item><title>Drop Akses Client Untuk Traceroute</title><link>http://emaknyus.blogspot.com/2011/09/drop-akses-client-untuk-traceroute.html</link><category>mikrotik</category><category>script</category><category>security</category><pubDate>Wed, 7 Sep 2011 18:34:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3787219161379371544.post-3710532704048553399</guid><description>&lt;div&gt;
Mungkin karena adanya suatu alasan penting sehingga client dalam 
suatu jaringan dilarang untuk melakukan traceroute keluar. Jika memang 
ini harus diperlukan maka, kita harus mempertimbangkannya kembali, 
mengingat tidak ada yang harus dikhawatirkan terhadap traceroute ini. 
Kembali kepada permasalahan awal, mungkin dikarenakan adanya suatu 
alasan yang penting sekali sehingga akses untuk traceroute pada client 
pun harus di block ~_~&lt;/div&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;div&gt;
Rule dibawah ini akan melakukan drop kepada client yang mencoba untuk melakukan traceroute keluar (forward):&lt;/div&gt;
&lt;br /&gt;&lt;blockquote&gt;
/ip firewall filter &lt;br /&gt;&lt;br /&gt;add chain=forward protocol=icmp \&lt;br /&gt;&lt;br /&gt;icmp-options=11:0 action=drop&lt;br /&gt;&lt;br /&gt;add chain=forward protocol=icmp \&lt;br /&gt;&lt;br /&gt;icmp-options=3:3 action=drop&lt;/blockquote&gt;
&lt;br /&gt;&lt;div&gt;
Dengan
 rule diatas, semua akses keluar dari client akan di drop ketika 
melakukan traceroute. Jika menginginkan ip tertentu saja yang hendak 
didrop cukup menambahkan src-address=ip yang dimaksud. Sebagai contoh 
pada ip client 192.168.10.20 akses untuk traceroute di block, maka 
rulenya menjadi:&lt;/div&gt;
&lt;br /&gt;&lt;blockquote&gt;
/ip firewall filter &lt;br /&gt;&lt;br /&gt;add chain=forward src-address=192.168.10.20 \&lt;br /&gt;&lt;br /&gt;protocol=icmp icmp-options=11:0 action=drop&lt;br /&gt;&lt;br /&gt;add chain=forward src-address=192.168.10.20 \&lt;br /&gt;&lt;br /&gt;protocol=icmp icmp-options=3:3 action=drop&lt;/blockquote&gt;
&lt;br /&gt;&lt;div&gt;
Jika
 ip tertentu lebih dari satu, maka gunakan 
src-address-list=nama_list_address_nya dengan catatan list-address yang 
dimaksud telah ditambahkan ip tertentu nya.&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;Salam Codet.&lt;div class=""&gt;
http://feeds.feedburner.com/blogspot/KLBuX&lt;img src="https://s-external.ak.fbcdn.net/safe_image.php?d=AQA1Rd_6-E7aiBbk&amp;amp;url=https%3A%2F%2Fblogger.googleusercontent.com%2Ftracker%2F6806369089159941977-2689687372916246040%3Fl%3Dasadi-febriyan.blogspot.com" /&gt;&lt;/div&gt;
</description><author>emaknyus@gmail.com (tamvan &amp;amp; verani)</author></item><item><title>Block TCP Flag rst</title><link>http://emaknyus.blogspot.com/2011/09/block-tcp-flag-rst.html</link><category>mikrotik</category><category>security</category><pubDate>Wed, 7 Sep 2011 18:33:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3787219161379371544.post-5438763181878325083</guid><description>&lt;div&gt;
Mengapa TCP Flag rst diblock ? Untuk penjelasan lanjutan tentang TCP Flag rst, silahkan dibuka kembali halaman &lt;a href="http://asadi-febriyan.blogspot.com/2011/05/transmission-control-protocol-flag.html" rel="nofollow" target="_blank"&gt;Transmission Control Protocol Flag&lt;/a&gt;,
 jika dirasa tidak diperlukan, maka sebaiknya di block saja karena 
dikhawatirkan hanya akan menjadi sebab terjadinya kesalahan konfigurasi 
atau kesalahan-kesalahan lainnya mengingat sifat dasar dari tcp flag rst
 ini adalah respon atas permintaan pembuatan koneksi.&lt;/div&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;div&gt;
Cukup ketikkan rule dibawah ini pada MikroTik, maka akses tcp dengan flag rst telah dapat diblock.&lt;/div&gt;
&lt;br /&gt;&lt;blockquote&gt;
/ip firewall filter&lt;br /&gt;&lt;br /&gt;add chain=input protocol=tcp tcp-flags=rst \&lt;br /&gt;&lt;br /&gt;action=drop comment="block tcp rst"&lt;/blockquote&gt;
&lt;br /&gt;&lt;br /&gt;Dan letakkan diatas input dengan action drop lainnya.</description><author>emaknyus@gmail.com (tamvan &amp;amp; verani)</author></item><item><title>Mencegah User Agar Tidak Bisa Membuka LAN Setting Pada Window Dengan Hide Tool</title><link>http://emaknyus.blogspot.com/2011/09/mencegah-user-agar-tidak-bisa-membuka.html</link><category>tool</category><category>trick</category><category>windows</category><pubDate>Wed, 7 Sep 2011 18:31:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3787219161379371544.post-5889902193681879001</guid><description>&lt;div style="text-align: justify;"&gt;
Terkadang ada diantara beberapa user 
yang sekedar iseng mengganti ip-address nya sendiri, entah ingin tahu 
atau ada maksud lain. Tetapi pada sisi admin dan system hal tersebut 
sedikit menjengkelkan karena dengan bergantinya ip address tersebut ada 
beberapa konfigurasi yang tidak berjalan dengan semestinya.&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
Dengan Aplikasi Hide Tool ini, itu 
bisa diamankankan dengan menutup dialog box Internet Protocol (TCP/IP) 
pada LAN Connection Properties.&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
Bagi anda yang belum mengetahui tentang Hide Tool, silahkan membuka &lt;a href="http://asadi-febriyan.blogspot.com/2011/05/hide-tools-child-control-block-program.html" target="_blank"&gt;artikel pada blog ini&lt;/a&gt;. Download dan install Aplikasi tersebut.&lt;/div&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
Buka dialog Box TCP/IP Properties, Lihat gambar dan catatlah header nya (yang dilingkari dengan warna merah).&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgy15I5wc9ZA3seMf2HLEvextkT5SKsYy9zIJPDUrdBKH_-zBuHP6xD3OC8eQQY4J4onA8mgwowIqAA0yS-b6dvhgmKb6TUYXSwfOCGdgHWn3-XMLk55sPOX4eK0FibkZWcsAkuBqUvoiw/s1600/wwww.jpg" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgy15I5wc9ZA3seMf2HLEvextkT5SKsYy9zIJPDUrdBKH_-zBuHP6xD3OC8eQQY4J4onA8mgwowIqAA0yS-b6dvhgmKb6TUYXSwfOCGdgHWn3-XMLk55sPOX4eK0FibkZWcsAkuBqUvoiw/s320/wwww.jpg" width="294" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
Kemudian buka Hide Tool, pada menu 
"Block Windows" tambahkan (add) tulisan header yang dicatat tersebut ke 
dalam list block windows. Close, dan jangan lupa untuk mengaktifkannya.&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDB264iy1Fbdqnl1XZz-VbYIdBImpSrXdNz0DR0sVB4JV5QMJAnWOiNWyva_7gl2LXEnq_0sbsl9HyFfo-rp7CLQhpOLvm3pbQ-olCrNT0Dw66eDhur8M6ye47bsK4RfilGHX3D0ElWbU/s1600/wwww2.jpg" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="236" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDB264iy1Fbdqnl1XZz-VbYIdBImpSrXdNz0DR0sVB4JV5QMJAnWOiNWyva_7gl2LXEnq_0sbsl9HyFfo-rp7CLQhpOLvm3pbQ-olCrNT0Dw66eDhur8M6ye47bsK4RfilGHX3D0ElWbU/s320/wwww2.jpg" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
Ketika user membuka TCP/IP Properties,
 maka akan tertutup secara otomatis, sehingga tidak bisa mengganti Ip 
address. Cara yang sama bisa dilakukan terhadap Dos-Prompt untuk 
menghindari pergantian IP melalui dos-prompt tersebut, dan berlaku pula 
cara yang sama terhadap aplikasi lainnya didalam windows yang memiliki 
header (judul) pada dialog box nya.&lt;/div&gt;
</description><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgy15I5wc9ZA3seMf2HLEvextkT5SKsYy9zIJPDUrdBKH_-zBuHP6xD3OC8eQQY4J4onA8mgwowIqAA0yS-b6dvhgmKb6TUYXSwfOCGdgHWn3-XMLk55sPOX4eK0FibkZWcsAkuBqUvoiw/s72-c/wwww.jpg" width="72"/><author>emaknyus@gmail.com (tamvan &amp;amp; verani)</author></item><item><title>Tipe-Tipe Serangan Denial Of Service Berikut Penangkalnya Pada MikroTik</title><link>http://emaknyus.blogspot.com/2011/09/tipe-tipe-serangan-denial-of-service.html</link><category>mikrotik</category><category>script</category><category>security</category><pubDate>Wed, 7 Sep 2011 18:30:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3787219161379371544.post-4015535196066860088</guid><description>&lt;div&gt;
Denial of service yang biasa disingkat dan disebut DOS (bukan 
dos-prompt microsoft) merupakan salah satu tipe serangan attacker kearah
 jaringan yang bertujuan untuk menghentikan sementara atau selamanya 
fungsi operasi dari sebuah system.&lt;/div&gt;
&lt;br /&gt;&lt;div&gt;
Secara umum ada 4 macam
 jenis serangan DOS, walaupun tidak menutup kemungkinan terjadinya flood
 atau jenis serangan DOS lainnya. Sekaligus disini juga akan dituliskan 
rule penangkalnya pada MikroTik Router dengan asumsi MikroTik RouterOS 
telah difungsikan sebagai router sebelumnya serta jalur koneksi telah 
benar (invalid, stabilished, related dan sebagainya). 4 type serangan 
DOS terdiri dari:&lt;/div&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;b&gt;1. Ping Of Death.&lt;/b&gt;&lt;br /&gt;&lt;div&gt;
Attackers 
mengirimkan serangkaian paket data ke target yang tidak sesuai ketentuan
 aturan jaringan. Jika secara terus menerus bisa mengakibatkan jalur 
koneksi penuh dan berakibat drop nya server karena tidak bisa menampung 
kebutuhan tersebut.&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;Penangkalnya, buat rule dengan accept icmp yang ter-filter:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;
/ip firewall filter&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;add chain=input protocol=icmp action=jump jump-target=icmp&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;add chain=icmp protocol=icmp icmp-options=0:0-255 limit=5,5 action=accept comment="Limited Ping Flood" disabled=no&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;add chain=icmp protocol=icmp icmp-options=3:3 limit=5,5 action=accept comment="" disabled=no&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;add chain=icmp protocol=icmp icmp-options=3:4 limit=5,5 action=accept comment="" disabled=no&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;add chain=icmp protocol=icmp icmp-options=8:0-255 limit=5,5 action=accept comment="" disabled=no&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;add chain=icmp protocol=icmp icmp-options=11:0-255 limit=5,5 action=accept comment="" disabled=no&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;add chain=icmp protocol=icmp action=drop comment="" disabled=no&lt;/blockquote&gt;
&lt;br /&gt;&lt;b&gt;2. SYN Flood.&lt;/b&gt;&lt;br /&gt;&lt;div&gt;
Attackers
 mengirimkan paket TCP SYN ke objek target, sehingga berdampak objek 
target mengalami hang karena harus menyelesaikan proses koneksi dalam 
jumlah yang tak terbatas dan berakibat resources yang dimiliki mengalami
 drop.&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;Penangkalnya, buat rule dengan accept TCP-SYN yang ter-filter:&lt;br /&gt;&lt;blockquote&gt;
/ip firewall filter&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;add
 chain=input protocol=tcp tcp-flags=syn connection-state=new action=jump
 jump-target=SYN-Protect comment="Flood protect" disabled=no&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;add chain=SYN-Protect protocol=tcp tcp-flags=syn limit=400,5 connection-state=new action=accept comment="" disabled=no&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;add chain=SYN-Protect protocol=tcp tcp-flags=syn connection-state=new action=drop comment="" disabled=no&lt;/blockquote&gt;
&lt;br /&gt;&lt;b&gt;3. Land/Lattiera.&lt;/b&gt;&lt;br /&gt;&lt;div&gt;
Serangan
 yang dilakukan oleh Attackers dengan mengirimkan paket SYN, yang 
memiliki alamat port/source yang sama dengan objek target.&lt;/div&gt;
&lt;br /&gt;&lt;div&gt;
Penangkalnya,
 lakukan hal yang sama pada cara menangkal SYN-FLOOD, hanya saja disini 
ditambahkan "chain forward" akses SYN, yang mana dibelokkan (jump) ke 
"chain SYN-Protect". Sehingga rule-nya menjadi seperti berikut:&lt;/div&gt;
&lt;blockquote&gt;
/ip firewall filter&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;add
 chain=forward protocol=tcp tcp-flags=syn connection-state=new 
action=jump jump-target=SYN-Protect comment="Flood protect" disabled=no&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;add chain=input protocol=tcp tcp-flags=syn connection-state=new action=jump jump-target=SYN-Protect comment="" disabled=no&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;add chain=SYN-Protect protocol=tcp tcp-flags=syn limit=400,5 connection-state=new action=accept comment="" disabled=no&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;add chain=SYN-Protect protocol=tcp tcp-flags=syn connection-state=new action=drop comment="" disabled=no&lt;/blockquote&gt;
&lt;br /&gt;&lt;b&gt;4. WinNuke.&lt;/b&gt;&lt;br /&gt;&lt;div&gt;
Pengiriman
 data OOB/ORG pada koneksi dengan menggunakan TCP ke port 139 (NetBios 
Session/SMB) yang berakibat OS (dalam hal ini adalah windows) mengalami 
hang.&lt;/div&gt;
&lt;br /&gt;&lt;div&gt;
Penangkalnya, tutup protocol tcp yang menggunakan 
port 139, begitu juga protocol udp port 139 untuk menghindari hal yang 
tidak diinginkan:&lt;/div&gt;
&lt;blockquote&gt;
/ip web-proxy direct &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;add dst-port=139 action=deny comment="" disabled=no&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;/ip firewall mangle&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;add chain=prerouting protocol=tcp dst-port=139 action=mark-connection new-connection-mark=drop-port&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;add chain=prerouting protocol=udp dst-port=139 action=mark-connection new-connection-mark=drop-port&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;/ip firewall filter&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;add chain=input connection-mark=drop-port action=drop comment="drop port" disabled=no&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;add chain=forward connection-mark=drop-port action=drop comment="" disabled=no&lt;/blockquote&gt;
&lt;br /&gt;&lt;div&gt;
Sengaja
 ditambahkan rule "forward" yang mana artinya koneksi tersebut berasal 
dari jaringan dalam, untuk menghindari hal yang tidak diinginkan, 
terkadang Attacker juga bisa berasal dari dalam jaringan kita sendiri.&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;Salam Codet&lt;div class=""&gt;
http://feeds.feedburner.com/blogspot/KLBuX&lt;/div&gt;
&lt;div class=""&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div class=""&gt;
https://www.facebook.com/pages/GreenBerret/206210029408584 &lt;/div&gt;
&lt;div class=""&gt;
&lt;/div&gt;
&lt;div class=""&gt;
&lt;img src="http://external.ak.fbcdn.net/safe_image.php?d=AQDOirjXPR6BQ3tm&amp;amp;url=https%3A%2F%2Fblogger.googleusercontent.com%2Ftracker%2F6806369089159941977-3859794662988460945%3Fl%3Dasadi-febriyan.blogspot.com" /&gt;&lt;/div&gt;
</description><author>emaknyus@gmail.com (tamvan &amp;amp; verani)</author></item><item><title>Mikrotik rogue dhcp detection</title><link>http://emaknyus.blogspot.com/2011/09/mikrotik-rogue-dhcp-detection.html</link><category>dhcp attack</category><category>mikrotik</category><category>rogue</category><category>security</category><pubDate>Tue, 6 Sep 2011 18:55:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3787219161379371544.post-3682403622070478693</guid><description>Mikrotik actually has a rogue detection service you can configure, 
but as we have found running apartment complexes, it can give you false 
positives.  To combat this, I’ve come up with a new method.&lt;br /&gt;

First configure syslog exporting with the DHCP service dumping.  Next
 enable the dhcp client to run on all your inside facing interfaces.  
I’ve got my &lt;a href="http://gregsowell.com/?p=40"&gt;Cacti&lt;/a&gt; syslog 
server set to match “dhcp,info,debug dhcp-client%got ip address”, which 
is the message sent when the dhcp client receives an IP address.  Once 
the syslog server processes the message it sends us an alert.&lt;br /&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;

Add dhcp-client to each interface, be sure to disable default route, peer dns and peer ntp.&lt;br /&gt;


&lt;div class="wp_syntax"&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class="line_numbers"&gt;&lt;pre&gt;1
2
3&lt;/pre&gt;
&lt;/td&gt;&lt;td class="code"&gt;&lt;pre class="text" style="font-family: monospace;"&gt;/ ip dhcp-client 
add interface=vlan10 comment="" disabled=no 
add interface=ether2 comment="" disabled=no&lt;/pre&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
This script will need to be scheduled to run around every hour or so.
  It will release the dhcp reservation on your interfaces.  Otherwise it
 won’t attempt to pull a new address until the old allocation has 
expired, which can be up to a year.  It loops through releasing from all
 your interfaces.&lt;br /&gt;


&lt;div class="wp_syntax"&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class="line_numbers"&gt;&lt;pre&gt;1
2
3
4&lt;/pre&gt;
&lt;/td&gt;&lt;td class="code"&gt;&lt;pre class="text" style="font-family: monospace;"&gt;:log info ("dhcp detect release")
:for e from=0 to=40 do={
/ip dhcp-client release ($e)
}&lt;/pre&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
Once you get an alert from your syslog server, you log into the Mikrotik and issue the:&lt;br /&gt;


&lt;div class="wp_syntax"&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class="line_numbers"&gt;&lt;pre&gt;1&lt;/pre&gt;
&lt;/td&gt;&lt;td class="code"&gt;&lt;pre class="text" style="font-family: monospace;"&gt;/ip dhcp-client print detail&lt;/pre&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
You’ll get the following:&lt;br /&gt;

&lt;blockquote&gt;
Flags: X – disabled, I – invalid&lt;br /&gt;
 0   interface=vlan10 status=bound address=192.168.1.100/24&lt;br /&gt;
     gateway=192.168.1.1 dhcp-server=192.168.1.1&lt;br /&gt;
     primary-dns=209.189.224.45 secondary-dns=209.189.224.40&lt;br /&gt;
     expires-after=21h13m2s&lt;/blockquote&gt;
Take the dhcp-server address and use it below:&lt;br /&gt;


&lt;div class="wp_syntax"&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class="line_numbers"&gt;&lt;pre&gt;1&lt;/pre&gt;
&lt;/td&gt;&lt;td class="code"&gt;&lt;pre class="text" style="font-family: monospace;"&gt;/ip arp print where address="192.168.1.1"&lt;/pre&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
You will get the following result:&lt;br /&gt;

&lt;blockquote&gt;
Flags: X – disabled, I – invalid, H – DHCP, D – dynamic&lt;br /&gt;
 #   ADDRESS         MAC-ADDRESS       INTERFACE&lt;br /&gt;
 0 D 192.168.0.253   00:08:74:4B:7F:BC ether1&lt;/blockquote&gt;
Now you track this guy down and shut him off at the switch port, or if you are using mac-track in &lt;a href="http://gregsowell.com/?p=40"&gt;cacti&lt;/a&gt;,
 you simply look him up, connect to the proper switch and kill him.  You
 could also use this in conjunction with the standard rogue detection 
service to more quickly find the MAC address&lt;br /&gt;
&lt;br /&gt;
http://gregsowell.com/?p=349 </description><author>emaknyus@gmail.com (tamvan &amp;amp; verani)</author></item><item><title>Mikrotik port knocking with ICMP Ping</title><link>http://emaknyus.blogspot.com/2011/09/mikrotik-port-knocking-with-icmp-ping.html</link><category>icmp</category><category>mikrotik</category><category>script</category><category>security</category><pubDate>Tue, 6 Sep 2011 18:54:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3787219161379371544.post-4199056706823583732</guid><description>&lt;div class="entry-content"&gt;

		Port knocking is a very easy and simple way to secure your network 
services. There are many ways to use port knocking: using a series of 
UDP packes towards different ports with some content, or just sending a 
series of SYN packets on different ports.&lt;br /&gt;

These methods usually requires a program to do the task.&lt;br /&gt;

Ping, however, is usually available from any device.&lt;br /&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;

&lt;span id="more-162"&gt;&lt;/span&gt;&lt;br /&gt;

&lt;strong&gt;We now want to open for SSH in to our Mikrotik by pinging the WAN adresse with a packet size of 5000 :&lt;/strong&gt;&lt;br /&gt;

&lt;a href="http://www.datapels.com/?attachment_id=166" rel="attachment wp-att-166"&gt;&lt;img alt="" class="alignleft size-full wp-image-166" height="242" src="http://www.datapels.com/wp-content/uploads/2011/05/icmp.png" width="435" /&gt;&lt;/a&gt;&lt;br /&gt;

&lt;br /&gt;

&lt;br /&gt;

&lt;br /&gt;

&lt;br /&gt;

&lt;br /&gt;

Type in your favorite number / code + 28&lt;br /&gt;

i.e: my favorite number is 5000, but because of some overhead we have to add 28 to the number&lt;br /&gt;

5000 + 28 = 5028&lt;br /&gt;

&lt;br /&gt;

&lt;a href="http://www.datapels.com/?attachment_id=167" rel="attachment wp-att-167"&gt;&lt;img alt="" class="alignleft size-full wp-image-167" height="473" src="http://www.datapels.com/wp-content/uploads/2011/05/packet.png" width="384" /&gt;&lt;/a&gt;&lt;br /&gt;

&lt;br /&gt;

&lt;br /&gt;

&lt;br /&gt;

&lt;br /&gt;

&lt;br /&gt;

&lt;br /&gt;

&lt;br /&gt;

&lt;br /&gt;

&lt;br /&gt;

&lt;br /&gt;

&lt;br /&gt;

&lt;br /&gt;

&lt;br /&gt;

Then you have to add you src address to an address list:&lt;br /&gt;

&lt;a href="http://www.datapels.com/?attachment_id=168" rel="attachment wp-att-168"&gt;&lt;img alt="" class="alignleft size-full wp-image-168" height="247" src="http://www.datapels.com/wp-content/uploads/2011/05/src.png" width="277" /&gt;&lt;/a&gt;&lt;br /&gt;

&lt;br /&gt;

&lt;br /&gt;

&lt;br /&gt;

&lt;br /&gt;

&lt;br /&gt;

&lt;br /&gt;

&lt;br /&gt;

&lt;br /&gt;

Now make a new rule:&lt;br /&gt;
&lt;a href="http://www.datapels.com/?attachment_id=169" rel="attachment wp-att-169"&gt;&lt;img alt="" class="alignleft size-full wp-image-169" height="234" src="http://www.datapels.com/wp-content/uploads/2011/05/fwrule.png" width="284" /&gt;&lt;/a&gt;&lt;br /&gt;

&lt;br /&gt;

&lt;br /&gt;

&lt;br /&gt;

&lt;br /&gt;

&lt;br /&gt;

&lt;br /&gt;

&lt;br /&gt;

&lt;br /&gt;

Add the src address list :&lt;br /&gt;
&lt;a href="http://www.datapels.com/?attachment_id=170" rel="attachment wp-att-170"&gt;&lt;img alt="" class="alignleft size-full wp-image-170" height="153" src="http://www.datapels.com/wp-content/uploads/2011/05/allowknow.png" width="444" /&gt;&lt;/a&gt;&lt;br /&gt;

&lt;br /&gt;

&lt;br /&gt;

&lt;br /&gt;

&lt;br /&gt;

&lt;br /&gt;

Testing:&lt;br /&gt;
&lt;a href="http://www.datapels.com/?attachment_id=175" rel="attachment wp-att-175"&gt;&lt;img alt="" class="alignnone size-full wp-image-175" height="351" src="http://www.datapels.com/wp-content/uploads/2011/05/test.png" width="580" /&gt;&lt;/a&gt;&lt;br /&gt;

&lt;br /&gt;

Perfect!&lt;br /&gt;
http://www.datapels.com/?p=162 &lt;br /&gt;

			&lt;/div&gt;
</description><author>emaknyus@gmail.com (tamvan &amp;amp; verani)</author></item><item><title>implementation prerouting and postrouting</title><link>http://emaknyus.blogspot.com/2011/09/implementation-prerouting-and.html</link><category>implementation</category><category>nat</category><pubDate>Mon, 5 Sep 2011 23:50:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3787219161379371544.post-8662641574015406894</guid><description>
							The DNAT target is used to do Destination Network Address Translation, which means
							that it is used to rewrite the &lt;code class="ENVAR"&gt;Destination IP&lt;/code&gt; address
							of a packet. If a packet is matched, and this is the target of the rule, the packet,
							and all subsequent packets in the same stream will be translated, and then routed
							on to the correct device, host or network. This target can be extremely useful,
							for example,when you have a host running your web server inside a &lt;span class="emphasis"&gt;
								&lt;i class="EMPHASIS"&gt;LAN&lt;/i&gt;&lt;/span&gt;, but no real IP to give it that will work
							on the Internet. You could then tell the firewall to forward all packets going to
							its own HTTP port, on to the real web server within the &lt;span class="emphasis"&gt;&lt;i class="EMPHASIS"&gt;LAN&lt;/i&gt;&lt;/span&gt;. We may also specify a whole range of destination
							IP addresses, and the DNAT mechanism will choose the destination IP address at random
							for each stream. Hence, we will be able to deal with a kind of load balancing by
							doing this.&lt;br /&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;

						
							Note that the DNAT target is only available within the PREROUTING and OUTPUT chains
							in the nat table, and any of the chains called upon from any of those listed chains.
							Note that chains containing DNAT targets may not be used from any other chains,
							such as the POSTROUTING chain.
						&lt;br /&gt;

						&lt;div class="TABLE"&gt;

							
							
								&lt;b&gt;Table 11-5. DNAT target options&lt;/b&gt;&lt;br /&gt;

							&lt;table border="1" class="CALSTABLE" frame="border" rules="all"&gt;
								&lt;col width="77"&gt;&lt;/col&gt;
								&lt;col width="1*"&gt;&lt;/col&gt;
								&lt;tbody&gt;
&lt;tr&gt;
										&lt;td&gt;
											Option&lt;/td&gt;
										&lt;td&gt;
											--to-destination&lt;/td&gt;
									&lt;/tr&gt;
&lt;tr&gt;
										&lt;td&gt;
											Example&lt;/td&gt;
										&lt;td&gt;
											iptables -t nat -A PREROUTING -p tcp -d 15.45.23.67 --dport 80 -j DNAT --to-destination
											192.168.1.1-192.168.1.10
										&lt;/td&gt;
									&lt;/tr&gt;
&lt;tr&gt;
										&lt;td&gt;
											Explanation&lt;/td&gt;
										&lt;td&gt;
											The --to-destination option tells the DNAT mechanism which Destination IP to set
											in the IP header, and where to send packets that are matched. The above example
											would send on all packets destined for IP address 15.45.23.67 to a range of &lt;span class="emphasis"&gt;&lt;i class="EMPHASIS"&gt;LAN&lt;/i&gt;&lt;/span&gt; IP's, namely 192.168.1.1
											through 10. Note, as described previously, that a single stream will always use
											the same host, and that each stream will randomly be given an IP address that it
											will always be Destined for, within that stream. We could also have specified only
											one IP address, in which case we would always be connected to the same host. Also
											note that we may add a port or port range to which the traffic would be redirected
											to. This is done by adding, for example, an :80 statement to the IP addresses to
											which we want to DNAT the packets. A rule could then look like --to-destination
											192.168.1.1:80 for example, or like --to-destination 192.168.1.1:80-100 if we wanted
											to specify a port range. As you can see, the syntax is pretty much the same for
											the DNAT target, as for the SNAT target even though they do two totally different
											things. Do note that port specifications are only valid for rules that specify the
											TCP or UDP protocols with the --protocol option.
										&lt;/td&gt;
									&lt;/tr&gt;
&lt;/tbody&gt;
							&lt;/table&gt;
&lt;/div&gt;
Since DNAT requires quite a lot of work to work properly, I have decided to add
							a larger explanation on how to work with it. Let's take a brief example on how things
							would be done normally. We want to publish our website via our Internet connection.
							We only have one IP address, and the HTTP server is located on our internal network.
							Our firewall has the external IP address $INET_IP, and our HTTP server has the internal
							IP address $HTTP_IP and finally the firewall has the internal IP address $LAN_IP.
							The first thing to do is to add the following simple rule to the PREROUTING chain
							in the nat table:
						&lt;br /&gt;

						&lt;pre class="SCREEN"&gt;iptables -t nat -A PREROUTING --dst $INET_IP -p tcp --dport 80 -j DNAT \
--to-destination $HTTP_IP
	&lt;/pre&gt;
Now, all packets from the Internet going to port 80 on our firewall are redirected
							(or DNAT'ed) to our internal HTTP server. If you test this from the Internet, everything
							should work just perfect. So, what happens if you try connecting from a host on
							the same local network as the HTTP server? It will simply not work. This is a problem
							with routing really. We start out by dissecting what happens in a normal case. The
							external box has IP address $EXT_BOX, to maintain readability.
						&lt;br /&gt;

						&lt;ol&gt;
&lt;li&gt;
								
									Packet leaves the connecting host going to $INET_IP and source $EXT_BOX.
								&lt;br /&gt;

							&lt;/li&gt;
&lt;li&gt;
								
									Packet reaches the firewall.
								&lt;br /&gt;

							&lt;/li&gt;
&lt;li&gt;
								
									Firewall DNAT's the packet and runs the packet through all different chains etcetera.
								&lt;br /&gt;

							&lt;/li&gt;
&lt;li&gt;
								
									Packet leaves the firewall and travels to the $HTTP_IP.
								&lt;br /&gt;

							&lt;/li&gt;
&lt;li&gt;
								
									Packet reaches the HTTP server, and the HTTP box replies back through the firewall,
									if that is the box that the routing database has entered as the gateway for $EXT_BOX.
									Normally, this would be the default gateway of the HTTP server.
								&lt;br /&gt;

							&lt;/li&gt;
&lt;li&gt;
								
									Firewall Un-DNAT's the packet again, so the packet looks as if it was replied to
									from the firewall itself.
								&lt;br /&gt;

							&lt;/li&gt;
&lt;li&gt;
								
									Reply packet travels as usual back to the client $EXT_BOX.
								&lt;br /&gt;

							&lt;/li&gt;
&lt;/ol&gt;
Now, we will consider what happens if the packet was instead generated by a client
							on the same network as the HTTP server itself. The client has the IP address $LAN_BOX,
							while the rest of the machines maintain the same settings.
						&lt;br /&gt;

						&lt;ol&gt;
&lt;li&gt;
								
									Packet leaves $LAN_BOX to $INET_IP.
								&lt;br /&gt;

							&lt;/li&gt;
&lt;li&gt;
								
									The packet reaches the firewall.
								&lt;br /&gt;

							&lt;/li&gt;
&lt;li&gt;
								
									The packet gets DNAT'ed, and all other required actions are taken, however, the
									packet is not SNAT'ed, so the same source IP address is used on the packet.
								&lt;br /&gt;

							&lt;/li&gt;
&lt;li&gt;
								
									The packet leaves the firewall and reaches the HTTP server.
								&lt;br /&gt;

							&lt;/li&gt;
&lt;li&gt;
								
									The HTTP server tries to respond to the packet, and sees in the routing databases
									that the packet came from a local box on the same network, and hence tries to send
									the packet directly to the original source IP address (which now becomes the destination
									IP address).
								&lt;br /&gt;

							&lt;/li&gt;
&lt;li&gt;
								
									The packet reaches the client, and the client gets confused since the return packet
									does not come from the host that it sent the original request to. Hence, the client
									drops the reply packet, and waits for the "real" reply.
								&lt;br /&gt;

							&lt;/li&gt;
&lt;/ol&gt;
The simple solution to this problem is to SNAT all packets entering the firewall
							and leaving for a host or IP that we know we do DNAT to. For example, consider the
							above rule. We SNAT the packets entering our firewall that are destined for $HTTP_IP
							port 80 so that they look as if they came from $LAN_IP. This will force the HTTP
							server to send the packets back to our firewall, which Un-DNAT's the packets and
							sends them on to the client. The rule would look something like this:
						&lt;br /&gt;

						&lt;pre class="SCREEN"&gt;iptables -t nat -A POSTROUTING -p tcp --dst $HTTP_IP --dport 80 -j SNAT \
--to-source $LAN_IP
	&lt;/pre&gt;
Remember that the POSTROUTING chain is processed last of the chains, and hence the
							packet will already be DNAT'ed once it reaches that specific chain. This is the
							reason that we match the packets based on the internal address.
						&lt;br /&gt;

						&lt;div class="WARNING"&gt;

							&lt;table border="0" class="WARNING"&gt;
								&lt;tbody&gt;
&lt;tr&gt;
										&lt;td align="center" style="width: 25px;" valign="top"&gt;
											&lt;img alt="Warning" src="http://www.iptables.info/files/warning.gif" /&gt;&lt;/td&gt;
										&lt;td align="left" valign="top"&gt;
											
												This last rule will seriously harm your logging, so it is really advisable not to
												use this method, but the whole example is still a valid one. What will happen is
												this, packet comes from the Internet, gets SNAT'ed and DNAT'ed, and finally hits
												the HTTP server (for example). The HTTP server now only sees the request as if it
												was coming from the firewall, and hence logs &lt;span class="emphasis"&gt;&lt;i class="EMPHASIS"&gt;
													all&lt;/i&gt;&lt;/span&gt; requests from the internet as if they came from the firewall.
											&lt;br /&gt;

											
												This can also have even more severe implications. Take an SMTP server on the LAN,
												that allows requests from the internal network, and you have your firewall set up
												to forward SMTP traffic to it. You have now effectively created an open relay SMTP
												server, with horrenduously bad logging!
											&lt;br /&gt;

											
												One solution to this problem is to simply make the SNAT rule even more specific
												in the match part, and to only work on packets that come in from our LAN interface.
												In other words, add a --src $LAN_IP_RANGE to the whole command as well. This will
												make the rule only work on streams that come in from the LAN, and hence will not
												affect the Source IP, so the logs will look correct, except for streams coming from
												our LAN.
											&lt;br /&gt;

											
												You will, in other words, be better off solving these problems by either setting
												up a separate DNS server for your LAN, or to actually set up a separate DMZ, the
												latter being preferred if you have the money.
											&lt;br /&gt;

										&lt;/td&gt;
									&lt;/tr&gt;
&lt;/tbody&gt;
							&lt;/table&gt;
&lt;/div&gt;
You think this should be enough by now, and it really is, unless considering one
							final aspect to this whole scenario. What if the firewall itself tries to access
							the HTTP server, where will it go? As it looks now, it will unfortunately try to
							get to its own HTTP server, and not the server residing on $HTTP_IP. To get around
							this, we need to add a DNAT rule in the OUTPUT chain as well. Following the above
							example, this should look something like the following:
						&lt;br /&gt;

						&lt;pre class="SCREEN"&gt;iptables -t nat -A OUTPUT --dst $INET_IP -p tcp --dport 80 -j DNAT \
--to-destination $HTTP_IP
	&lt;/pre&gt;
Adding this final rule should get everything up and running. All separate networks
							that do not sit on the same net as the HTTP server will run smoothly, all hosts
							on the same network as the HTTP server will be able to connect and finally, the
							firewall will be able to do proper connections as well. Now everything works and
							no problems should arise.
						&lt;br /&gt;

						&lt;div class="NOTE"&gt;

							&lt;table border="0" class="NOTE"&gt;
								&lt;tbody&gt;
&lt;tr&gt;
										&lt;td align="center" style="width: 25px;" valign="top"&gt;
											&lt;img alt="Note" src="http://www.iptables.info/files/note.gif" /&gt;&lt;/td&gt;
										&lt;td align="left" valign="top"&gt;
											
												Everyone should realize that these rules only affect how the packet is DNAT'ed and
												SNAT'ed properly. In addition to these rules, you may also need extra rules in the
												filter table (FORWARD chain) to allow the packets to traverse through those chains
												as well. Don't forget that all packets have already gone through the PREROUTING
												chain, and should hence have their destination addresses rewritten already by DNAT.
											&lt;br /&gt;

										&lt;/td&gt;
									&lt;/tr&gt;
&lt;/tbody&gt;
							&lt;/table&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;table border="0" class="NOTE"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td align="center" style="width: 25px;" valign="top"&gt;
											&lt;img alt="Note" src="http://www.iptables.info/files/note.gif" /&gt;&lt;/td&gt;
										&lt;td align="left" valign="top"&gt;
											
												Works under Linux kernel 2.3, 2.4, 2.5 and 2.6.&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table border="0" class="NOTE"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td align="left" valign="top"&gt;&lt;br /&gt;
http://www.iptables.info/en/iptables-targets-and-jumps.html#DNATTARGET &lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
</description><author>emaknyus@gmail.com (tamvan &amp;amp; verani)</author></item><item><title>mikrotik nat</title><link>http://emaknyus.blogspot.com/2011/09/mikrotik-nat.html</link><category>mikrotik</category><category>nat</category><pubDate>Mon, 5 Sep 2011 22:18:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3787219161379371544.post-7853925641806138222</guid><description>&lt;h3&gt;
 &lt;span class="mw-headline" id="Source_NAT"&gt;Source NAT&lt;/span&gt;&lt;/h3&gt;
If you want to "hide" the private LAN 192.168.0.0/24 "behind" one 
address 10.5.8.109 given to you by the ISP, you should use the source 
network address translation (masquerading) feature of the MikroTik 
router. The masquerading will change the source IP address and port of 
the packets originated from the network 192.168.0.0/24 to the address 
10.5.8.109 of the router when the packet is routed through it.
&lt;br /&gt;


To use masquerading, a source NAT rule with action 'masquerade' should be added to the firewall configuration:
&lt;br /&gt;
&lt;pre&gt;/ip firewall nat add chain=srcnat action=masquerade out-interface=Public&lt;/pre&gt;
All outgoing connections from the network 192.168.0.0/24 will have 
source address 10.5.8.109 of the router and source port above 1024. No 
access from the Internet will be possible to the Local addresses. If you
 want to allow connections to the server on the local network, you 
should use destination Network Address Translation (NAT).
&lt;br /&gt;


&lt;h3&gt;
 &lt;span class="mw-headline" id="Destination_NAT"&gt;Destination NAT&lt;/span&gt;&lt;/h3&gt;
If you want to link Public IP 10.5.8.200 address to Local one 
192.168.0.109, you should use destination address translation feature of
 the MikroTik router. Also if you want allow Local server to talk with 
outside with given Public IP you should use source address translation, 
too.
&lt;br /&gt;


Add Public IP to Public interface:
&lt;br /&gt;
&lt;pre&gt;/ip address add address=10.5.8.200/32 interface=Public   &lt;/pre&gt;
Add rule allowing access to the internal server from external networks:
&lt;br /&gt;

&lt;pre&gt;/ip firewall nat add chain=dstnat dst-address=10.5.8.200 action=dst-nat \
	to-addresses=192.168.0.109 &lt;/pre&gt;
Add rule allowing the internal server to talk to the outer networks having its source address translated to 10.5.8.200:
&lt;br /&gt;

&lt;pre&gt;/ip firewall nat add chain=srcnat src-address=192.168.0.109 action=src-nat \
	to-addresses=10.5.8.200&lt;/pre&gt;
&lt;h3&gt;
 &lt;span class="mw-headline" id="1:1_mapping"&gt;1:1 mapping&lt;/span&gt;&lt;/h3&gt;
If you want to link Public IP subnet 11.11.11.0/24 to local one 
2.2.2.0/24, you should use destination address translation and source 
address translation features with action=netmap.
&lt;br /&gt;
&lt;pre&gt;/ip firewall nat add chain=dstnat dst-address=11.11.11.1-11.11.11.254 \
	action=netmap to-addresses=2.2.2.1-2.2.2.254

/ip firewall nat add chain=srcnat src-address=2.2.2.1-2.2.2.254 \
	action=netmap to-addresses=11.11.11.1-11.11.11.254  &lt;/pre&gt;
&lt;h3&gt;
 &lt;span class="mw-headline" id="Port_mapping"&gt;Port mapping&lt;/span&gt;&lt;/h3&gt;
If you would like to direct requests for a certain port to an 
internal machine (sometimes called opening a port, port mapping), you 
can do it like this:&lt;br /&gt;

&lt;pre&gt;/ip firewall nat add chain=dstnat dst-port=1234 action=dst-nat protocol=tcp to-address=192.168.1.1 to-port=1234 
&lt;/pre&gt;
This rule translates to: &lt;i&gt;when an incoming connection requests TCP 
port 1234, use the DST-NAT action and redirect it to local address 
192.168.1.1 and the port 1234&lt;/i&gt;
</description><author>emaknyus@gmail.com (tamvan &amp;amp; verani)</author></item><item><title>Saying How To Mangle The Packets</title><link>http://emaknyus.blogspot.com/2011/09/saying-how-to-mangle-packets.html</link><category>dnat</category><category>masquerade</category><category>nat</category><category>port mapping</category><category>snat</category><category>srcnat</category><pubDate>Mon, 5 Sep 2011 22:13:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3787219161379371544.post-4802564064071067614</guid><description>So now we know how to select the packets we want to mangle.  To
complete our rule, we need to tell the kernel exactly what we want it
to do to the packets.&lt;br /&gt;


&lt;h2&gt;
&lt;a href="" name="ss6.1"&gt;6.1&lt;/a&gt; &lt;a href="http://www.netfilter.org/documentation/HOWTO/NAT-HOWTO.html#toc6.1"&gt;Source NAT&lt;/a&gt;
&lt;/h2&gt;
You want to do Source NAT; change the source address of connections
to something different.  This is done in the POSTROUTING chain, just
before it is finally sent out; this is an important detail, since it
means that anything else on the Linux box itself (routing, packet
filtering) will see the packet unchanged.  It also means that the `-o'
(outgoing interface) option can be used.&lt;br /&gt;


Source NAT is specified using `-j SNAT', and the `--to-source'
option specifies an IP address, a range of IP addresses, and an
optional port or range of ports (for UDP and TCP protocols only).&lt;br /&gt;


&lt;br /&gt;
&lt;blockquote&gt;
&lt;code&gt;
&lt;/code&gt;&lt;pre&gt;## Change source addresses to 1.2.3.4.
# iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to 1.2.3.4

## Change source addresses to 1.2.3.4, 1.2.3.5 or 1.2.3.6
# iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to 1.2.3.4-1.2.3.6

## Change source addresses to 1.2.3.4, ports 1-1023
# iptables -t nat -A POSTROUTING -p tcp -o eth0 -j SNAT --to 1.2.3.4:1-1023&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;



&lt;h3&gt;
Masquerading&lt;/h3&gt;
There is a specialized case of Source NAT called masquerading: it
should only be used for dynamically-assigned IP addresses, such as
standard dialups (for static IP addresses, use SNAT above).&lt;br /&gt;


You don't need to put in the source address explicitly with
masquerading: it will use the source address of the interface the
packet is going out from.  But more importantly, if the link goes
down, the connections (which are now lost anyway) are forgotten,
meaning fewer glitches when connection comes back up with a new IP
address.&lt;br /&gt;


&lt;br /&gt;
&lt;blockquote&gt;
&lt;code&gt;
&lt;/code&gt;&lt;pre&gt;## Masquerade everything out ppp0.
# iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;h2&gt;
&lt;a href="" name="ss6.2"&gt;6.2&lt;/a&gt; &lt;a href="http://www.netfilter.org/documentation/HOWTO/NAT-HOWTO.html#toc6.2"&gt;Destination NAT&lt;/a&gt;
&lt;/h2&gt;
This is done in the PREROUTING chain, just as the packet comes in;
this means that anything else on the Linux box itself (routing, packet
filtering) will see the packet going to its `real' destination.  It
also means that the `-i' (incoming interface) option can be used.&lt;br /&gt;


Destination NAT is specified using `-j DNAT', and the
`--to-destination' option specifies an IP address, a range of IP
addresses, and an optional port or range of ports (for UDP and TCP
protocols only).&lt;br /&gt;


&lt;br /&gt;
&lt;blockquote&gt;
&lt;code&gt;
&lt;/code&gt;&lt;pre&gt;## Change destination addresses to 5.6.7.8
# iptables -t nat -A PREROUTING -i eth0 -j DNAT --to 5.6.7.8

## Change destination addresses to 5.6.7.8, 5.6.7.9 or 5.6.7.10.
# iptables -t nat -A PREROUTING -i eth0 -j DNAT --to 5.6.7.8-5.6.7.10

## Change destination addresses of web traffic to 5.6.7.8, port 8080.
# iptables -t nat -A PREROUTING -p tcp --dport 80 -i eth0 \
        -j DNAT --to 5.6.7.8:8080&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;h3&gt;
Redirection&lt;/h3&gt;
There is a specialized case of Destination NAT called redirection:
it is a simple convenience which is exactly equivalent to doing DNAT
to the address of the incoming interface.&lt;br /&gt;


&lt;br /&gt;
&lt;blockquote&gt;
&lt;code&gt;
&lt;/code&gt;&lt;pre&gt;## Send incoming port-80 web traffic to our squid (transparent) proxy
# iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 \
        -j REDIRECT --to-port 3128&lt;/pre&gt;
&lt;/blockquote&gt;
Note that squid needs to be configured to know it's a transparent proxy!&lt;br /&gt;


&lt;h2&gt;
&lt;a href="" name="ss6.3"&gt;6.3&lt;/a&gt; &lt;a href="http://www.netfilter.org/documentation/HOWTO/NAT-HOWTO.html#toc6.3"&gt;Mappings In Depth&lt;/a&gt;
&lt;/h2&gt;
There are some subtleties to NAT which most people will never have
to deal with.  They are documented here for the curious.&lt;br /&gt;


&lt;h3&gt;
Selection Of Multiple Addresses in a Range&lt;/h3&gt;
If a range of IP addresses is given, the IP address to use is
chosen based on the least currently used IP for connections the
machine knows about.  This gives primitive load-balancing.&lt;br /&gt;


&lt;h3&gt;
Creating Null NAT Mappings&lt;/h3&gt;
You can use the `-j ACCEPT' target to let a connection through
without any NAT taking place.&lt;br /&gt;


&lt;h3&gt;
Standard NAT Behavior&lt;/h3&gt;
The default behavior is to alter the connection as little as
possible, within the constraints of the rule given by the user.  This
means we won't remap ports unless we have to.&lt;br /&gt;


&lt;h3&gt;
Implicit Source Port Mapping&lt;/h3&gt;
Even when no NAT is requested for a connection, source port
translation may occur implicitly, if another connection has been
mapped over the new one.  Consider the case of masquerading, which
is rather common:&lt;br /&gt;


&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt; A web connection is established by a box 192.1.1.1 from port
1024 to www.netscape.com port 80.
&lt;/li&gt;
&lt;li&gt; This is masqueraded by the masquerading box to use its source
IP address (1.2.3.4).
&lt;/li&gt;
&lt;li&gt; The masquerading box tries to make a web connection to
www.netscape.com port 80 from 1.2.3.4 (its external interface
address) port 1024.
&lt;/li&gt;
&lt;li&gt; The NAT code will alter the source port of the second
connection to 1025, so that the two don't clash.&lt;/li&gt;
&lt;/ol&gt;
When this implicit source mapping occurs, ports are divided into
three classes:
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt; Ports below 512&lt;/li&gt;
&lt;li&gt; Ports between 512 and 1023&lt;/li&gt;
&lt;li&gt; Ports 1024 and above.&lt;/li&gt;
&lt;/ul&gt;
A port will never be implicitly mapped into a different class.&lt;br /&gt;


&lt;h3&gt;
What Happens When NAT Fails&lt;/h3&gt;
If there is no way to uniquely map a connection as the user
requests, it will be dropped.  This also applies to packets which
could not be classified as part of any connection, because they are
malformed, or the box is out of memory, etc.&lt;br /&gt;


&lt;h3&gt;
Multiple Mappings, Overlap and Clashes&lt;/h3&gt;
You can have NAT rules which map packets onto the same range; the
NAT code is clever enough to avoid clashes.  Hence having two rules
which map the source address 192.168.1.1 and 192.168.1.2 respectively
onto 1.2.3.4 is fine.&lt;br /&gt;


Furthermore, you can map over real, used IP addresses, as long as
those addresses pass through the mapping box as well.  So if you have
an assigned network (1.2.3.0/24), but have one internal network using
those addresses and one using the Private Internet Addresses
192.168.1.0/24, you can simply NAT the 192.168.1.0/24 source addresses
onto the 1.2.3.0 network, without fear of clashing:&lt;br /&gt;


&lt;br /&gt;
&lt;blockquote&gt;
&lt;code&gt;
&lt;/code&gt;&lt;pre&gt;# iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o eth1 \
        -j SNAT --to 1.2.3.0/24&lt;/pre&gt;
&lt;/blockquote&gt;
The same logic applies to addresses used by the NAT box itself:
this is how masquerading works (by sharing the interface address
between masqueraded packets and `real' packets coming from the box
itself).&lt;br /&gt;


Moreover, you can map the same packets onto many different targets,
and they will be shared.  For example, if you don't want to map
anything over 1.2.3.5, you could do:&lt;br /&gt;


&lt;br /&gt;
&lt;blockquote&gt;
&lt;code&gt;
&lt;/code&gt;&lt;pre&gt;# iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o eth1 \
        -j SNAT --to 1.2.3.0-1.2.3.4 --to 1.2.3.6-1.2.3.254&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;h3&gt;
Altering the Destination of Locally-Generated Connections&lt;/h3&gt;
The NAT code allows you to insert DNAT rules in the OUTPUT chain,
but this is not fully supported in 2.4 (it can be, but it requires a
new configuration option, some testing, and a fair bit of coding, so
unless someone contracts Rusty to write it, I wouldn't expect it
soon).&lt;br /&gt;


The current limitation is that you can only change the destination
to the local machine (e.g. `j DNAT --to 127.0.0.1'), not to any other
machine, otherwise the replies won't be translated correctly.&lt;br /&gt;
&lt;br /&gt;
http://www.netfilter.org/documentation/HOWTO/NAT-HOWTO-6.html </description><author>emaknyus@gmail.com (tamvan &amp;amp; verani)</author></item><item><title>When AND Why Proxy-ARP</title><link>http://emaknyus.blogspot.com/2011/09/when-and-why-proxy-arp.html</link><category>arp</category><category>proxy arp</category><pubDate>Mon, 5 Sep 2011 22:11:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3787219161379371544.post-8403573987256974645</guid><description>In my training classes, I go to great lengths to teach when and why 
proxy arp is necessary on an interface.&amp;nbsp; I have seen (and answered) 
numerous questions on my mailing lists regarding proxy arp and it seems 
it is time to create an article that I can just point people to.&amp;nbsp; I will
 focus this article on Mikrotik RouterOS (as many of my articles are), 
but it should be noted that proxy arp is not unique to Mikrotik.&lt;br /&gt;

&lt;span id="more-196"&gt;&lt;/span&gt;If you do not already understand what ARP 
is, then you will need to understand that before this article will make 
much sense.&amp;nbsp; ARP, which stands for “Address Resloution Protocol”, in 
simple terms is a mechanism that makes it possible for devices that are 
on an Ethernet-like network communicate.&amp;nbsp; Let’s take a very simple 
example where we have 2 devices plugged into an Ethernet switch using IP
 addresses &lt;span style="color: blue;"&gt;192.168.1.1&lt;/span&gt; for &lt;span style="color: blue;"&gt;device A&lt;/span&gt; and &lt;span style="color: red;"&gt;192.168.1.2&lt;/span&gt; for &lt;span style="color: red;"&gt;device B&lt;/span&gt;
 and subnet mask /24 (255.255.255.0).&amp;nbsp; These devices can communicate at 
layer 3 directly, because they are in the same subnet.&amp;nbsp; If Device A 
needs to send an IP packet to Device B, it will need to send that packet
 via the Ethernet switch.&amp;nbsp; This means that the IP packet will need to be
 framed in an Ethernet frame.&amp;nbsp; Device A already knows the IP address it 
needs to communicate with, but it needs a method to determine which MAC 
(Ethernet address) is associated with that IP address.&amp;nbsp; This is where 
ARP comes in.&lt;br /&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;

In the above circumstance, Device A will know that Device B is 
plugged into the same Ethernet segment because it’s subnet is the same 
as it’s own.&amp;nbsp; In order to determine which MAC address is associated with
 the IP 192.168.1.2, Device A will send a packet onto the Ethernet 
segment that is destined to the Ethernet Broadcast address.&amp;nbsp; This 
address is one that every device plugged into the switch will “hear” and
 “inspect”.&amp;nbsp; This packet includes a request asking “Who has 
192.168.1.2?”.&amp;nbsp; Every device on the segment will “hear” this request, 
but only one device will “own” that IP and respond.&amp;nbsp; The response will 
be something like “192.168.1.2 is at 00:12:34:56:78:9A”.&amp;nbsp; Now Device A 
knows the MAC address that is associated with the IP address 192.168.1.2
 and it can frame the IP packet and send it out the Ethernet interface.&lt;br /&gt;

The above description is very much shortened, but should give you 
some understanding of the process.&amp;nbsp; It is important to note that both 
Device A and Device B MUST be connected to the same LAN segment.&amp;nbsp; The 
ARP process is needed only for LAYER 2 addressing purposes.&lt;br /&gt;

So, let’s take a look at a situation where proxy arp would be necessary.&amp;nbsp; Consider this network diagram:&lt;br /&gt;

&lt;img alt="Proxy Arp Network" class="aligncenter size-full wp-image-198" height="386" src="http://blog.butchevans.com/wp-content/uploads/2010/06/proxyarp1.gif" title="proxyarp1" width="640" /&gt;&lt;br /&gt;

In the above network, we have a client device that could be a Windows
 PC, Laptop or another router.&amp;nbsp; For the purpose of this explanation, we 
need to assume it is not a router.&amp;nbsp; The reason for this assumption is 
that the behaviour of a router may (or may not) be different than I will
 describe.&amp;nbsp; Let’s assume for a moment that the router (on the right) 
assigns this client device with an IP of &lt;span style="color: red;"&gt;&lt;strong&gt;192.168.2.1&lt;/strong&gt;&lt;/span&gt;.&amp;nbsp;
 When the client sends IP traffic to the server at 192.168.1.2, that 
packet will have a source address of 192.168.2.1 (the tunnel IP).&amp;nbsp; The 
server “sees” that packet and responds to the IP 192.168.2.1, which is 
not on it’s local subnet.&amp;nbsp; The server would send the packet through it’s
 “gateway” at 192.168.1.1.&lt;br /&gt;

Let’s consider another scenario where the router assigns the pptp client with the IP address &lt;span style="color: red;"&gt;&lt;strong&gt;192.168.1.10&lt;/strong&gt;&lt;/span&gt;.&amp;nbsp;
 Again, when the client sends IP traffic to the server, the source IP 
address will be the tunnel IP of 192.168.1.10.&amp;nbsp; The server will need to 
respond to the IP address 192.168.1.10.&amp;nbsp; The problem here is that 
although the server will ASSUME that the device with the IP address 
192.168.1.10 exists on the local LAN, it does not.&amp;nbsp; When the server 
sends it’s ARP request to the LAN asking “Who has 192.168.1.10″, there 
is NO device on the LAN with that IP and therefore the communication 
will fail.&amp;nbsp; If, however, on the router’s LAN interface, we configured it
 to answer ARP requests “by proxy” for the tunnels it knows about, the 
ROUTER will answer the server’s arp request.&amp;nbsp; In this way, the server 
would “deliver” the Ethernet frame (with the IP packet inside) to the 
router, which in turn will deliver the IP packet to the PPtP client over
 the tunnel.&amp;nbsp; I am certain that you’ve already figured out the rest, but
 I’ll say it anyway…the configuration we need to do on the router is to 
turn on proxy arp on the LAN interface.&lt;br /&gt;

In the Mikrotik, this is very simple to do.&amp;nbsp; If the interface is named “LAN”, then the following command would do it:&lt;br /&gt;

&lt;span style="color: red;"&gt;&lt;em&gt;&lt;strong&gt;/interface ethernet set LAN arp=proxy-arp&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;

That’s IT!&amp;nbsp; In MOST circumstances, I recommend using IP space that is
 NOT in the LAN subnet for tunnels.&amp;nbsp; If it is necessary, due to limited 
IP space or for any other reason (Active Directory issues are one 
situation), setting proxy arp will be necessary and will allow this to 
function.&lt;br /&gt;

As always, I hope this article has been helpful to you.&amp;nbsp; If you find 
it of use, by all means “Digg it” above to let others know about it.&lt;br /&gt;
&lt;br /&gt;
http://blog.butchevans.com/2010/06/when-and-why-proxy-arp/ </description><author>emaknyus@gmail.com (tamvan &amp;amp; verani)</author></item><item><title>Breaking a network in two with proxy ARP</title><link>http://emaknyus.blogspot.com/2011/09/breaking-network-in-two-with-proxy-arp.html</link><category>arp</category><category>proxy arp</category><pubDate>Mon, 5 Sep 2011 22:11:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3787219161379371544.post-8597829558275853628</guid><description>
      Proxy ARP is a technique for splitting an IP network into two
      separate segments.  Hosts on one segment can only reach hosts in the
      other segment through the router performing proxy ARP.  If a router sits
      between two parts of an IP network and is not running bridging software,
      then routes to hosts in each segment and proxy ARP are required
      on the router to allow each half of the
      network to communicate with the other half.
    &lt;br /&gt;

      Occasionally, this technique is incorrectly called proxy ARP bridging.
      An Ethernet bridge operates on frames and a router operates on packets.
      The proxy ARP router should have routes to all hosts on both segments.
      Once the router can reach all locally connected destinations via the
      correct interfaces, you can begin to configure the proxy ARP
      functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;

      Although proxy ARP complicates a network, a great advantage of proxy ARP
      technique is the greater control over IP connections between hosts.
    &lt;br /&gt;

      There are two primary proxy ARP techniques.  With the 2.4 kernel, it is
      possible to use the sysctl
      &lt;code class="filename"&gt;net/ipv4/conf/all/proxy_arp&lt;/code&gt; to perform proxy ARP.
      Alternatively, manual population of the ARP table reaches the same end.
    &lt;br /&gt;

      The key part of the correct functioning of proxy ARP in a network is
      that the host breaking a network into two parts has correct routes for
      all destinations in both halves of the network.  If the host which has
      interfaces in both networks does not have an accurate routing table, IP
      packets will get dropped on the routing device.
    &lt;br /&gt;

      One common method of breaking a network in two involves making a very
      small stub subnet at one end or the other of the IP range.  This small
      subnet (maybe as small as a /30 network, with two usable IPs) makes an
      excellent sequestered location for a host which requires more
      protection or even, a generally untrusted host which shouldn't have
      complete access to the Ethernet to which the other machines connect.
    &lt;br /&gt;

      For a practical example of this, see the relationship between the
      &lt;code class="systemitem"&gt;service-router&lt;/code&gt;, &lt;code class="systemitem"&gt;masq-gw&lt;/code&gt; and &lt;code class="systemitem"&gt;isolde&lt;/code&gt; in the
      &lt;a href="http://linux-ip.net/html/example-network-netmap.html" title="A.1. Example Network Map and General Notes"&gt;network map&lt;/a&gt;.  &lt;code class="systemitem"&gt;isolde&lt;/code&gt; and
      &lt;code class="systemitem"&gt;service-router&lt;/code&gt; share the same IP network, 192.168.100.0/24.  If either
      has a packet for the other, it will generate an ARP request which should
      be answered by &lt;code class="systemitem"&gt;masq-gw&lt;/code&gt;.  Naturally, &lt;code class="systemitem"&gt;masq-gw&lt;/code&gt; has its routes
      configured in such a way that both hosts are reachable from it.  Thus,
      the packet will successfully pass through &lt;code class="systemitem"&gt;masq-gw&lt;/code&gt;.
    &lt;br /&gt;

      Let's examine what the sequence of events is by which the packet will
      reach &lt;code class="systemitem"&gt;service-router&lt;/code&gt; from &lt;code class="systemitem"&gt;isolde&lt;/code&gt;.  In this example, &lt;code class="systemitem"&gt;isolde&lt;/code&gt; will
      send an echo request packet to &lt;code class="systemitem"&gt;service-router&lt;/code&gt;.  Please also refer to
      &lt;a href="http://linux-ip.net/html/tools-arp.html" title="B.1. arp"&gt;Section&amp;nbsp;B.1, “&lt;span&gt;&lt;strong class="command"&gt;arp&lt;/strong&gt;&lt;/span&gt;”&lt;/a&gt; for examples and command lines to create
      a proxy ARP configuration.
    &lt;br /&gt;
&lt;div class="itemizedlist"&gt;
&lt;ul type="disc"&gt;
&lt;li&gt;
          the admin on &lt;code class="systemitem"&gt;isolde&lt;/code&gt; creates an echo request packet 
          for 192.168.100.1 with
          &lt;a href="http://linux-ip.net/html/tools-ping.html" title="G.1. ping"&gt;&lt;span&gt;&lt;strong class="command"&gt;ping&lt;/strong&gt;&lt;/span&gt;&lt;/a&gt;
        &lt;/li&gt;
&lt;li&gt;
          &lt;code class="systemitem"&gt;isolde&lt;/code&gt; sends an ARP request for the owner of 192.168.100.1
        &lt;/li&gt;
&lt;li&gt;
          &lt;code class="systemitem"&gt;masq-gw&lt;/code&gt; replies that &lt;code class="systemitem"&gt;isolde&lt;/code&gt; should send packets for
          192.168.100.1 to its Ethernet address, 00:80:c8:f8:5c:71
        &lt;/li&gt;
&lt;li&gt;
          &lt;code class="systemitem"&gt;masq-gw&lt;/code&gt; receives the packet, unwraps it and selects eth3 as
          the output interface
        &lt;/li&gt;
&lt;li&gt;
          &lt;code class="systemitem"&gt;masq-gw&lt;/code&gt; sends an ARP request for the owner of 192.168.100.1
        &lt;/li&gt;
&lt;li&gt;
          &lt;code class="systemitem"&gt;service-router&lt;/code&gt; replies that &lt;code class="systemitem"&gt;masq-gw&lt;/code&gt; should send packets for
          192.168.100.1 to its Ethernet address, 00:c0:7b:7d:00:c8
        &lt;/li&gt;
&lt;li&gt;
          &lt;code class="systemitem"&gt;service-router&lt;/code&gt; receives the packet unwraps it and hands it up
          the IP stack, which generates an echo reply bound for the source
          address, 192.168.100.17 (&lt;code class="systemitem"&gt;isolde&lt;/code&gt;'s IP)
        &lt;/li&gt;
&lt;li&gt;
          &lt;code class="systemitem"&gt;service-router&lt;/code&gt; sends an ARP request for the owner of 192.168.100.17
        &lt;/li&gt;
&lt;li&gt;
          &lt;code class="systemitem"&gt;masq-gw&lt;/code&gt; replies that &lt;code class="systemitem"&gt;service-router&lt;/code&gt; should send packets for
          192.168.100.17 to its Ethernet address, 00:80:c8:f8:5c:74
        &lt;/li&gt;
&lt;li&gt;
          &lt;code class="systemitem"&gt;masq-gw&lt;/code&gt; receives the packet, unwraps it and selects eth0 as
          the output interface
        &lt;/li&gt;
&lt;li&gt;
          &lt;code class="systemitem"&gt;masq-gw&lt;/code&gt; sends an ARP request for the owner of 192.168.100.17
        &lt;/li&gt;
&lt;li&gt;
          &lt;code class="systemitem"&gt;isolde&lt;/code&gt; replies that &lt;code class="systemitem"&gt;masq-gw&lt;/code&gt; should send packets for
          192.168.100.17 to its Ethernet address, 00:80:c8:e8:4b:8e
        &lt;/li&gt;
&lt;li&gt;
          &lt;code class="systemitem"&gt;isolde&lt;/code&gt; receives the reply, unwraps it and hands it up the IP stack
          to the awaiting
          &lt;a href="http://linux-ip.net/html/tools-ping.html" title="G.1. ping"&gt;&lt;span&gt;&lt;strong class="command"&gt;ping&lt;/strong&gt;&lt;/span&gt;&lt;/a&gt; command
        &lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
Where possible, a simplified network is easier to maintain, but
      occasionally, this sort of trickery is necessary.  This is an excellent
      way to insert a firewall into the middle of a network.  The firewall,
      naturally, has to have its routes set properly, and proxy ARP entries
      will be required for routers.
    &lt;br /&gt;

      Now, here's a short script and configuration file which can be run as a
      SysVInit style script.  This script provides a great deal of control
      over the ARP table directly so may be preferable in some cases to an
      alternate solution outlined below.  This
      &lt;a href="http://linux-ip.net/html/scripts-proxy-arp.html#ex-sc-proxy-arp" title="Example 11.1. Proxy ARP SysV initialization script"&gt;proxy-arp script&lt;/a&gt; reads the
      following
      &lt;a href="http://linux-ip.net/html/scripts-proxy-arp.html#ex-sc-proxy-arp-conf" title="Example 11.2. Proxy ARP configuration file"&gt;configuration file&lt;/a&gt;.
      Each is commented heavily so it should be clear how to use them.
    &lt;br /&gt;

      This chapter discussed how to break a network in twain with proxy ARP
      techniques.  For another explanation of the same concepts, read the
      &lt;a class="nonlocal" href="http://www.linuxpowered.com/HOWTO/mini/Proxy-ARP-Subnet/" target="_top"&gt;Proxy
      ARP Subnet mini-HOWTO&lt;/a&gt;.  Available in most (all?) 2.4 kernels is
      built-in capability for Proxy ARP.  This is documented in deeper detail
      &lt;a href="http://linux-ip.net/html/ether-arp-proxy.html#ether-arp-proxy-kernel"&gt;above&lt;/a&gt;.
      Consider familiarizing yourself with the methods of suppressing
      and controling ARP through
      &lt;a class="nonlocal" href="http://www.ssi.bg/%7Eja/" target="_top"&gt;Julian
      Anastasov's work&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
http://linux-ip.net/html/adv-proxy-arp.html </description><author>emaknyus@gmail.com (tamvan &amp;amp; verani)</author></item></channel></rss>