Wednesday 10 July 2013

MyLinuxNote2 [ Basic of Network layers ]

The Sever OSI layers:

1. Physical
2. Link
3. Network
4. Transport
5. Session
6. Presentation
7. Application

List of protocols OSI models:
IMP: http://en.wikipedia.org/wiki/List_of_network_protocols_%28OSI_model%29

Private IP Address:

10.0.0.0 - 10.255.255.255
172.16.0.0 - 172.31.255.255
192.168.0.0 - 192.168.255.255

-> Local host IP Address: 127.0.0.1 [ Also known as loopback IP address]


IP Class:

A-> 00000000 -> 01111111 ( 0 - 127 ) but as 127. is used for loopback its  ( 0 - 126 )
B -> 10000000 -> 10111111 (128 - 191)
C ->11000000 -> 11011111 (192 - 223)
D ->11100000 -> 11101111 (224 - 239)
E -> 11110000 -> 11110111 (240 - 247)


NOTE:

-> Go to network 10.0.0.0 255.0.0.0 via router R1
-> Go to everything else via Router R2
-> R2, therefor would be considered your default gateway.

man -k ssh
man ifconfig

ifconfig -a

*) # ifconfig eth0 10.0.0.1 netmask 255.255.255.0 up

[ To make this permanent each time you boot up, add this above command in "/etc/rc.local". ]

*) /etc/sysconfig/network-scripts/ifcfg-eth0

if static: -

DEVICE = eth0
IPADDR = 192.168.1.100
NETMASK = 255.255.255.0
BOOTPROTO = static
ONBOOT = yes

if dhcp: -

DEVICE = eth0
BOOTPROTO = dhcp
ONBOOT = yes

*) ifdown eth0
*) ifup eth0

*) Assigning more then 1 IP to an interface:

ifconfig eth0:0 192.168.1.99 netmask 255.255.255.0 up
(or)
vi /etc/sysconfig/network-scripts/ifconfig-eth0:0

*) For range of ipaddress:-

*) netstat -nr [ Current routing table ]
*) route
*) Network with a gateway 0.0.0.0 are usually directly connected to the interface.
*) The router with a destination address of 0.0.0.0 is your default gateway.

*) # route add default gw 192.168.1.1 eth0

*) # vi /etc/sysconfig/network
NETWORKING = yes
HOSTNAME = amit
GATEWAY = 192.168.1.1


*) Configuring two gateways: - ( scenario)

S1. You have one router providing access to the internet that you would like to have a default gateway:

# route add default gw 192.168.1.1 eth0

S2. You have another router providing access to your corporate network using addresses range 10.0.0.0 to 10.255.255.255 . Let's assume that this router has an IP address of 192.168.1.254

# route add -net 10.0.0.0 netmask 255.0.0.0 gw 192.168.1.254 eth0

S3. If only for an individual server, then: -

# route add -host 10.0.0.1 gw 192.168.1.254 eth0

*) man route

*) for keeping the settings: ( add the commands in "/etc/rc.d/rc.local" )


Adding permanent static routs:

vi /etc/sysconfig/network-scripts/route-eth0


10.0.0.0/8 via 192.168.1.254

# The filename need to be: - " route-interfaceName "

*) Test: -
. /etc/sysconfig/network-scripts/ifup-routes route-eth0
ifup-route [ which should adds the route ]

*) route del -net 10.0.0.0 netmask 255.0.0.0 gw 192.168.1.254 eth0


packet forwarding: -

-> /etc/sysctl.conf  : [ net.ipv4.ip_forward=1 ]
sysctl -p [ This command will reload the /etc/sysctl.conf file. ]


*) Some files and commands to look:

/etc/hosts
mii-tool eth0
ethtool eth0
netstat -i
arp -a
service iptables status
tracerouter -I <IP address>
tcpdump -i eth0 icmp
tcpdump -i eth0 -t host 192.168.1.102 and tcp port 22
nslookup <hostname/ipaddress> <dns server>
nmap -sT -T 5 -P 1-5000 192.168.1.153
nc -l 7777
nc <ServerIP> <server tcp port>  -> nc 127.0.0.1 7777
last
who
whoami
tail -f /var/log/messages > /dev/tty9



No comments:

Post a Comment