August 1, 2013

Virtualbox high network latency with multiple CPU Cores

On Virtualbox 4.2, if you assign multiple cores to your VM, and you are running Linux Guest, you may experience high network latency (ssh typing is sporadic even on local GigE network).

This is a bug with Virtualbox.

The solution: Change your VM Ethernet type to PCnet. Then it works!

Here is the link to the bug report: https://www.virtualbox.org/ticket/10157

July 23, 2013

A good Windows SSH/Telnet Server


http://www.kpym.com/

  • Free, Open source, 
  • works with putty in full color, and full window size
  • and command auto complete works well
  • what else could I ask for?


July 15, 2013

linux dummy interface and renaming

In linux, there is a kernel module called "dummy", which allows you to generate dummy network interfaces such as "dummy0", "dummy1", etc.

1. sudo modprobe dummy numdummies=2
2. now you can do "ifconfig dummy0 192.168.1.124" to give it an IP address.
3. you can also rename the dummy interface with the following command:
        ip link set dummy0 name eth3
you need to "down" the interface before running the command above.

With the combination of dummy interfaces and ability to rename dummy interfaces, you can do a lot of fun things with them.

July 11, 2013

initramfs with boot argument init=/bin/sh

If you use a Linux kernel with initramfs, the boot argument "init=/bin/sh" would not work. The correct one is "rdinit=/bin/sh". Aha. Gotcha.

July 9, 2013

Add new file type to ack-grep

If you use ack as your grep replacement, and would like to add a new file type, do this:

Create a file at ~/.ackrc with the following line (change Ruby to your file type, and .haml,etc to your actual file extension):

--type-add=ruby=.haml,.rake,.rsel

July 1, 2013

How to hide/remove OS field in Bugzilla

This method uses javascript to hide the unwanted fields

1. edit template/en/default/global/header.html.tmpl. Search for "global.js". After the line "[% END %]" add the following lines:

    [% starting_js_urls.push('//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js') %]

    [% FOREACH javascript_url = starting_js_urls %]
      [% PROCESS format_js_link %]
    [% END %]
    [% starting_js_urls.push('js/my.js') %]

    [% FOREACH javascript_url = starting_js_urls %]
      [% PROCESS format_js_link %]
    [% END %]

2. create the file js/my.js with the following contents:
$(document).ready(function(){
        $("#os_guess_note").parent().hide();
        $("#field_container_op_sys").parent().hide();
        $("#field_container_rep_platform").parent().hide();
});

This hides three fields: OS, OS comment, and Hardware.

To remove more clutters, use the following js:

$(document).ready(function(){
        $("#os_guess_note").parent().hide();
        $("#field_container_op_sys").parent().hide();
        $("#field_container_rep_platform").parent().hide();
        $("#op_sys").closest("tr").hide();
        $("#bz_url_input_area").closest("tr").hide();
        $("#tag_container").closest("tr").hide();
        $("#dependson").closest("tr").hide();
        $("#blocked_input_area").closest("tr").hide();
        $("#show_dependency_tree_or_graph").closest("tr").hide();
        $("td.bz_section_spacer").closest("tr").hide();
        $(".bz_collapse_expand_comments").closest("td").hide();
        $("div.bz_add_comment").hide();
        $("#xml").hide();

        $("#comment").attr("rows","2");
        $("#attachment_table").hide().before("<button id='tz_bug_edit' style='width:50px'> <b>Edit</b> </button>");
        $("#add_comment").hide();
        $("#tz_bug_edit").prevAll("br").remove();
        $("#tz_bug_edit").click(function(){
                if ($("#attachment_table").is(":visible")){
                        $("#attachment_table").hide();
                        $("#add_comment").hide();
                }else{
                        $("#attachment_table").show();
                        $("#add_comment").show();
                }
                return false;
        });
});
        $("#bz_show_bug_column_1").append($("#bz_show_bug_column_2").html());
        $("#bz_show_bug_column_2").remove();
        $("table.edit_form").css("width","auto").css("float","right").find("th").css("text-align","left");

        $("#changeform").css("min-height","400px");


You can also change skins/standard/global.css to remove hyperlink underline, and change default font:

a {
        text-decoration: none;
}


/* this already exists, just edit it */
body, td, th, input {
    font-family: Verdana, sans-serif;
    font-size: 11pt;
}


June 27, 2013

GOLANG SSL Server and Client example

https://gist.github.com/spikebike/2232102

Below is my simple static "SSL Proxy" that listens on port 8000, and connects to another machine 10.3.0.124:443, and the proxy logs traffic both ways on screen.

To generate key.pem and cert.pem, you can use openssl, or use go team's simple program included in go package: http://golang.org/src/pkg/crypto/tls/generate_cert.go

package main
import (
        "io"
        "log"
        "net"
        "fmt"
        "os"
        "crypto/tls"
        "crypto/rand"
)

func checkError(err error) {
        if err != nil {
                fmt.Fprintf(os.Stderr, "Fatal error: %s", err.Error())
                os.Exit(1)
        }
}

/* slower, by we can print/log everything */
func myrawcopy(dst,src net.Conn) (written int64, err error) {
    buf := make([]byte, 32*1024)
    for {
        nr, er := src.Read(buf)
        if nr > 0 {
                        fmt.Printf("%s",string(buf[0:nr]));
            nw, ew := dst.Write(buf[0:nr])
            if nw > 0 {
                written += int64(nw)
            }
            if ew != nil {
                err = ew
                break
            }
            if nr != nw {
                err = io.ErrShortWrite
                break
            }
        }
        if er == io.EOF {
            break
        }
        if er != nil {
            err = er
            break
        }
    }
    return written, err
}

func myiocopy(dst net.Conn, src net.Conn){
        myrawcopy(dst, src)
        //io.Copy(dst,src);
        dst.Close();
        src.Close();
}

func handleclient(c net.Conn){
        config := tls.Config{InsecureSkipVerify: true}
        conn, err := tls.Dial("tcp", "10.3.0.124:443", &config)
        checkError(err)

        go myiocopy(conn,c)

        //io.Copy(c, conn)
        myrawcopy(c, conn)
        c.Close()
        conn.Close();
}

