Linux Network Fundamentals

Source: Internet
Author: User

Seven-layer OSI and four-layer TCP/IP reference models:

  

Application layer: The highest level, provides the interface service between the network and the user should the software, such as HTTP,FTP,SMTP,POP3

Presentation layer: Responsible for data format transformation, encryption, compression, recovery, etc.

Session layer: Used to organize communication between two session processes

Transport Layer: Provides end-to-end service; tcp/udp

Network layer: Select the best path for grouping via subnet via routing algorithm

Data Link Layer:

Physical layer: The lowest level, using physical transport media to provide physical connectivity to the data link layer


Application layer:

Transport Layer:

Interconnect Layer:

Host-Network layer


IP Address: IPv4 mainstream

IPV6 Trends

Class A: 1.0.0.0-126.255.255.255

Class B: 128.0.0.0-191.255.255.255

Class C: 192.0.0.0-223.255.255.255

Special Address 10.0.0.0-10.255.255.255

127.0.0.1

172.16.0.0-172.31.255.255

192.168.0.0-192.168.255.255

          

[[email protected]/]# IPCALC-BMN 192.168.1.3/24 COMPUTE subnet mask, broadcast, and network number

netmask=255.255.255.0

broadcast=192.168.1.255

network=192.168.1.0


[[email protected]/]# route-n View routing information

Kernel IP Routing Table

Destination Gateway genmask Flags Metric Ref use Iface

192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0

172.16.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth1

169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0

169.254.0.0 0.0.0.0 255.255.0.0 U 1003 0 0 eth1

0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth0

Add a route, destination network segment; 211.220.1.0/24 all data is sent through the gateway 192.168.1.1 and passed through the eth0 NIC

[Email protected]/]# Route add-net 211.220.1.0 netmask 255.255.255.0 gw 192.168.1.1 Dev eth0

[Email protected]/]# route-n

Kernel IP Routing Table

Destination Gateway genmask Flags Metric Ref use Iface

192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0

211.220.1.0 192.168.1.1 255.255.255.0 UG 0 0 0 eth0

172.16.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth1

169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0

169.254.0.0 0.0.0.0 255.255.0.0 U 1003 0 0 eth1

0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth0


[Email protected]/]# Route del-net 211.220.1.0/24 GW 192.168.1.1 Dev eth0

Delete

[[email protected]/]# ifconfig-View Network Device interface information

Eth0 Link encap:ethernet HWaddr 00:0c:29:a0:9b:d5

inet addr:192.168.1.3 bcast:192.168.1.255 mask:255.255.255.0

Inet6 ADDR:FE80::20C:29FF:FEA0:9BD5/64 Scope:link

Up broadcast RUNNING multicast mtu:1500 metric:1

RX packets:27697 errors:0 dropped:0 overruns:0 frame:0

TX packets:8761 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:2020334 (1.9 MiB) TX bytes:2538083 (2.4 MiB)

Interrupt:19 Base address:0x2000


eth1 Link encap:ethernet HWaddr 00:0c:29:a0:9b:df

inet addr:172.16.100.1 bcast:172.16.255.255 mask:255.255.0.0

Inet6 ADDR:FE80::20C:29FF:FEA0:9BDF/64 Scope:link

Up broadcast RUNNING multicast mtu:1500 metric:1

RX packets:81 errors:0 dropped:0 overruns:0 frame:0

TX packets:18 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:15030 (14.6 KiB) TX bytes:1324 (1.2 KiB)

Interrupt:16 Base address:0x2080


Lo Link encap:local Loopback

inet addr:127.0.0.1 mask:255.0.0.0

Inet6 addr::: 1/128 scope:host

Up LOOPBACK RUNNING mtu:65536 metric:1

RX packets:1568 errors:0 dropped:0 overruns:0 frame:0

TX packets:1568 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:0

RX bytes:89656 (87.5 KiB) TX bytes:89656 (87.5 KiB)


Set up a sub-interface of a NIC and activate

[Email protected]/]# ifconfig eth0:0 192.168.1.4 netmask 255.255.255.0 up

[Email protected]/]# ifconfig-a

Eth0 Link encap:ethernet HWaddr 00:0c:29:a0:9b:d5

inet addr:192.168.1.3 bcast:192.168.1.255 mask:255.255.255.0

Inet6 ADDR:FE80::20C:29FF:FEA0:9BD5/64 Scope:link

Up broadcast RUNNING multicast mtu:1500 metric:1

