GOOGLE Search

Google
 

Thursday, January 31, 2008

Linux Tip No. 9: Setting your hostname

Setting your hostname

File: /etc/sysconfig/network

[root@proxy sysconfig]# more network

NETWORKING=yes

HOSTNAME=localhost.localdomain

Example:

Edit the file

[root@proxy docadmin]# cat /etc/sysconfig/network

NETWORKING=yes

HOSTNAME=proxy.jepoy.net

[root@proxy docadmin]# /sbin/service network restart
Shutting down interface eth0: [ OK ]
Shutting down interface eth1: [ OK ]
Shutting down loopback interface: [ OK ]
Disabling IPv4 packet forwarding: net.ipv4.ip_forward = 0
[ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: [ OK ]
Bringing up interface eth1: [ OK ]

[root@proxy docadmin]# hostname

proxy.jepoy.net

Tuesday, January 15, 2008

Linux Tip No. 8: Tcpdump to capture traffic

Using tcpdump to capture the traffic

[root@proxy /]# /usr/sbin/tcpdump -i eth0 port 80
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes
09:17:49.575590 IP proxy.jepoy.ph.56790 > nxdomain.guide.opendns.com.http: S 583111147:583111147(0) win 5840
09:17:49.755526 IP nxdomain.guide.opendns.com.http > proxy.jepoy.ph.56790: S 1378975104:1378975104(0) ack 583111148 win 16384
09:17:49.755592 IP proxy.jepoy.ph.56790 > nxdomain.guide.opendns.com.http: . ack 1 win 1460
09:17:49.756126 IP proxy.jepoy.ph.56790 > nxdomain.guide.opendns.com.http: P 1:248(247) ack 1 win 1460

Monday, January 7, 2008

Linux Tip No. 7: Print System Info

uname - print system info

Example:
[admin@proxy ~]$ uname -a
Linux proxy 2.6.11-1.1369_FC4 #1 Thu Jun 2 22:55:56 EDT 2005 i686 i686 i386 GNU/Linux

Sunday, January 6, 2008

Linux Tip No. 6: Creating a Logical Link

Create a File as a Logical Link to Another File

[root@mail admin]#ln -s existingFile newFile

Example:
Link the maillog to your home directory

[root@mail admin]#ln -fs /var/log/maillog .
[root@mail admin]#ls -al
lrwxrwxrwx 1 root root 16 Jan 7 14:48 maillog -> /var/log/maillog

Wednesday, January 2, 2008

Linux Tip No. 5: Determining the uptime

[root@mail admin]# uptime
10:45:52 up 89 days, 10:26, 1 user, load average: 0.00, 0.02, 0.00

Wednesday, December 26, 2007

Linux Tip No. 4: Sorting the Biggest Directory

This command will show the biggest directory.

[root@nuxmachine admin]# du -Sh | sort -n
4.0K ./backup
9.8M ./backup/web
11G ./backup/home
16K ./.ssh
28K ./backup/Dovecot
28K ./backup/users/last-full
36K .
36K ./backup/users
40K ./backup-sh
328K ./backup/Postfix
628K ./backup/MailScanner

Monday, December 17, 2007

Linux Tip No. 3: How to Check NIC Settings in Tru64

How to Check NIC Speed and Negotiation

#hwmgr get attr -cat network | grep -E "name|speed|duplex"

Thursday, December 13, 2007

Linux Tip No. 2: Combining Tail and Awk

- you can use this command to provide a nice output of logs.

Command:
>tail -f logs.log | grep -e "word" | awk '{ print $12 "\t" $13' }'

"word" - any line containing "word" will be captured
$12 - column 12
"\t" - space

Tuesday, December 11, 2007

How To: Foward Tape Content in Tru64

How To: Forward Tape Content in Tru64

root@machine01:/home/data/backup/databases# mt fsf 1
root@machine01:/home/data/backup/databases# vrestore -t -f /dev/ntape/tape0
vrestore: Date of the vdump save-set: Mon Nov 5 22:22:07 2007
vrestore: Save-set source directory : /home/data/backup/
vrestore: Target directory : /usr1/data/backup/

Tuesday, December 4, 2007

Devices on AIX

Devices on AIX

Devices Information on AIX

1.List all devices on a system
lsdev
Device states are: Undefined; Supported Device, Defined; Not usable
(once seen), Available; Usable

2.List all disk devices on a system (Some other devices are: adapter,
driver, logical volume, processor)
lsdev -Cc disk

3.List all customized (existing) device classes (-P for complete list)
lsdev -C -r class

4.Remove hdisk5
rmdev -dl hdisk5

5.Get device address of hdisk1
getconf DISK DEVNAME hdisk1 or bootinfo -o hdisk1

6.Get the size (in MB) of hdisk1
getconf DISK SIZE hdisk1 or bootinfo -s hdisk1

7.Find the slot of a PCI Ethernet adapter
lsslot -c pci -l ent0