func main() {
        cert, err := tls.LoadX509KeyPair("cert.pem", "key.pem")
        if err != nil {
                log.Fatalf("server: loadkeys: %s", err)
        }
        config := tls.Config{Certificates: []tls.Certificate{cert}}
        config.Rand = rand.Reader
        service := "0.0.0.0:8000"
        listener, err := tls.Listen("tcp", service, &config)
        if err != nil {
                log.Fatalf("server: listen: %s", err)
        }
        log.Printf("server: listening on %s for https, connects to https://10.3.0.124:443",service)
        for {
                conn, err := listener.Accept()
                if err != nil {
                        log.Printf("server: accept: %s", err)
                        break
                }
                defer conn.Close()
                log.Printf("server: accepted from %s", conn.RemoteAddr())
                go handleclient(conn)
        }
}

June 24, 2013

Free - Remote Desktop Control Software

To sum it up: 

For business, Use LogMeIn for unattended, Join.me for attended.
For personal: Use TeamViewer.


LogMeIn The first and highest rated product in the unattended category is LogMeIn. This is a web-based service that's extremely easy to set up and use and can be accessed from any PC with a browser. The free version won't allow file transfer or remote printing but is a great solution for accessing your remote data as well as file sharing. Registration is required before using the product. It is really meant to be an 'install and leave it' kind of tool and not for the 'quick connect to help a friend' scenario.
I still very much believe that the features and speed of LogMeIn are unmet by any other product and worth the extra hassle if you have access to the other machine(s) or means to connect remotely and install it. It is free for personal and commercial use.

TeamViewer Next is TeamViewer. It is very reliable, allows both attended and unattended control and has great features. There is a portable version of the viewer if you want to use an application or they also have a web-based control site that requires no installation to remotely control computers. The web-based version uses HTML and Flash, so it is usable even if the browser or firewall doesn't allow Java or ActiveX. TeamViewer is a commercial product and is only free  for personal use. Any commercial use is prohibited by the TeamViewer use policy.

Join.MeThe fastest solution in the attended category is Join.me. Its small 1 MB download and simple security code make it very quick to establish a remote session.

MikogoThe last solution in this category is Mikogo. Mikogo is not the fastest nor is it the most reliable, but it offers the most features of any of the solutions in this article. It is a full-featured solution comparable to the commercial Citrix GotoMeeting product with features such as presenter switching, remote control, white board sharing, file sharing and session recording.

June 7, 2013

To open a page in a frame using javascript




"javascript:top.frames['framename'].location = 'filename.html';return true;"

A list of SSL/HTTPS sniffer/proxy/dump


  1. mitmproxy, written in Python, includes a ncurse-based UI, or the console-based mitmdump. Able to generate SSL certs on the fly. http://mitmproxy.org/
  2. TCPCather: http://www.tcpcatcher.org/. Looks really good.
  3. sslsniff: by the famous hacker moxie0: https://github.com/moxie0/sslsniff
  4. burp (the free version): http://www.portswigger.net/burp/proxy.html
I personally used mitmproxy to my satisfaction. 

June 6, 2013

vim regex search tips

1. $ < > does not need to be escaped.
2. [ ] & needs to be escaped
3. [a-zA-Z] sometimes can be better accepted than \a (for alphabet)
4. For replacement, & means the matched term

May 9, 2013

hg serve multiple projects

To use "hg serve" to serve multiple project internally (with your LAN). Create a file named webconf (it can be any name) with the following content:



[collections]
repos/ = .

[extensions]
hgext.highlight=

[web]
allow_push = *
push_ssl = false
pygments_style = vs
style = gitweb


Then in system start up run this:

cd your_hg_directory && sudo -u your-name hg serve --web-conf ./webconf


I like the "gitweb" style because it gives you date on files. The default style is "paper". Other styles can be:

atom
coal
gitweb
monoblue
paper
raw
rss
spartan

May 8, 2013

shrew vpn masquerade on Linux

Once your have your VPN client running on a Linux box, sometimes you would like to share that link with that machines on your LAN (either physical LAN or virtual LAN such as Virtual Machines).

Because shrew uses the kernel IPsec VPN, the iptables masquerade rule does not work on the virtual tap0 interface. There does not seem to exist an easy fix.

The work around I have is to install a linux virtual machine (virtualbox) on the host, which has two NICs, one is NAT, the other one is bridging. Then run iptables masquerade on the virtual Linux, taking traffic from the bridged NIC, and send it out to the NATed NIC. On the host, since virtualbox behaves just like any other application, it is able to access all the VPNed network resources. Bingo!

It works well here. Let me know your thoughts.

shrew vpn client on Linux for Cisco Concentrator

To talk to a Cisco VPN Concentrator, one can use "vpnc" or "shrew vpn client".

My vpnc only stays up for a few hours, while on Windows the Cisco VPN client can stay up for days. So I wanted to give shrew a try.

Shrew can import Cisco .pcf configuration file. After that, a connection entry is created. However, you probably will need to modify the profile for it to work. On the "qikea" window, right click on the profile, then "Modify", go to tab "Phase 2" and make your choices instead of auto. For example, try change PFS Group to "2". This worked for many people.

If you are interested, you can try to use the tool "ike-scan" to probe your vpn server and find out exactly the parameters for this tab.

That solved my problem.

The following screenshot is a Windows screenshot, but the Linux one is very similar.

VPN Setting

I got the this tip from the following post:
http://www.rhyous.com/2009/10/29/windows-7-64-bit-vpn-client-shrewsoft/

April 26, 2013

Text to ASCII Art

Under Linux, use the program "figlet" to turn regular text info a ASCII art text.

Example:


 figlet hello
 _          _ _
| |__   ___| | | ___
| '_ \ / _ \ | |/ _ \
| | | |  __/ | | (_) |
|_| |_|\___|_|_|\___/


figlet -W hello (wide version)
  _              _   _
 | |__     ___  | | | |   ___
 | '_ \   / _ \ | | | |  / _ \
 | | | | |  __/ | | | | | (_) |
 |_| |_|  \___| |_| |_|  \___/


You can choose different style too:


figlet -f banner -W hello

 #    #  ######  #       #        ####
 #    #  #       #       #       #    #
 ######  #####   #       #       #    #
 #    #  #       #       #       #    #
 #    #  #       #       #       #    #
 #    #  ######  ######  ######   ####

figlet -f bubble -W hello
   _     _     _     _     _
  / \   / \   / \   / \   / \
 ( h ) ( e ) ( l ) ( l ) ( o )
  \_/   \_/   \_/   \_/   \_/

