Monday, December 29, 2014

How to create the Wyse terminal definition in CentOS/Redhat and most other linux flavors.

The mechanism for modifying an existing terminfo definition is quite simple.
  1. Create a source definition for the terminal.
  2. Compile the source definition for the terminal into a binary entry in the terminfo database.
  3. Copy the new terminal definitions to the /lib/terminfo/w directory for a complete solution.
These 3 simple steps are shown below for the wyse definition (Note the 'vi' editor commands are shown to help out).

1. First you will need a valid Wyse terminal definition to create the .ti file that you will use to compile and create a new Wyse terminfo entries.

Using the vi editor, edit the /tmp/wyse.ti file by typing "vi /tmp/wyse.ti"

Copy and paste this into the file.  (Make sure you are in insert mode by typing "i" in the editor)

Here is the termcap file:

------------------ Cut Here --------------------------
60|wy60|wyse60|wy99gt|wyse99gt|Wyse 60 and Wyse 99GT:\
 :am:bw:hs:km:mi:ms:bs:pt:\
 :co#80:li#24:kn#8:\
 :ae=\EH^C:al=4\EE:as=\EH^B:bt=\EI:cd=100\Ey:ce=\Et:\
 :cl=100\E*:cm=\E=%+ %+ :ct=\E0:dc=10\EW:dl=5\ER:\
 :ds=\EF\r:ei=\Er:fs=\r:ho=^^:i1=\EcB0\EcC1:im=\Eq:\
 :ip=3:\
 :is=\Ed$\EcD\E'\Er\EH^C\Ed/\EO\Ee1\Ed*\E`@\E`9\E`1^N^T:\
 :k1=^A@\r:k2=^AA\r:k3=^AB\r:k4=^AC\r:k5=^AD\r:\
 :k6=^AE\r:k7=^AF\r:k8=^AG\r:k9=^AH\r:kb=\b:kd=\n:\
 :kh=^^:kl=\b:kr=\f:ku=^K:nd=\f:r1=150\E~!\E~4:\
 :r2=150\EeF:r3=150\EwG\Ee(:se=\EG0:so=\EGt:sr=7\Ej:\
 :st=\E1:ts=\EF:uc=\EG8%.\EG0:ue=\EG0:up=^K:us=\EG8:\
 :ve=\E`1:vi=\E`0:ko=le,do,nd,up,dc,dl,ho,al:
wy60-25-w|wyse60-25-w|wyse 60 132-column 25-lines:\
 :am:bw:hs:km:mi:ms:bs:pt:\
 :co#132:li#25:kn#8:\
 :ae=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\b:kd=\n:\
 :kh=^^:kl=\b:kr=\f:ku=^K:nd=\f:r1=150\E~!\E~4:\
 :r2=300\EeF\E`;:r3=150\EwG\Ee(:se=\EG0:so=\EGt:\
 :sr=7\Ej:st=\E1:ts=\EF:uc=\EG8%.\EG0:ue=\EG0:up=^K:\
 :us=\EG8:vb=100\E`8\E`9:ve=\E`1:vi=\E`0:\
 :ko=le,do,nd,up,dc,dl,ho,al:
------------------ Cut Here --------------------------

Next, get out of insert mode in the editor by pressing escape.

Then type :wq and enter to write and quite the editor.

This will create the /tmp/wyse.ti file needed for the next step.

In this compilation of the terminal definition step, type the following at the shell prompt:
# tic /tmp/wyse.ti
This will create the necessary terminfo database entries for the new wyse terminal definition.

Next, for completion, copy the newly created terminal definitions.  Type the following:

cp /usr/share/terminfo/w/* /lib/terminfo/w    and press <enter>

After the items are copied, you can test and examine the definitiions by using "infocmp" utility.

The infocmp command is used to de-compile the binary database entry for the wyse terminal and the output is re-directed to file wyse.ti. This file can then be modified with any editor, in this example vi was shown. Finally , as root user, the tic command is used to compile the source file definition into a compiled binary entry in the terminfo database.

The layout of the source file 'wyse.ti' is explained fully by using the Unix command 'man terminfo'. 

Friday, December 12, 2014

HowTo Red Hat Enterprise Linux 5 Configure The Network Card

HowTo Red Hat Enterprise Linux 5 Configure The Network Card


Red hat Enterprise Linux version 5.x and 4.x provides the following tools to make changes to network configuration such as add new card, assign/change IP address/subnet/gateway, and change DNS server and more.

[a] GUI tool - system-config-network
[b] Command line text based GUI tool (No X Windows/Gnome/KDE required) - system-config-network
[c] Edit configuration files stored in/etc/sysconfig/network-scripts/ directory. This method works with remote server over the ssh based session.
The following instructions are tested and compatible with:
  1. Cent OS Linux v3/4/5.x.
  2. Fedora Core Linux (older version).
  3. Red Hat Enterprise Linux (RHEL) v3/4/5.x based server.
Method # 1: GUI tool system-config-network
Open the X terminal or login using ssh over X based session command (ssh -X user@server-name-here). Type the following command at shell prompt:
Warning: It is important that you configure network interface cards correctly over ssh -X based session; otherwise, you will be locked out due to wrong network configuration.
$ system-config-network &
Sample outputs:
Fig.01: Configuring the RHEL/CentOS server network card using GUI tool
Fig.01: Configuring the RHEL/CentOS server network card using GUI tool
You will see a Window as above. Next, select your Ethernet card (such as eth0 or eth1) and click on the Edit button. You can now setup/modify IP address, netmask, default gateway and other properties. Here is an example from my personal RHEL 5.x server:
Fig.02: Setting or modifying IPv4 and IPv6 properties on RHEL/CentOS based server
Fig.02: Setting or modifying IPv4 and IPv6 properties on RHEL/CentOS based server
You can obtain IP address using DHCP or setup manually. Once IP address assigned, click onOk button to save the changes. You can activate card by clicking on Activate button.

Method # 2: Command line tool system-config-network-tui

If you don't have X windows GUI (gnome/kde desktop) installed on RHEL/CentOS/Fedora based system, than type the following command at shell prompt (this method also works on remote server using ssh based session):
Warning: It is important that you configure network interface cards correctly over ssh based session; otherwise, you will be locked out due to wrong network configuration.
# system-config-network-tui &
Sample outputs:
Fig.03: RHEL/CentOS command line network config tool (click to large)
Fig.03: RHEL/CentOS command line network config tool (click to large)
Select your Ethernet card such as eth0 or eth1 and hit [Enter] or [F12] special key to configure IP properties for selected NIC:
Fig.04: Setting up IPv4 properties on RHEL/CentOS (click to large)
Fig.04: Setting up IPv4 properties on RHEL/CentOS (click to large)
You can obtain an IP address using DHCP or setup IP address manually. Once an IP address assigned, click on the Ok button to save the changes.

Method #3: Edit configuration files stored in/etc/sysconfig/network-scripts/ directory

You can configure network card by editing text files stored in /etc/sysconfig/network-scripts/ directory. Open the terminal or login using ssh. Next, change directory to /etc/sysconfig/network-scripts/:
# cd /etc/sysconfig/network-scripts/
You need to edit / create files as follows using a text editor such as vi:
  • /etc/sysconfig/network-scripts/ifcfg-eth0 : First Ethernet card configuration file.
  • /etc/sysconfig/network-scripts/ifcfg-eth1 : Second Ethernet card configuration file.

Examples: Edit eth0 configuration file

To edit/create first NIC file, type the following command in /etc/sysconfig/network-scripts/ directory:
Warning: It is important that you configure network interface cards correctly over ssh based session; otherwise, you will be locked out due to wrong network configuration.
# vi ifcfg-eth0
OR
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
Edit or modify as follows for static ip configuration:
# eth0 - Intel Corporation 82573E Gigabit Ethernet Controller (Copper) on server1.cyberciti.biz by nixCraft on 10/4/2007
DEVICE=eth0
BOOTPROTO=static
DHCPCLASS=
HWADDR=00:30:48:56:A6:2E
IPADDR=10.10.29.66
NETMASK=255.255.255.192
ONBOOT=yes
 
Save and close the file.

Setting up default gateway and server (host) name

You need to define a default gateway (router IP) and hostname in /etc/sysconfig/network file. Edit /etc/sysconfig/network, enter:
# vi /etc/sysconfig/network
Append or modify configuration as follows:
NETWORKING=yes
HOSTNAME=www1.nixcraft.in
GATEWAY=10.10.29.65
 
Save and close the file. Finally, you need to restart the network service, run:
# /etc/init.d/network restart
OR
# /sbin/service network restart

Setting up dns server

Make sure you have correct DNS server defined in /etc/resolv.conf file:
# vi /etc/resolv.conf
Setup DNS server IP address as follows (feel free to replace 10.0.80.11, 10.0.80.12 as per your setup):
nameserver 10.0.80.11
nameserver 10.0.80.12
nameserver 202.67.222.222

Save and close the file. Now you can ping the gateway/other hosts using the ping command:
$ ping 10.0.80.12
Sample outputs:
PING 10.0.80.12 (10.0.80.12) 56(84) bytes of data.
64 bytes from 10.0.80.12: icmp_seq=1 ttl=251 time=0.972 ms
64 bytes from 10.0.80.12: icmp_seq=2 ttl=251 time=1.11 ms
You can also check for Internet connectivity with the ping, nslookup and/or host command:
$ nslookup cyberciti.biz
Sample outputs:
Server:         10.0.80.11
Address:        10.0.80.11#53
Non-authoritative answer:
Name:   cyberciti.biz
Address: 75.126.43.232
You can also use host dns lookup command as follows:
$ host nixcraft.in
Sample outputs:
nixcraft.in has address 75.126.43.232
nixcraft.in mail is handled by 10 mail.nixcraft.in.

How do I see or debug network configuration on RHEL/CentOS based server?

Simply use any one of the following commands:
 
###########################
## display ip config     ##
###########################
ifconfig
ifconfig -a | more
ifconfig eth0
ifconfig eth1
ip link
ip addr
 
###########################
## display routing table ##
###########################
route
route -nr
route -nr|more
ip route
 
###########################
## display dns config    ##
###########################
cat /etc/resolv.conf
 
###########################
## display firewall config#
###########################
iptables -L -n -v | more
cat /etc/sysconfig/iptables
 
###########################
## Debug network issues   #
###########################
ping host-name-here
ping ip-addeess-here
host ip-address-here
host domain-name-here
traceroute host-name-here
mtr host-name-here
dmesg | grep eth
lspci  | grep -i eth