8.Find the (virtual) location of an Ethernet adapter
lscfg -l ent1

9.Find the location codes of all devices in the system
lscfg

10.List all MPIO paths for hdisk0
lspath -l hdisk0

11.Find the WWN of the fcs0 HBA adapter
lscfg -vl fcs0 | grep Network

12.Temporarily change console output to /console.out
swcons /console.out (Use swcons to change back.)

Monday, December 3, 2007

Router: Traffic Shaping

Traffic Shaping

class-map match-any IB-11.70
match access-group name IB-11.70
!
class-map match-any OB-11.70
match access-group name OB-11.70
!
!
policy-map To-Public
class OB-11.70
shape average 256000
!
policy-map To-Lan
class IB-11.70
shape average 256000
!
!
interface FastEthernet0
description ***LAN side***
ip address 20.18.11.65 255.255.255.224
service-policy output To-Lan
speed auto
!
interface Serial0
description *** To Public Serial 2/1 ***
bandwidth 2000000
ip address 20.18.11.98 255.255.255.252
service-policy output To-Public
load-interval 30
clockrate 2000000
!
ip route 0.0.0.0 0.0.0.0 20.18.11.97
!
!
ip access-list extended IB-11.70
permit ip any host 20.18.11.70
ip access-list extended OB-11.70
permit ip host 20.18.11.70 any

Note:
The service is always in the OUTPUT policy.
Service Policy To-LAN is inbound of LAN.
Service Pplicy To-Public is outbound of LAN.

Linux Tip No. 1: Change Timezone

Change Timezone on AIX
chtz (timezone eg GMT0BST) - Changes the timezone in /etc/environment file

Thursday, November 29, 2007

Router: NAT with DHCP

ip dhcp excluded-address 192.168.0.1 192.168.0.127
!
ip dhcp pool LANDHCP
network 192.168.0.0 255.255.255.0
domain-name jefferson.com
dns-server 20.18.11.34
netbios-name-server 20.18.11.34
default-router 192.168.0.1
!
interface Ethernet0/0
description **** To Public Interace Fa0/1 ****
ip address 20.18.10.2 255.255.255.252
ip nat outside
ip virtual-reassembly
full-duplex
!
interface Ethernet1/0
description ***Connection To LAN ***
ip address 192.168.0.1 255.255.255.0 secondary
ip address 20.18.10.129 255.255.255.128
ip nat inside
ip virtual-reassembly
full-duplex

ip route 0.0.0.0 0.0.0.0 20.18.10.1
!
ip nat inside source list 10 interface Ethernet0/0 overload
!
access-list 10 permit 192.168.0.0 0.0.0.255
access-list 10 deny any

Wednesday, November 28, 2007

Router: NAT with Secondary IP Address

interface Ethernet0/0
description **** To Public Address ****
ip address 20.18.10.2 255.255.255.252
ip nat outside
ip virtual-reassembly
full-duplex
!
interface Ethernet1/0
description ***Connection To LAN ***
ip address 192.168.0.1 255.255.255.0 secondary
ip address 20.18.10.129 255.255.255.128
ip nat inside
ip virtual-reassembly
full-duplex


ip route 0.0.0.0 0.0.0.0 20.18.10.1
!
ip nat inside source list 10 interface Ethernet0/0 overload
!
access-list 10 permit 192.168.0.0 0.0.0.255
access-list 10 deny any

Monday, November 19, 2007

Tape Commands in AIX

Useful Tape commands in AIX

1.Rewind and eject the rmt0 tape drive
# tctl -f /dev/rmt0 offline

2.Rewind the rmt0 tape drive
# mt -f /dev/rmt0 rewind

3.Check the content of the tape
#tctl -f /dev/rmt0.1 -b 1024 -n read

Tape Commands in Tru64

*****************************
Useful Tape Commands in Tru64
*****************************


Rewind and unload the tape
mt -t /dev/ntape/tape0 offline

1. rewind the tape
#mt -f /dev/ntape/tape0 rewind
or
#mt rewind

2. check the content
#vrestore -t -f /de/ntape/tape0

3. for interactive resotre
#vrestore -i

add - add the file
restore -restore the file

4. for manual restore
Example: restore jeff02.backup.log file from tape /dev/ntape/tape0/jeff02 to the current directory
# vrestore -x /jeff02/jeff02.backup.log

#vrestore -x -D /tmp /jeff02/jeff02.backup.log
root@jeff02:/tmp# cd /home
root@jeff02:/home# vrestore -x -D /tmp /jeff02/jeff02.backup.log
vrestore: Date of the vdump save-set: Mon Oct 22 20:33:06 2007
vrestore: Save-set source directory : /
vrestore: Target directory : /tmp

Monday, November 5, 2007

AIX as NTP Client

AIX as NTP Client
On machine that will be the client:
1. In file /etc/ntp.conf

Add:
server

prefer
driftfile /etc/ntp.drift
tracefile /etc/ntp.trace