Use "figlist" to list all the styles.




April 10, 2013

Fix: vim indent not working

If you loaded a new indent file or syntax file under ~/.vim/ and it is not taking effect, make sure you have the following line in your ~/.vimrc file:


filetype plugin indent on


This turns on filetype detection, filetype plugin, and filetype-indent. 

April 1, 2013

how to mount vdi

First install lvm2, ndb and qemu-common packages:

Code

yum install lvm2 nbd qemu-common

Then run this to load the nbd module:

Code

modprobe nbd max_part=16

And connect the device:

Code

qemu-nbd -c /dev/nbd0 "/home/USER/VirtualBox VMs/CentOS6/CentOS6.vdi"

Load the dm-mod module:

Code

modprobe dm-mod

Run this command to scan for volume groups:

Code

vgscan

This will output something like this:
  Reading all physical volumes.  This may take a while...
  Found volume group "vg_centos" using metadata type lvm2

In the next step we want to use what is in the quotes above. Run this command but replace vg_centos with whatever shows in the quotes.

Code

vgchange -ay vg_centos

Then show which partitions there are:

Code

lvs

This will output something like this:
  LV      VG        Attr   LSize  Origin Snap%  Move Log Copy%  Convert
  lv_root vg_centos -wi-a- 18.12g
  lv_swap vg_centos -wi-a-  1.97g

In this case we want the logical volume named lv_root so run this command:

Code

mount /dev/vg_centos/lv_root /mnt/vdi -o ro,user

Now you should be able to find your disk in the /mnt/vdi folder. Note that you must have created the /mnt/vdi folder first but you can mount it wherever you like into an empty folder.

Some more useful tips.

You can unmount the disk:

Code

umount /mnt/vdi

This command will disconnect the nbd:

Code

qemu-nbd -d /dev/nbd0

After you disconnect the nbd you can unload the module:

March 29, 2013

tip: embed raw text in html


 it's become somewhat au courant to use the "type" attribute to mark <script> blocks that you don't want to be evaluated:
<script type='text/html-template'>
  <div> this is a template </div>
</script>
By giving a weird non-JavaScript type, you get a way to stuff raw text into the page for use by other JavaScript code (which is presumably in script block that can be evaluated).

This technique is great for using the block inside the <script> for html template, to be used by JQuery. Without the <script> block, IE will mess with the source code and remove thing it does not know.

Source: http://stackoverflow.com/questions/5265202/do-you-need-text-javascript-specified-in-your-script-tags

March 20, 2013

California LLC taxs and fees

For California LLC not treated as corporation:



  1. Annual tax of $800 is paid in the tax year by 04/15 with form 3522 . 
  2. LLC fee estimate for current year is paid by 6/15 current year
  3. LLC fee final is filed by next year 4/15 with From 568, the payment form is 3536
  4. The Fee is tax deductible
Source:

1. https://www.ftb.ca.gov/businesses/bus_structures/LLCompany.shtml
2. http://www.taxes.ca.gov/Income_Tax/limliacobus.shtml
3. https://www.upcounsel.com/california-llc-fee

March 15, 2013

php one line udp client

socket_sendto(socket_create(AF_INET, SOCK_DGRAM, SOL_UDP), $raw_post_data, strlen($raw_post_data), 0, '127.0.0.1', 57000);

The above will send the post data  (suppose it is in $raw_post_data) to a local udp server listening on port 57000.

March 6, 2013

Excel 2003 useful shortcuts

Ctrl-1:          Open Cell Format Dialog
shift +space: select row
ctrl + -:        delete row.
ctrl + +:        Insert a row (above the currently selected row)     

March 1, 2013

clean up diff file

The following program take a diff file and removes chunks that are simply different by a white spaces or carriages returns, such as

