Monday, March 8, 2010
Port forwarding
1.) Every device on the internet has at least one ip address. The IP address is a number that is used to identify a device. For more information on ip addresses refer to our What is an IP Address page.
2.) Every IP address is divided up into many ports. When one computer sends data to another computer, it sends it from a port on an ip address to a port on an ip address. For more information on ports refer to our What is a Port page.
3.) A port can only be used by one program at a time.
Now that we've got those general concepts out of the way let's talk about NAT. NAT is an acronym for Network Address Translation. NAT takes one ip address and basically breaks it into many ip addresses.
[img]http://www.portforward.com/help/BasicNetwork.jpg[\img]
Here the external ip address is broken into two internal ip addresses. The first ip address "IP Address1" is the gateway. While "IP Address2" is the ip address of the first computer. Take note that the router has two ip addresses. It has the external ip address, and an internal ip address which acts as the gateway for every computer on the network.
[img]http://www.portforward.com/help/NetworkVisibility.jpg[\img]
Excuse my rough drawing. Computers on the internal network can only "see" internal ip addresses. So computers on the internal network can not send data directly to a computer outside of the network. When a computer on the network wants to send data to a computer outside of the network, it sends the data to the gateway. Remember the gateway is the internal ip address of the router. The router then takes this data and sends it out to the computer on the internet. The router sends the data out of the external ip address. The same thing is true of computers on the internet. A computer outside of the network can not "see" a computer inside of the network. They can only "see" and send data to the external ip address of the router. The router must then decide what to do with this data. Lucky for us NAT takes care of most of the work for us. There are some programs that NAT was not designed to work with, those are the programs we need to set up port forwarding for. Okay take a deep breath! We are on to port forwarding.
Now that you understand the general concepts of a network, explaining port forwarding is easy. When a computer on the internet sends data to the external ip address of the router, the router needs to know what to do with the data. Port Forwarding simply tells the router which computer on the local area network to send the data to. When you have port forwarding rules set up, your router takes the data off of the external ip address:port number and sends that data to an internal ip address:port number. Port Forwarding rules are created per port. So a rule set up for port 53 will only work for port 53.
A port can only be used by one program at a time! Think of how this rule interacts with NAT. Well you've only got one external ip address on your router. When computer 1 is using port 500, it is using port 500 on it's internal ip address. If you have set up a port forwarding rule for computer 1 and port 500, the external ip address's port 500 is also in use. This means that you can only use port 500 on one computer on the network at a time. Using port 500 on two computers at the same time would violate the one program rule, and your data would get messed up. Most routers require you to specify an internal ip address to forward ports to, just for this reason. Some do not, so be aware of this. Port Forwarding rules will only work for one computer at a time!
Reference:
http://portforward.com/help/portforwarding.htm
Friday, February 26, 2010
Firefox
How to make firefox ask me to choose whether to open or save links
tools>options>applications ; Find the program that you want changed. Change action to "Always Ask"
Monday, February 8, 2010
Switching & Routing
In short, If packet forwarding is dependent on mac then your doing switching and if it IP then your doing routing.
Difference between L3 switch and a Router.
Router does forwarding through S/W algoritms whereas L3 does through inbuilt ASICs.
In latest trend, any forwarding done in h/w is named as a switch :-).
L2 switch is a bridge which forward the packets based on MAC address.
Switch is faster than a router because forwarding is built in h/w.
bridges can’t block a broadcast (where a data packet is sent to all nodes on a network). Broadcasts can consume a great deal of bandwidth. Routers are able to block broadcasts, so they provide security and assist in bandwidth control.
Switching:
Ethernet is fundamentally what we call a shared technology.And that is, all users of a given LAN segment are fighting for the same amount of bandwidth.
A by-product that we have in any Ethernet network is something called collisions. And this is a result of the fundamental characteristic of how any Ethernet network works.Basically, what happens in an Ethernet network is that many stations are sharing the same segment. So what can happen is any one of these stations can transmit at any given time.And if 2 or more stations try to transmit at the same time, it's going to result in what we call a collision.
It's also important to understand fundamentally how transmissions can occur in the network. There's basically three different ways that we can communicate in the network.
1. Unicast
2. Broadcast
3. Multicast
in shared bandwidth, Broadcasts Consume Bandwidth & Processor Performance.
References:
http://www.e-tutes.com/index.html
http://www.e-tutes.com/lesson8/networking_fundamentals_lesson8_1.htm
http://www.tcpipguide.com/
Sunday, February 7, 2010
Linux
In general xinetd will be listening for general daemons like ssh & telnet. When telnet request comes, xinetd handovers the control to telnetd and it inturn starts login which
xinetd--->telnetd--->login--->shell
xinetd--->sshd--->shell
PAM: Pluggable Authentication Modules
PAM is a library.
Through the PAM we can customize our the authentication methods.
For example: telnet spawns login. login will be having dependency on libpam.so. libpam.so reads the configuration file where we can define our customized authentication method(as a library) or we can use default linux authentication method.
similar to login for telnet, sshd will be having dependency on libpam.so.
To know the installed packages in linux:
Fedora:
#yum list installed
#rpm -qa
Ubuntun:
#dpkg --get-selections
Linux repositories are at:
#ls /etc/yum.repos.d/* OR
#cat /etc/yum.conf
Installing firefox in fedora:
http://www.if-not-true-then-false.com/2011/install-firefox-5-on-fedora/
To add new search plugin to firefox:
cp cisco.xml /usr/lib64/firefox/searchplugins/
Difference between zombie & orphan process
Tuesday, January 19, 2010
Memory Layout of a C Program
high --------------| |
| Arguments and || environment |
| variables |
| |
|---------------|| Stack |<--|--
|(grow downward)| |
| | |User
| | |Stack
| | |Frame
| | |
| (grow upward) | |( Mind the Gap )
| Heap |<--|--
|---------------|| BSS |<-- uninitialized static data(block started by symbol
|||| | | long sum[1000];
|| | |
|---------------|| Data |<-- initilized static data(int maxcount = 99)
|---------------|| Code |<-- text segment machine instructions lowStack : where automatic variables are stored, along with information that is
saved each time a function is called. Each time a function is called, the
address of where to return to and certain information about the caller's
environment, such as some of the machine registers, are saved on the stack. The
newly called function then allocates room on the stack for its automatic and
temporary variables. This is how recursive functions in C can work. Each time a
recursive function calls itself, a new stack frame is used, so one set of
variables doesn't interfere with the variables from another instance of the
function.
Text Segment: The text segment contains the actual code to be executed. It's
usually sharable, so multiple instances of a program can share the text segment
to lower memory requirements. This segment is usually marked read-only so a
program can't modify its own instructions.
Initialized Data Segment: This segment contains global variables which are
initialized by the programmer.
Uninitialized Data Segment: Also named "bss" (block started by symbol) which
was an operator used by an old assembler. This segment contains uninitialized
global variables. All variables in this segment are initialized to 0 or NULL
pointers before the program begins to execute.
The stack: The stack is a collection of stack frames which will be described in
the next section. When a new frame needs to be added (as a result of a newly
called function), the stack grows downward.
Every time a function is called, an area of memory is set aside, called a stack frame,
for the new function call. This area of memory holds some crucial information, like:
1. Storage space for all the automatic variables for the newly called function.
2. The line number of the calling function to return to when the called function
returns.
3. The arguments, or parameters, of the called function.
The heap: Most dynamic memory, whether requested via C's malloc() and friends
or C++'s new is doled out to the program from the heap. The C library also gets
dynamic memory for its own personal workspace from the heap as well. As more
memory is requested "on the fly", the heap grows upward.
Constants are stored in text segment since they are non-writeable. However u can make them to writeable by moving them to data segment. gcc provides this functionality
gcc -fwritable-strings sample.c // this will keep constants in data segment
References:
http://discussknowhow.blogspot.com/2008/08/memory-layout-of-c-program-stack-wise.html
Monday, December 28, 2009
C stuff
How to add non-printable characters to a string
strcat(test2,"\x01"); 01 -- is non-printable ascii character.
I will be updating the new stuff which come across in C language here, Hope it will be useful.
1. void perror(const char *s); --The perror() function shall map the error number accessed through the symbol errno to a language-dependent error message, which shall be written to the standard error stream
malloc(),calloc() and realloc():
void *malloc(size_t size): Returns unintialized memory of size "size", retuns "null" if memory is not available.
void *calloc(size_t nelem, size_t elsize): Returns intialized memory with 0 of nelem variables of size "elsize".
void *realloc(void *ptr, size_t size): changes the size of the object pointed to by ptr to the size specified by size, and returns a pointer to the possibly moved block. The contents are unchanged up to the lesser of the new and old sizes. If ptr is null,
Saturday, December 19, 2009
BSNL Broadband
GOTO DSL ROUTER SITE (http://192.168.1.1).. PASSWORD N LOGIN ID IS
"ADMIN"
AND CLICK ON ADVANCE SETUP THEN CLICK ON WAN ...
HERE U WILL SEE SOME VALUES (((VPI/VCI 0/35 Con. ID Category Service
Interface Protocol Igmp QoS State ))) AND ON 1ST OPTION {VPI/VCI 0/35}
TICK THE REMOVE OPTION AND REMOVE IT......THEN CLICK ON ADD OPTION AND CLICK NEXT NEXT AND LAST SAVE IT
....U HAVE TO DO NOTHING;;; DONT CHANGE ANYTHING VALUES THAT WILL COME ..ALL ARE PRE SET AND SO AFTER SAVE
CLICK ON SAVE/REBOOT.......
UR DONE .......... .....
THIS IS SOLUTION FOR PHONE
Not able to connect to the router 192.168.1.1 says page cannot be displayed
go to your local area connection's properties
in tcp/ip connections keep it to :use the following ip address" then in
ip address = 192.168.1.2
subnet mask = 255.255.255.0 (automatically it will take or else you type it)
default gateway = 192.168.1.1
PPPoE & Bridge mode:
PPPoE
(1) PPPoE modem is an always connected mode.(userid and password stored in modem)
(2) For getting good speed with torrents ports are required to be forwarded.
(3) For connecting multiple PCs modem must be in PPPoE mode.
(4) Telenet scripts are required for scheduled automatic booting and re booting.
(5) More secured.
Bridge mode
(1) Connects to net through dialer by entering userid and password
(2) No need of port forwarding for torrents as all ports are open
(3) Telenet scripts are not required for scheduled downloads.
(4) Strong firewalls required as as all ports r open.
Reference:
change from bridge mode to pppoe mode: http://www.chennai.bsnl.co.in/BBS/Wireless/WirelessSecurity.htm#WA3002_Modem_configuration:
http://www.indiabroadband.net/bsnl-broadband/10489-phone-line-busy-error-ut300r2u-modem-here-100-solution.html
http://www.indiabroadband.net/bsnl-broadband/15507-not-able-connect-router-192-168-1-1-says-page-cannot-displayed.html
http://www.indiabroadband.net/bsnl-broadband/8088-pppoe-bridge-mode.html
http://en.kioskea.net/forum/affich-91194-bsnl-wifi-iti-dna-a211-1