Saturday, October 27, 2007

FTP Server - Active vs Passive

What is FTP server?
FTP stands for File Transfer Protocol. It is associated with two ports(21,20).
FTP server listening on port 21 for client connection.

PORT 21 : command port
PORT 20 : data port (depends on ftp server mode)

FTP Server Types :

1. Active FTP Server
2. Passive FTP Server

In both the modes, the client initiates the connection to the command port for request of file transfer. It only differs in the data tranfer connection creation.


1. Active FTP Server
In Active FTP server mode, steps involved for file tranfer are given below.

1. Client creates a connection to server and informs the server that on which port the server should do the data transfer with client.
Client port : >1023
Server port : 21


2. Server creates a connection to client to the port mentioned by the client from its port 20
client port : >1023
server port : 20

3. Once the port is closed means that the data transfer is complete.


Passive FTP Server :
1. Client creates a connection to server and gets the information from the server that on which port the client should do the data transfer with server.
Client port : >1023
Server port : 21


2. Client creates a connection to the server on the mentioned port and do the data transfer
client port : >1023
server port : >1023


-------------------------------------------

Which One Will You Use:
It depends on the purpose for which you are running.

FireWall @server side:
In this case, if you use passive ftp server, the client will try to initiate connection with server on ports >1023. So the firewall on the server side will block the ftp data transfer even though it gets connected with ftp server on port 21. So in this case its better to use Active Ftp server.

Distributing files using FTP server:
in this case, if you use active ftp server, the server will try to initiate connection with server on ports >1023. So the firewall on the client side will block the ftp data transfer even though it gets connected with ftp server on port 21. So in this case its better to use PASSIVE Ftp server.

Thursday, October 25, 2007

Run a Script or command during bootup

This example is for RedHat and Fedora Linux

If you want to execute a shell script or command during system bootup (like startup in microsoft windows), put that command inside the file /etc/rc.local.

The last file which gets executed during system startup is /etc/rc.local

So whatever you want to execute during boot up can be put inside this file.

Example:

if you want to add a static route

1. open the file /etc/rc.local

2. put the command

/sbin/route add -net 10.0.0.0 netmask 255.0.0.0 gw 10.0.0.1
3. close the file

next time when you restarts the system this static route will be added in your routing table.

Execute a shell script program

Add a route using command in a seperate file

1. vi add-static-routes.sh (i am creating this file under /etc. but it can be created anywhere)

2. add commands

/sbin/route add -net 10.0.0.0 netmask 255.0.0.0 gw 10.0.0.1
/sbin/route add -net 20.0.0.0 netmask 255.0.0.0 gw 10.0.0.2

3. open the file /etc/rc.local

4. enter the following line

/bin/bash /etc/add-static-routes.sh

( If you created the file in some other location , give the correct path)


That's all.

If you want delete the routes which you created using the above file, just replace add as del.

/sbin/route del -net 10.0.0.0 netmask 255.0.0.0 gw 10.0.0.1
/sbin/route del -net 20.0.0.0 netmask 255.0.0.0 gw 10.0.0.2

Tuesday, October 16, 2007

How to access intranet and internet simultaneously

how to access Two networks simulteneously

Suppose if you are having two networks

1. intranet (your official network)
2. internet

how to configure your pc to get access simultaneously.

Let the pc is having 2 Lan cards


LAN CARD 1 is connected to the intranet site.

LAN CARD 2 is connected to the internet.

you can configure only one default gateway.

even if you give gateway address in the tcp/ip configuration in both lan cards, only one will be the effetive.

Simple steps:
1. In NIC1 configure only IP and subnet mask
2. In NIC2 Configure ip, subnetmask, gateway.
3. configure static route for wan network




the below example shows the default gateway points to internet.





here is the simple and how the configuration done


C:\Documents and Settings\balasankar.sellappan>ipconfig

Windows IP Configuration


Ethernet adapter Wireless Network Connection:

Connection-specific DNS Suffix . :
IP Address. . . . . . . . . . . . : 192.168.1.33
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.1.1

Ethernet adapter Local Area Connection:

Media State . . . . . . . . . . . : Media disconnected

PPP adapter Mottu:

Connection-specific DNS Suffix . :
IP Address. . . . . . . . . . . . : 59.92.52.248
Subnet Mask . . . . . . . . . . . : 255.255.255.255
Default Gateway . . . . . . . . . : 59.92.52.248

after the configuration of the both the lan cards
the routing table looks as given below



C:\Documents and Settings\balasankar.sellappan>route print
===========================================================================
Interface List
0x1 ........................... MS TCP Loopback interface
0x2 ...00 1b 77 a8 a5 34 ...... Intel(R) PRO/Wireless 3945ABG Network Connect
- Packet Scheduler Miniport
0x30004 ...00 1c 23 0d fb 51 ...... Broadcom NetXtreme 57xx Gigabit Controlle
Packet Scheduler Miniport
0x60005 ...00 53 45 00 00 00 ...... WAN (PPP/SLIP) Interface
===========================================================================
===========================================================================
Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 59.92.52.248 59.92.52.248 1
0.0.0.0 0.0.0.0 192.168.1.1 192.168.1.33 26
59.92.32.1 255.255.255.255 59.92.52.248 59.92.52.248 1
59.92.52.248 255.255.255.255 127.0.0.1 127.0.0.1 50
59.255.255.255 255.255.255.255 59.92.52.248 59.92.52.248 50
127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1
192.168.1.0 255.255.255.0 192.168.1.33 192.168.1.33 25
192.168.1.33 255.255.255.255 127.0.0.1 127.0.0.1 25
192.168.1.255 255.255.255.255 192.168.1.33 192.168.1.33 25
224.0.0.0 240.0.0.0 192.168.1.33 192.168.1.33 25
224.0.0.0 240.0.0.0 59.92.52.248 59.92.52.248 1
255.255.255.255 255.255.255.255 59.92.52.248 59.92.52.248 1
255.255.255.255 255.255.255.255 192.168.1.33 30004 1
255.255.255.255 255.255.255.255 192.168.1.33 192.168.1.33 1
Default Gateway: 59.92.52.248
===========================================================================
Persistent Routes:
None