RX packets:27971 errors:0 dropped:0 overruns:0 frame:0

TX packets:8892 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:2043236 (1.9 MiB) TX bytes:2550985 (2.4 MiB)

Interrupt:19 Base address:0x2000


eth0:0 Link encap:ethernet HWaddr 00:0c:29:a0:9b:d5

inet addr:192.168.1.4 bcast:192.168.1.255 mask:255.255.255.0

Up broadcast RUNNING multicast mtu:1500 metric:1

Interrupt:19 Base address:0x2000


You can set the network configuration with the Setup command:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/73/FB/wKioL1YLixbwd0PAAADcaa-xU7o156.jpg "style=" float: none; "title=" qq20150930151133.jpg "alt=" Wkiol1ylixbwd0paaadcaa-xu7o156.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/73/FB/wKioL1YLixfyC4HqAAEgufUAlU8295.jpg "style=" float: none; "title=" qq20150930151143.jpg "alt=" Wkiol1ylixfyc4hqaaegufualu8295.jpg "/>


To view the configuration file:

[Email protected]/]# cd/etc/sysconfig/network-scripts

[[email protected] network-scripts]# ls

Ifcfg-eth0 ifdown ifdown-ib ifdown-isdn ifdown-routes ifup ifup-eth Ifup-ipv6 ifup-plusb Ifup-rou TES ifup-wireless Network-functions

Ifcfg-eth1 IFDOWN-BNEP ifdown-ippp ifdown-post ifdown-sit ifup-aliases ifup-ib ifup-isdn ifup-post ifup-sit Init.ipv6-global Network-functions-ipv6

Ifcfg-lo ifdown-eth Ifdown-ipv6 ifdown-ppp ifdown-tunnel ifup-bnep ifup-ippp ifup-plip ifup-ppp Ifup-tun Nel net.hotplug


[[email protected] network-scripts]# cat Ifcfg-eth0 Nic 1

Device=eth0

Type=ethernet

Uuid=d1680cf6-689c-4126-9c78-635e28957da6

Onboot=yes

Nm_controlled=yes

Bootproto=none

Hwaddr=00:0c:29:a0:9b:d5

Defroute=yes

Peerroutes=yes

Ipv4_failure_fatal=yes

Ipv6init=yes

Name= "System eth0"

ipaddr=192.168.1.3

netmask=255.255.255.0

gateway=192.168.1.1

Userctl=no


[[email protected] network-scripts]# cat ifcfg-eth1 Nic 2

Ce=eth1

Type=ethernet

Onboot=yes

Nm_controlled=yes

Bootproto=none

Hwaddr=00:0c:29:a0:9b:df

Defroute=yes

Peerroutes=yes

Ipv4_failure_fatal=yes

Ipv6init=yes

Name= "System eth1"

ipaddr=172.16.100.1

netmask=255.255.0.0

Device=eth1

Userctl=no

[Email protected] network-scripts]#


Netstat: An explanation of usage

-A: Show all protocol and socket connection information

-N: Corresponding source IP and destination IP address

-L: Displays information being monitored

-T:TCP protocol

-U:UDP protocol

-P: Server name

[Email protected] network-scripts]# Netstat-antulp

Active Internet connections (servers and established)

Proto recv-q send-q Local address Foreign address State Pid/program Name

TCP 0 0 0.0.0.0:21 0.0.0.0:* LISTEN 1878/vsftpd

TCP 0 0 0.0.0.0:53 0.0.0.0:* LISTEN 1833/dnsmasq

TCP 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1855/sshd

TCP 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1632/cupsd

TCP 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2276/master

TCP 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 3687/sshd

TCP 0 0 0.0.0.0:50831 0.0.0.0:* LISTEN 1593/rpc.statd

TCP 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1469/rpcbind

TCP 0 192.168.1.3:22 192.168.1.2:4682 established 3687/sshd

TCP 0 0::: +:::* LISTEN 1833/DNSMASQ

TCP 0 0::: $:::* LISTEN 1855/sshd

TCP 0 0:: 1:631:::* LISTEN 1632/CUPSD

TCP 0 0::: 3128:::* LISTEN 2351/(squid)



Nslookup:domain name | IP Address


/etc/sysconfig/network: Used to set host name and whether the NIC is loaded when system starts

/etc/service: A network Service configuration file for converting the network service name to a port number/protocol;


Linux Network Fundamentals

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.