int func(a,b){

vs. 

int func(a,b)
{

Save this to file "diffclean.awk" and run it as "./diffclean.awk my.diff".



#!/usr/bin/gawk -f
function process_block(str,strp,strm){
        regex="[ \t\f\r\n]+";
        gsub(regex," ",strp);
        gsub(regex," ",strm);
        if (strp!=strm){
                print str;
        }
}

{
        if (!block_started) {
                if (/^@@/) {
                        block_started=1;
                        str=$0;
                        strp="";
                        strm="";
                }else{
                        print;
                }
                next;
        }

        if (/^diff/) {
                process_block(str,strp,strm);
                block_started=0;
                print;
                next;
        }
        if (/^@@/) {
                process_block(str,strp,strm);
                str=$0;
                strp="";
                strm="";
                next;
        }

        str=str "\n" $0;
        if (/^-/) strm=strm substr($0,2);
        if (/^+/) strp=strp substr($0,2);
}

END{
        if (block_started){
                process_block(str,strp,strm);
        }
}

February 27, 2013

vimdiff ignore empty lines

Add this to the end of your .vimrc file to make vimdiff ignore empty lines:


set diffopt+=iwhite
set diffexpr=MyDiff()
function MyDiff()
    let opt = ""
    if &diffopt =~ "icase"
        let opt = opt . "-i "
    endif
    if &diffopt =~ "iwhite"
        let opt = opt . "-w -B " " vim uses -b by default
    endif
    silent execute "!diff -a --binary " . opt .
                \ v:fname_in . " " . v:fname_new .  " > " . v:fname_out
endfunction

February 25, 2013

Thinkpad T530 Ctrl-Alt-Break for Remote Desktop Full Screen

Thinkpad T530 does not have the "break" key. Use "Fn-Alt-B" will generate "Break" key code.

So to send Ctrl-Alt-Break, just do Ctrl-Alt-Fn-B

February 8, 2013

diff ignore files only in one directory


diff -bBur old_dir/ new_dir/ | grep -v "^Only in" > my.diff

February 5, 2013

How to add a upstart task on RHEL6


Suppose the application you want to start is called myapp.

Become root and create a file under /etc/init/myapp.conf

start on stopped rc RUNLEVEL=[2345]

respawn
script
        cd /home/me/myapp
        ./myapp -i /home/me/myapp/system.ini
end script

Run "initctl start myapp" to start the app.
Run "initctl status myapp" to see the status.
Run "initctl stop myapp" to stop the app

Keep in mind that myapp should not daemonize itself. Upstart will do the daemonize part.

January 20, 2013

So Cal lakes that allow bow fishing

El Capitan
Sutherland
Otay
San Vicente
Hodges

Lakes Already Approved:

Elsinore
Big Bear
Cachuma
Hemet (with strict regulations)

January 14, 2013

uml and console job control

I started uml with my host debian file system:


./linux rootfstype=hostfs rw init=/home/tzhang/uml/init-uml.sh mem=64M TERM=linux eth0=tuntap,,,192.168.6.88

However the shell I get does not have job control. I tried multiple things found on internet but none did the trick for me. This is what finally solved the problem:

1. get busybox and build it with the "cttyhack" enabled (in shell section of menuconfig)
2. ln -sf busybox cttyhack
3. run that in your init. My init.sh looks like this:


#!/bin/bash
export PS1="[\\u@\\h:\\w] $"
export HOME=/home/tzhang
. /home/tzhang/.bashrc
ifconfig eth0 192.168.6.99
hostname -b R1
export PATH=/usr/local/bin:/usr/bin:/bin:/sbin:/usr/local/sbin:/usr/sbin
mount -t proc proc /proc
mount -t sysfs sysfs /sys
mount -t tmpfs tmpfs /var/run -o rw,nosuid,nodev
mount -t tmpfs tmpfs /var/log -o rw,nosuid,nodev
cd $HOME/uml


mount -t tmpfs /dev/ /dev/

/etc/init.d/udev start
/home/tzhang/uml/dropbear -r dropbear_rsa_host_key
exec setsid /home/tzhang/uml/cttyhack bash

This solved the problem beautifully. The last line is what did the trick for job control.
the udev daemon and dropbear made ssh possible.

=============UPDATED 4/10/2017=====================
init.sh:
#!/bin/bash
export PS1="\u@\h:\w $"
export HOME=/home/tzhang
. /home/tzhang/.bashrc
ifconfig eth0 192.168.6.99
hostname -b R1
export PATH=/usr/local/bin:/usr/bin:/bin:/sbin:/usr/local/sbin:/usr/sbin
mount -t proc proc /proc
mount -t sysfs sysfs /sys
mount -t tmpfs tmpfs /var/run -o rw,nosuid,nodev
mount -t tmpfs tmpfs /var/log -o rw,nosuid,nodev
cd $HOME/uml

mount -t tmpfs /dev/ /dev/
ifconfig eth1 192.168.3.2
ifconfig eth0 192.168.2.2

busybox mdev -s
mkdir /dev/pts
mount -t devpts /dev/pts /dev/pts

#dropbear -r dropbear_rsa_host_key -p 2222
exec setsid /home/tzhang/uml/cttyhack bash


run.sh
./linux rootfstype=hostfs rw init=/home/tzhang/uml/init.sh mem=64M TERM=linux \
eth0=tuntap,tap0,,192.168.2.88 \
eth1=tuntap,tap1,,192.168.3.88

Host /etc/network/interfaces
# The primary network interface
auto ens33
iface ens33 inet manual
auto ens38
iface ens38 inet manual
auto tap0
iface tap0 inet manual
    pre-up ip tuntap add tap0 mode tap user tzhang
    up ip link set dev tap0 up
auto tap1
iface tap1 inet manual
    pre-up ip tuntap add tap1 mode tap user tzhang
    up ip link set dev tap1 up
auto br0
iface br0 inet dhcp
        bridge_ports ens33 tap0
auto br0:1
allow-hotplug br0:1
iface br0:1 inet static
        address 192.168.2.1
        broadcast 192.168.2.255
        netmask 255.255.255.0
auto br1
iface br1 inet dhcp
        bridge_ports ens38 tap1
auto br1:1
allow-hotplug br1:1
iface br1:1 inet static
        address 192.168.3.1
        broadcast 192.168.3.255
        netmask 255.255.255.0

January 13, 2013

uml with minimal debian


Build kernel:

1. get kernel
2. make ARCH=um defconfig
3. make ARCH=um menuconfig ; to remove options you don't need
4. make -j 12 ; parallel build


Build rootfs:
dd if=/dev/zero of=my.rootfs bs=1M seek=512 count=0
mkfs.ext2 -F my.rootfs

mkdir rootfs
sudo mount -o loop my.rootfs rootfs
sudo debootstrap --arch=i386 --variant=minbase lucid rootfs

January 8, 2013

SQL Server 2008 can't login with newly created user


SQL Server was not configured to allow mixed authentication.
Here are steps to fix:
  1. Right-click on SQL Server instance at root of Object Explorer, click on Properties
  2. Select Security from the left pane.
  3. Select the SQL Server and Windows Authentication mode radio button, and click OK.

    Right-click on the SQL Server instance, select Restart (alternatively, open up Services and restart the SQL Server service).

    I wish Microsoft has better document.

    Source: http://stackoverflow.com/questions/1719399/sql-server-2008-cant-login-with-newly-created-user

December 27, 2012

putty and gnu screen scroll back with mouse


Summary: add the line to your .screenrc file:
termcapinfo xterm ti@:te@
Reference ( Putty FAQ )
PuTTY's terminal emulator has always had the policy that when the ‘alternate screen’ is in use, nothing is added to the scrollback. This is because the usual sorts of programs which use the alternate screen are things like text editors, which tend to scroll back and forth in the same document a lot; so (a) they would fill up the scrollback with a large amount of unhelpfully disordered text, and (b) they contain their own method for the user to scroll back to the bit they were interested in. We have generally found this policy to do the Right Thing in almost all situations.
Unfortunately, screen is one exception: it uses the alternate screen, but it's still usually helpful to have PuTTY's scrollback continue working. The simplest solution is to go to the Features control panel and tick ‘Disable switching to alternate terminal screen’. (See section 4.6.4 for more details.) Alternatively, you can tell screen itself not to use the alternate screen: the screen FAQ suggests adding the line ‘termcapinfo xterm ti@:te@’ to your .screenrc file.

November 30, 2012

run as user in inittab or init

Sometimes sudo -u USERNAME gives error.

You can try to to use su USERNAME -c "COMMAND" instead.

November 28, 2012

Start screen after sudo su to another user


Sudo'ing to a user then running screen doesn't work out of the box.  Typically you get the following error:
Cannot open your terminal '/dev/pts/1' - please check.
The solution:
sudo su - someuser
script /dev/null
screen

Source: http://dbadump.blogspot.com/2009/04/start-screen-after-sudo-su-to-another.html 

November 26, 2012

Creating a self-signed certificate with ADT


http://help.adobe.com/en_US/air/build/WS5b3ccc516d4fbf351e63e3d118666ade46-7f74.html

You can use self-signed certificates to produce a valid AIR installation file. However, self-signed certificates only provide limited security assurances to your users. The authenticity of self-signed certificates cannot be verified. When a self-signed AIR file is installed, the publisher information is displayed to the user as Unknown. A certificate generated by ADT is valid for five years.
If you create an update for an AIR application that was signed with a self-generated certificate, you must use the same certificate to sign both the original and update AIR files. The certificates that ADT produces are always unique, even if the same parameters are used. Thus, if you want to self-sign updates with an ADT-generated certificate, preserve the original certificate in a safe location. In addition, you will be unable to produce an updated AIR file after the original ADT-generated certificate expires. (You can publish new applications with a different certificate, but not new versions of the same application.)
Important: Because of the limitations of self-signed certificates, Adobe strongly recommends using a commercial certificate issued by a reputable certification authority for signing publicly released AIR applications.
The certificate and associated private key generated by ADT are stored in a PKCS12-type keystore file. The password specified is set on the key itself, not the keystore.

Certificate generation examples

adt -certificate -cn SelfSign -ou QE -o "Example, Co" -c US 2048-RSA newcert.p12 39#wnetx3tl 
adt -certificate -cn ADigitalID 1024-RSA SigningCert.p12 39#wnetx3tl

To
use these certificates to sign AIR files, you use the following
signing options with the ADT -package or -prepare commands:

-storetype pkcs12 -keystore newcert.p12 -keypass 39#wnetx3tl 
-storetype pkcs12 -keystore SigningCert.p12 -keypass 39#wnetx3tl

Note: Java versions 1.5 and above do not accept high-ASCII characters in passwords used to protect PKCS12 certificate files. Use only regular ASCII characters in the password.


ADT -package command examples

Package specific application files in the current directory for a SWF-based AIR application:

adt –package -storetype pkcs12 -keystore cert.p12 myApp.air myApp.xml myApp.swf components.swc

Download older version of flex SDK

http://blogs.adobe.com/flex/files/2012/05/FlexLicense.swf

November 10, 2012

netcat/ncat server file as a web server

I will use the ncat (part of nmap) tool:

1. first create a bash file with the following contents, and save it as nchttp.sh, and chmod+x on it:
#!/bin/sh
echo "HTTP/1.1 200 OK"
mydate=`date -R`
echo "Date: $mydate"
echo "Server: Apache"
echo "Last-Modified: $mydate"
echo "Accept-Ranges: bytes"
echo "Content-Disposition: inline; filename=\"$1\"";
mysize=`stat $1 |awk '/Size/{print $2}'`
echo "Content-Length: $mysize"
echo "Keep-Alive: timeout=30, max=300"
echo "Connection: Keep-Alive"
echo "Content-Type: application/octet-stream"
echo
cat $1

2. ./nchttp.sh the-file-to-be-downloaded | ncat -l -vv 8001

3. point your brower to your http://YOURSERVERIP:8001, your file will be downloaded

November 9, 2012

Faster ssh X11 Forwarding


I use ssh daily to connect to my servers and laptops around my home office. Most of the time I'm using ssh to login and build software, so it's plain and simple command line activity. However, sometimes I need to run an X11 application on a remote machine, in which case I use X forwarding to display the remote X application on my laptop. However, this can be slow. Today I stumbled on the following incantation to speed up X11 forwarding over ssh:


ssh -c arcfour,blowfish-cbc -X -C user@remotehost

Thanks to Samat Jain for this info.

The choice of cipher is based on some performance benchmarks as noted in LaunchPad bug #54180

Source: http://smackerelofopinion.blogspot.com/2009/07/faster-ssh-x11-forwarding.html

November 7, 2012

php mail() function data flow

php mail() called /usr/sbin/sendmail, which may be a symbolic link to exit4 or sendmail.postfix or whatever sendmail "MTA" installed on your system. If you change that to your own sendmail, you can probably log all outgoing emails for debugging purpose.

November 6, 2012

Build and install python and mercurial from scratch on a system


wget http://www.python.org/ftp/python/2.5.4/Python-2.5.4.tgz
wget http://www.selenic.com/mercurial/release/mercurial-1.2.1.tar.gz
tar zxvf mercurial-1.2.1.tar.gz
tar zxvf Python-2.5.4.tgz

Configure and build Python using /opt - you could use /usr/local or similar but I preferred to keep it out of my $PATH:

cd Python-2.5.4
./configure --prefix=/opt
make
su -c "make install"

Test Python installed properly:

/opt/bin/python
Python 2.5.4 (r254:67916, Mar 25 2009, 12:16:36)
[GCC 3.2.3 20030502 (Red Hat Linux 3.2.3-56)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

Build Mercurial, using your Python 2.5:

cd ../mercurial-1.2.1
su -c "make install PYTHON=/opt/bin/python PREFIX=/opt"

Test Mercurial installed properly:

/opt/bin/hg --version
Mercurial Distributed SCM (version 1.2.1)
Copyright (C) 2005-2009 Matt Mackall and others

You may wish to symlink hg from somewhere in your $PATH:
su -c "ln -s /opt/bin/hg /usr/local/bin/hg"

Obviously you'll need a C compiler and associated development tools installed. You may find that the Python configure command complains of missing libraries, such as zlib-devel which can be installed via yum if required

Source: http://blog.friedland.id.au/2009/03/installing-mercurial-on-rhelcentos-3.html

November 2, 2012

When running configure, “.infig.status: error: cannot find input file:” error was generated:


This appears to be caused by by having DOS style line endings in the configure script.
You should be able to use the dos2unix command or alternatively, the tr command:

$ tr -d "\15\32" < configure > configure.new
$ mv configure.new configure
     $ chmod +x configure

 Original Post Here

November 1, 2012

linux console get image size

On linux console, if you need to get an image size, and imagemagick is not installed, you can use the following script (save it as "getimgsize.php", chmod +x, then run it with your image file":


#!/usr/bin/php -f
<?php
if ($argc<2){
        die("Usage: getimagesize IMAGEFILE\n");
}
list($width, $height, $type, $attr) = getimagesize($argv[1]);
echo "Size is $width x $height\n";

October 30, 2012

Windows 8 and Ubuntu 12.10 dual boot issue

I recently bought a HP Envy dv4 laptop for work. It came with Windows 8, and I wanted to install Ubuntu 12.10 Server on it. Here is the problems I ran into and how they were solved:

1. Internal CDROM install did not work correctly. First I thought it was because the CDROM was broken. Later on I found out that legacy BIOS support is not enabled in the UEFI. Once Legacy support is enabled in UEFI, installing from CDROM worked fine.

2. Ubuntu 12.10 64-bit did not detect that the system is using UEFI and installed GRUB-PC(which is for the old BIOS/MBR) instead. So after installation the system booted straight into Windows 8 with no  option to boot into Linux.

3. I downloaded the Boot Repair and ran it. It uninstalled the grub-pc and installed grub-efi but at the end it stated that error occurred and suggested that I move the Linux into the first partition. This was not an easy option for me. So the system still cannot boot into Linux.

4. What saved the day was the tool called "rEFInd" found in  This Post . The actual website is located at HERE. A great piece of software with clear instructions. So I booted into Windows 8 and followed the instruction listed under "

Installing rEFInd Manually Using Windows"


5. It worked great!! Later on I used the "bcdedit" command to set the boot manager to grubx64 directly and it worked as well.

Thanks Rod!


October 23, 2012

How to Tell if Your CPU supports Virtulization Technology on Linux


It’s quite simple: We’ll need to take a peek inside the /proc/cpuinfo file and look at the flags section for one of two values, vmx or svm.
  • vmx – (intel)
  • svm – (amd)
You can use grep to quickly see if either value exists in the file by running the following command:
egrep ‘(vmx|svm)’ /proc/cpuinfo
If your system supports VT, then you’ll see vmx or svm in the list of flags. My system has two processors, so there are two separate sections:

flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr lahf_lm
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr lahf_lm
VT technology can still be disabled in your computer’s BIOS, however, so you’ll want to check there to make sure that it hasn’t been disabled. The flags in cpuinfo simply mean that your processor supports it.


Source: http://www.howtogeek.com/howto/linux/linux-tip-how-to-tell-if-your-processor-supports-vt/

October 12, 2012

vmware and virtualbox usb device in use not able to attach to VM

If you have a USB device that cannot be detached from the HOST and attach to your VM, one possible reason is because you are using USB 3.0 port the device. Change to a USB 2.0 port should help in that case. This was my case with Windows 7 running on Thinkpad T530.

September 19, 2012

Resolve IP Fragmentation, MTU, MSS, and PMTUD Issues with GRE and IPSEC


Resolve IP Fragmentation, MTU, MSS, and PMTUD Issues with GRE and IPSEC


Excerpt:

Avoiding IP Fragmentation: What TCP MSS Does and How It Works

The TCP Maximum Segment Size (MSS) defines the maximum amount of data that a host is willing to accept in a single TCP/IP datagram. This TCP/IP datagram may be fragmented at the IP layer. The MSS value is sent as a TCP header option only in TCP SYN segments. Each side of a TCP connection reports its MSS value to the other side. Contrary to popular belief, the MSS value is not negotiated between hosts. The sending host is required to limit the size of data in a single TCP segment to a value less than or equal to the MSS reported by the receiving host.
Originally, MSS meant how big a buffer (greater than or equal to 65496K) was allocated on a receiving station to be able to store the TCP data contained within a single IP datagram. MSS was the maximum segment (chunk) of data that the TCP receiver was willing to accept. This TCP segment could be as large as 64K (the maximum IP datagram size) and it could be fragmented at the IP layer in order to be transmitted across the network to the receiving host. The receiving host would reassemble the IP datagram before it handed the complete TCP segment to the TCP layer.

September 18, 2012

vboxheadless does not listen on VRDE port

vboxheadless in virtualbox is really good, but it does not report error messages very well. If you see it running but does not listen on the VRDE port, there is a chance that you have the following issue:

This supposes that your host is Linux.

Your host may have loaded the linux KVM modules, which conflicts the VirtualBox.  Do a "lsmod" to see whether you have the following modules installed:


 kvm_intel
 kvm

If you do, "rmmod" them. To make it permanent, put them in /etc/modprobe.d/blacklist.conf


September 14, 2012

debug udev rules

To debug your udev rules, just run udevd as:

udevd --debug

Keep in mind that some udevd cannot detect changes in rule files so make sure you restart udevd after rule changes.

Qt embedded Linux usb keyboard auto detect

Qt in embedded Linux can detect the plug/unplug of an USB Mouse and enable it when USB mouse is plugged in. For USB keyboard, it does not support such capability.

To solve this problem, I have to resort to qt plugin. The following links will provide all the necessary material to write and deploy a plugin.

The plugin is a dynamic library that qt app looks for when it starts. In this case, the "customized qt keyboard driver" is located at qt-binary-directory/kbddrivers/libhotplugkbplugin.so. Before start the app, set the key board environment variable:


export QWS_KEYBOARD="HotPlugKb"

The plugin is based on the simplestyle plugin below structure-wise and based on the qt internal linuxInput driver function-wise.


http://doc.qt.nokia.com/4.7-snapshot/qkbddriverplugin.html
http://qt-project.org/doc/qt-5.0/deployment-plugins.html
http://doc.qt.nokia.com/4.7-snapshot/plugins-howto.html
http://doc.qt.nokia.com/4.7-snapshot/tools-styleplugin.html
http://doc.qt.nokia.com/4.7-snapshot/qt-embedded-charinput.html

Debugging Plugins

export QT_DEBUG_PLUGINS='2'

September 7, 2012

Makefile and autoconf/automake gcc version check

Makefile:

GCC_VERSION_GE_45 := $(shell g++ -dumpversion | gawk '{print $$1>=4.5?"1":"0"}')
ifeq ($(GCC_VERSION_GE_45),1)
    AM_CXXFLAGS +=-Wunreachable-code
endif

Note the use of double $ sign inside gawk script.


In Autoconf/Automake:
1. Add the following line to configure.ac
  AM_CONDITIONAL(GCC_GE_45, test `g++ -dumpversion | gawk '{print $1>=4.5?"1":"0"}'` = 1)

2. Add the following line to Makefile.am
  include $(top_srcdir)/common.mk

3. Add the following lines to common.mk
if GCC_GE_45
    AM_CXXFLAGS +=-Wunreachable-code
endif

September 6, 2012

buffer overflow example and gcc flags

If you want to try some buffer overflow examples online, make sure you compile your C code with the gcc flag:

     -mno-accumulate-outgoing-args 

otherwise your assembly code may look different than the assembly code on the book. Read more at this Stackoverflow post

August 30, 2012

hg serve multiple projects


1. Create a file under the parent directory of the multiple project hg directories
Example:
#> cat webconf
[collections]
repos/ = .

[web]
allow_push = *
push_ssl = false


2.  hg serve --web-conf ./webconf -d

debian add key


sudo gpg --keyserver subkeys.pgp.net --recv-keys 55BE302B
sudo gpg -a --export 55BE302B | sudo apt-key add -

August 29, 2012

vim man page skip command line

In vim, when you want to get the man page of the word under the cursor, you can just type shift-k or "K". However, for some functions, there is a "command line" tool with the same time, so you will get the man page for that command line instead of the function you are looking for.

For example, if you hit "K" on "unlink", you will get the bash unlink man page instead of the system call unlink(). To solve this problem, put the following line in your .bashrc:

    export MANSECT=3,2,1,4,5,6,7,8,9

This tells man to search section 3 first, then section 2, then section 1, etc., thus solved the problem of section 1 coming up before section 2 or 3.

While on this topic, you can also add the following line to your .bashrc file to make your man page have colors. Make sure you installed the program "most" on your computer.


    export MANPAGER="/usr/bin/most -s"

Or you can use the default "less" program and add the following lines to .bashrc to make "less" colorful:


man() {
 env \
  LESS_TERMCAP_mb=$(printf "\e[1;31m") \
  LESS_TERMCAP_md=$(printf "\e[1;31m") \
  LESS_TERMCAP_me=$(printf "\e[0m") \
  LESS_TERMCAP_se=$(printf "\e[0m") \
  LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
  LESS_TERMCAP_ue=$(printf "\e[0m") \
  LESS_TERMCAP_us=$(printf "\e[1;32m") \
   man "$@"
}

August 23, 2012

Flags to enable thorough and verbose g++ warnings


Flags to enable thorough and verbose g++ warnings


-pedantic -Wall -Wextra -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wnoexcept -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-null-sentinel -Wstrict-overflow=5 -Wswitch-default -Wundef -Werror-Wno-unused


A good base setup for C is:
-std=c99 -pedantic -Wall -Wextra -Wwrite-strings -Werror
and for C++
-ansi -pedantic -Wall -Wextra -Weffc++

My C++ version:

-g -O -Wall -Wextra -Weffc++ -pedantic -Wformat=2 \
 -Waggregate-return -Wcast-align \
 -Wcast-qual   -Wconversion \
 -Wdisabled-optimization  -Wfloat-equal   \
 -Winit-self  -Winline \
 -Winvalid-pch   -Wunsafe-loop-optimizations  -Wmissing-braces \
 -Wmissing-format-attribute   \
 -Wmissing-include-dirs \
 -Wpacked  -Wpadded -Wpointer-arith \
 -Wredundant-decls -Wshadow  -Wstack-protector \
 -Wswitch-default  -Wswitch-enum \
 -Wunknown-pragmas  -Wunreachable-code -Wunused \
 -Wvariadic-macros  -Wwrite-strings \
 -Wlogical-op -Wsign-conversion  \
 -Wstrict-overflow=5 -Wundef

August 2, 2012

Windows 7 change alt-tab preview deplay


Open Registry Editor and create the following registry key:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\AltTab.

In that key, create the following DWORD value: LivePreview_ms and set it to the delay (in milliseconds) of the first live preview.

Restart Explorer to see the changes.

Other Aero-peek related registry entries that I've found on the net are:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced

    DesktopLivePreviewHoverTime
    ThumbnailLivePreviewHoverTime
    ExtendedUIHoverTime

These control the delay of other components of Aero-peek.

Give regular user right to start/stop service in Windows 7


  1. Download and install SubInACL.exe
  2. run "C:\Program Files\Windows Resource Kits\Tools\subinacl" /service Spooler /grant=<username>=TO
SubInACL works on Windows 7.
The T grant parameter is for start service access and the O parameter is stop service access.
Now <username> can:
  • run sc stop Spooler and sc start Spooler
  • run net stop "Print Spooler" and net start "Print Spooler"
  • use the Restart button on the Print Spooler item in services.msc
Source: http://superuser.com/questions/419194/is-there-a-way-to-allow-standard-users-to-restart-stop-start-the-print-spooler

Update: The single subinacl.exe download seems to be not available anymore. Try download the windows 2003 resource toolkit at

Windows Server 2003 Resource Kit Tools

July 27, 2012

How to Resolve “mount error(12): Cannot allocate memory” on a Windows Share


From: http://jlcoady.net/windows/how-to-resolve-mount-error12-cannot-allocate-memory-windows-share

If you mount a Windows 7 share using Samba/CIFS you may run into “mount error(12): Cannot allocate memory” if you are using very large files on the Windows machine. Looks like in certain situations Windows needs to be told to run as a file server and to expect large files. You can read more details at Large Files are locking up Windows 7 32 bit and 64 bit, but the solution is to make two registry edits and then restart a service:
  1. Set “HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\LargeSystemCache” to “1″.
  2. Set “HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters\Size” to “3″.
  3. Restart the “server” service.
Once you have done that you should be able to mount the share using a command like “sudo mount -a” or just reboot the Linux machine.

July 18, 2012

__USE_GNU (use GNU specific feature)


Directly define __USE_GNU is wrong, __USE_GNU is glibc internal macro that shouldn't be ever defined by apps.
The way to select GNU feature set in glibc headers is to define _GNU_SOURCE, either before including first include header in the source .c/.C file, or by defining it on the command line (-D_GNU_SOURCE).

July 16, 2012

VirtualBox USB from the command line

Credit: http://richardhorwood.com/108/virtualbox-usb-from-the-command-line/

How to add a USB device using vboxmanage


  1. Ensure you actually have USB support for your target VM:
    # VBoxManage showvminfo "somevm" | grep USB
    USB:             enabled
  2. If it’s not set to “enabled” you’ll have to add USB support to your VM.  You’ll need to power off the VM to do this:

    # VBoxManage modifyvm "somevm" --usb on --usbehci on
  3. To attach a device that’s plugged into the same system as your VM (in my case, a Sony USB memory stick), grab its UID as follows:
    # VBoxManage list usbhost
    Sun VirtualBox Command Line Management Interface Version 3.1.4
    (C) 2005-2010 Sun Microsystems, Inc.
    All rights reserved.
    
    Host USB Devices:
    [...]
    UUID:               2a2c7255-3b90-448e-aa7a-b1c5710ddd79
    VendorId:           0x054c (054C)
    ProductId:          0x0243 (0243)
    Revision:           1.0 (0100)
    Manufacturer:       Sony
    Product:            Storage Media
    SerialNumber:       6A08102832911
    Address:            0x54c:0x243:256:/pci@0,0/pci108e,5347@2,1
    Current State:      Busy
    
  4. Create a usb filter which will tell VirtualBox to provide the USB device to your virtual machine when it’s detected as plugged in on the host:
    # VBoxManage usbfilter add 0 --target "somevm" --name usbstick \
                   --vendorid 054C --productid 0243
  5. Go ahead and power on your Virtual Machine.  You’ll notice that the USB device (if it’s currently plugged in) immediately becomes unavailable on the host.  You can confirm that it’s attached and that you didn’t make a typo with the vendor and/or product IDs:
    # VBoxManage showvminfo "somevm"
    [...]
    Currently Attached USB Devices:
    
    UUID:               582313d4-1d51-41ea-a053-ba5ac552d2e5
    VendorId:           0x054c (054C)
    ProductId:          0x0243 (0243)
    Revision:           1.0 (0100)
    Manufacturer:       Sony
    Product:            Storage Media
    SerialNumber:       6A08102832911
    Address:            0x54c:0x243:256:/pci@0,0/pci108e,5347@2,1
That’s it.  You can mount and unmount this device now inside your VM.

July 13, 2012

Import certificate and key into java key store using keytool

If you have the certificate and key in pkcs12 format you can directly import it into an existing java key store:

keytool -importkeystore -srckeystore server.p12 -srcstoretype pkcs12 -destkeystore server.jks -deststoretype jks

If you have it in PEM you can convert it to pkcs12 first:
cat server_key.pem server_cert.pem server_cacert.pem > server.pem
openssl pkcs12 -export -out server.p12 -in server.pem

July 2, 2012

Windows VPN: this connection requires an active internet connection

Even though selecting Start>Connect To won't let you connect, this will:
 - Go to Control Panel > Network and Sharing center
 - Click on Manage Network Connections
 - You can see the VPN connection(s) and connect to it (right click and select "Connect")

June 29, 2012

Command line tools on Linux to beautify CSS ,Javascript, and PHP

For CSS, I use "csstidy", the C++ version. I added CSS 3.0 support to it and also added a default "indented" template. You can get the latest version at:
    https://bitbucket.org/tiebingzhang/csstidy

For Javascript, I use the command line version of jsbeautifier, which can be downloaded at
http://github.com/einars/js-beautify/zipball/master

For PHP, I use an enhanced version of phptidy:
https://bitbucket.org/tiebingzhang/phptidy

June 18, 2012

php.ini send email on Linux

If you just want to send email (not receiving email) from your PHP server, and you have a SMTP Email server, here is how you do it:

(First, you don't need to edit your php.ini file SMTP settings, because on Linux those are not used by PHP)

1. Install SSMTP on your system (Debian/Ubuntu via apt-get, RHEL/CentOS using the Fedora EPEL Package search to find the package.
2. Use "ssmtp" to replace "sendmail" on your system. ssmtp use the same command argument as sendmail.
3. configure your /etc/ssmtp/ssmtp.conf file:


root=postmaster
mailhub=SMTP SERVER IP ADDRESS
RewriteDomain=your_from_domain.com
#this allows you to specify your from address
FromLineOverride=YES

4.  Now send an email. Type
ssmtp recipient_email@example.com
sSMTP will then wait for you to type your message, which needs to be formatted like this:
To: recipient_email@example.com
From: myemailaddress@gmail.com
Subject: test email

hello world!

Note the blank like after the subject, everything after this line is the body of the email. When you’re finished, press Ctrl-D.

You can also use script. Create a file msg.txt, then send it:
ssmtp myemailaddress@gmail.com < msg.txt


msg.txt is a simple text using the proper formatting for sSMTP:
To: myemailaddress@gmail.com
From: myemailaddress@gmail.com
Subject: alert

The server is down!



Credit: http://tombuntu.com/index.php/2008/10/21/sending-email-from-your-system-with-ssmtp/

June 15, 2012

CentOS or RHEL enable PHP to make TCP Connect

setsebool -P httpd_can_network_connect 1

June 7, 2012

RHEL/Centos sysconfig network scripts



The /etc/sysconfig/network-scripts/ifcfg-ethN files

File configurations for each network device you may have or want to add on your system are located in the /etc/sysconfig/network-scripts/ directory with Red Hat Linux 6.1 or 6.2 and are named ifcfg-eth0 for the first interface and ifcfg-eth1 for the second, etc. Following is a example /etc/sysconfig/network-scripts/ifcfg-eth0 file:

           DEVICE=eth0
           IPADDR=208.164.186.1
           NETMASK=255.255.255.0
           NETWORK=208.164.186.0
           BROADCAST=208.164.186.255
           ONBOOT=yes
           BOOTPROTO=none
           USERCTL=no
           
If you want to modify your network address manually, or add a new network on a new interface, edit this file -ifcfg-ethN, or create a new one and make the appropriate changes.

  • DEVICE=devicename, where devicename is the name of the physical network device.
  • IPADDR=ipaddr, where ipaddr is the IP address.
  • NETMASK=netmask, where netmask is the netmask IP value.
  • NETWORK=network, where network is the network IP address.
  • BROADCAST=broadcast, where broadcast is the broadcast IP address.
  • ONBOOT=answer, where answer is yes or no. Do the interface need to be active or inactive at boot time.
  • BOOTPROTO=proto, where proto is one of the following :

    1. none - No boot-time protocol should be used.
    2. bootp - The bootp now pump protocol should be used.
    3. dhcp - The dhcp protocol should be used.
  • USERCTL=answer, where answer is one of the following:

    1. yes - Non-root users are allowed to control this device.
    2. no - Only the super-user root is allowed to control this device.  


      NM_CONTROLLED="no"/"yes" : Whether Network-Manager controlled