So. now the default gateway is 59.92.52.248. so you can access internet and local lan. you can not access your WAN network.

what will happen if you access 192.168.10.1 which is a WAN IP.

1. first checks whether this ip belongs to local lan.
2. if not, looks the routing table and forward this packet to default gateway
3. so this is searching this ip in internet domain. it won't find it there. so packet lost.

To direct this wan traffic to 192.168.1.33, you need to define a manual route for this WAN network

why should i define manual route for WAN? why not for Internet?

Because we know WAN ip network segmnet. But for the internet, we can't define the network addresses.

C:\Documents and Settings\balasankar.sellappan>route -p add 192.168.0.0 mask 255.255.0.0 192.168.1.33



-p option in the route add command is make this persistent.

to delete a route, use the following command

route delete 192.168.0.0



after adding the manual route , now the routing table looks like as given below

C:\Documents and Settings\balasankar.sellappan>route print
===========================================================================
Interface List
0x1 ........................... MS TCP Loopback interface
0x2 ...00 1b 77 a8 a5 34 ...... Intel(R) PRO/Wireless 3945ABG Network Connectio
- Packet Scheduler Miniport
0x30004 ...00 1c 23 0d fb 51 ...... Broadcom NetXtreme 57xx Gigabit Controller
Packet Scheduler Miniport
0x60005 ...00 53 45 00 00 00 ...... WAN (PPP/SLIP) Interface
===========================================================================
===========================================================================
Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 59.92.52.248 59.92.52.248 1
0.0.0.0 0.0.0.0 192.168.1.1 192.168.1.33 26
59.92.32.1 255.255.255.255 59.92.52.248 59.92.52.248 1
59.92.52.248 255.255.255.255 127.0.0.1 127.0.0.1 50
59.255.255.255 255.255.255.255 59.92.52.248 59.92.52.248 50
127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1
192.168.0.0 255.255.0.0 192.168.1.33 192.168.1.33 1
192.168.1.0 255.255.255.0 192.168.1.33 192.168.1.33 25
192.168.1.33 255.255.255.255 127.0.0.1 127.0.0.1 25
192.168.1.255 255.255.255.255 192.168.1.33 192.168.1.33 25
224.0.0.0 240.0.0.0 192.168.1.33 192.168.1.33 25
224.0.0.0 240.0.0.0 59.92.52.248 59.92.52.248 1
255.255.255.255 255.255.255.255 59.92.52.248 59.92.52.248 1
255.255.255.255 255.255.255.255 192.168.1.33 30004 1
255.255.255.255 255.255.255.255 192.168.1.33 192.168.1.33 1
Default Gateway: 59.92.52.248
===========================================================================
Persistent Routes:
Network Address Netmask Gateway Address Metric
192.168.0.0 255.255.0.0 192.168.1.33 1

C:\Documents and Settings\balasankar.sellappan>

Saturday, October 13, 2007

linux boot problem with grub

Linux Boot Loader
LILO (Linux Loader)
GRUB (Graphical User Boot)
The default boot loader in Redhat linux till Redhat Liux 8.0 is LILO. From Redaht 9.0 onwards the default boot loader is GRUB.

GRUB
The configuration file grub.conf is under /boot/grub directory. the other two important files are stage1,stage2 and splashImage.

GRUB is broken into 2 stages, which are loaded at different times in the boot process.
The Stage 1 has to know where to find Stage 2
The Stage 2 has to know where to find it's configuration file

if Stage 2 doesn't have a config file, it drops into the command-line interface and waits for a user command as shown below

grub>

the simple configuration in grub.conf file

title Redhat Linux // the title given here is shown in the boot menu option
root (hd0,0) // telling the file system of the boot files and kernel
kernel vmlinuz-??????? root=/dev/hda5 // this tells the where the /sbin/loader is located
initrd ----------------


if you are dropped at
grub>
command line, then you can boot your system with following way

grub> root (hd0,0)
grub> kernel vmlinuz---- root=/dev/hda5
grub> boot

it will start booting into your system

----- this post not yet completed

Thursday, October 11, 2007

nc command for network program testing

hi folks,
What is the command nc in linux?
nc is abbreviation of netcat (network cat)

What are the Uses of this command???

debuging Network Program
This command is very useful when you are doing a network programming. you can use this command nc as server as well as client. if your server program is running and you do not have client program then you can easily use this command

catching the traffic over the network
We can capture the traffic which flowing over the network. The normal cat command only shows the contents of a file inside the system.

Chating over network
Without installing any chat server and client, we can initiate the chat session between computers in the network

for more information and command usage visit the man page of linux

Prevent Hot Linking to images

How do you stop other sites directly linking to your images and media files and stealing your bandwidth? Simple. Open notepad (or similar text editor) and add the following and (this is important) save it as .htaccess (the dot before htaccess is important).

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www.)?mywebsite.com(/)?.*$ [NC]
RewriteRule .*.(gifjpgjpegbmpwmv)$
http://www.mywebsite.com/image.jpg [R,NC]

Edit this rule to suit your web domain and redirect requirements.
Google

Ads By Google

Ads By Google