2. Issue command:
ntpdate


NOTE:If it doesn't say "No server suitable for synchronization found" proceed
to next step.


3. Start using:
#smitty xntpd -> Start at both system restart and now
or
#startsrc -s xntpd

and uncomment the line in /etc/rc.tcpip
start /usr/sbin/xntpd -x "$src_running"


Let the daemon run for 6 miuntes before proceeding to the next step - or
may get stratum 16 error.


4.
#lssrc -ls xntpd
Stratum should show between 3-4, but longer is okay so long as not 16.

#ntpdate -d
(to sync server to client)
# ntpq -p

remote refid st t when poll reach delay offset jitter
=====================================================================
LOCAL(0) LOCAL(0) 3 l 9 64 377 0.000 0.000 0.000
*swisstime.ethz. .DCFa. 1 u 17 64 377 25.088 -10.040 1.071

Thursday, October 25, 2007

NTP on UNIXTru64

NTP Information

NTP Version
1-ntpd daemon
2-xntpd
3-xntpd


SYSMAN
# /usr/bin/sysman ntp_config


# ntpq -p

remote refid st t when poll reach delay offset jitter
=====================================================================
LOCAL(0) LOCAL(0) 3 l 9 64 377 0.000 0.000 0.000
*xyzabc.ethz. .DCFa. 1 u 17 64 377 25.088 -10.040 1.071

% xntpdc -p
remote refid st when poll reach delay offset disp
==========================================================================
*hosta.corp.com hostj.corp.co 2 47 64 377 31.3 93.94 16.5
+hostb.corp.com hoste.corp.com 3 212 1024 377 33.8 89.58 16.9
.hostc.corp.com hostf.phi.edu 2 111 1024 377 39.1 46.98 17.7


Edit the configuration file /etc/ntp.conf

server 127.127.1.0 # local clock
server 129.132.2.21 # swisstime.ethz.ch (stratum 1)
driftfile /etc/ntp/drift
multicastclient # listen on default 224.0.1.1
broadcastdelay 0.008



Start NTP Server and check /var/log/messages
# /etc/rc.d/init.d/ntpd start



You can use sysman to configure NTP client.
Edit /etc/ntp.conf and add:

server version 3
server version 3
server version 3

In /etc/rc.config set:

XNTPD_CONF="YES"
XNTP_SERV1="ntp_server1"
export XNTP_SERV1
XNTP_SERV2="ntp_server2"
export XNTP_SERV2
XNTP_SERV3="ntp_server3"
export XNTP_SERV3

# ntpdc monlist

to get the lis

#ntpdate -b

How To: AIX Networking

Network Administration on AIX

1.TCP/IP related daemon startup script
/etc/rc.tcpip

2.To view the route table
netstat -r

3.To view the route table from the ODM DB
lsattr -EHl inet0 -a route

4.Temporarily add a default route
route add default 192.168.1.1

5.Temporarily add an address to an interface
ifconfig en0 192.168.1.2 netmask 255.255.255.0

6.Temporarily add an alias to an interface
ifconfig en0 192.168.1.3 netmask 255.255.255.0 alias

7.To permanently add an IP address to the en1 interface
chdev -l en1 -a netaddr=192.168.1.1 -a netmask=0xffffff00

8.Permanently add an alias to an interface
chdev -l en0 -a alias4=192.168.1.3,255.255.255.0

9.Remove a permanently added alias from an interface
chdev -l en0 -a delalias4=192.168.1.3,255.255.255.0

10.List ODM (next boot) IP con guration for interface
lsattr -El en0

11.Permanently set the hostname
chdev -l inet0 -a hostname=www.tablesace.net

12.Turn on routing by putting this in rc.net
no -o ipforwarding=1

13.List networking devices
lsdev -Cc tcpip

14.List Network Interfaces
lsdev -Cc if

15.List attributes of inet0
lsattr -Ehl inet0

16.List (physical layer) attributes of ent0
lsattr -El ent0

17.List (networking layer) attributes of en0
lsattr -El en0

18.Speed is found through the entX device
lsattr -El ent0 -a media speed

19.Set the ent0 link to Gig full duplex
(Auto Negotiation is another option)
chdev -l ent0 -a media speed=1000 Full Duplex -P

20.Turn off Interface Speci c Network Options
no -p -o use isno=0

21.Get (long) statistics for the ent0 device (no -d is shorter)
entstat -d ent0javascript:void(0)
Save Now

22.List all open, and in use TCP and UDP ports
netstat -anf inet

23.List all LISTENing TCP ports
netstat -na | grep LISTEN

Timezone on Tru64

Change Timezone on Unix Tru64
/etc/zoneinfo
/etc/zoneinfo/localtime
/etc/zoneinfo/sources
zic(8)

Changing localtime to New York
# ln -sf /etc/zoneinfo/America/New_York /etc/zoneinfo/localtime
# ln -sf /etc/zoneinfo/Hongkong /etc/zoneinfo/localtime