Linux Network Configuration Miscellaneous

Source: Internet
Author: User

11.211.2.1 ifcfg View Linux Routing entries
[[email protected] ~]# route -nKernel IP routing tableDestination     Gateway         Genmask         Flags Metric Ref    Use Iface10.201.106.0    0.0.0.0         255.255.255.0   U     0      0        0 eth00.0.0.0         10.201.106.2    0.0.0.0         UG    0      0        0 eth0
View system Activity Status Network interface information
[[email protected] ~]# ifconfigens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500        inet 10.201.106.130  netmask 255.255.255.0  broadcast 10.201.106.255        inet6 fe80::20c:29ff:fea7:7aec  prefixlen 64  scopeid 0x20<link>        ether 00:0c:29:a7:7a:ec  txqueuelen 1000  (Ethernet)        RX packets 15514  bytes 17988974 (17.1 MiB)        RX errors 0  dropped 0  overruns 0  frame 0        TX packets 5902  bytes 1004507 (980.9 KiB)        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536        inet 127.0.0.1  netmask 255.0.0.0        inet6 ::1  prefixlen 128  scopeid 0x10
Show all active and inactive interface information
[[email protected] ~]# ifconfig-aeth0 Link encap:ethernet HWaddr 00:0c:29:da:5a:22 inet addr:10.201  .106.129 bcast:10.201.106.255 mask:255.255.255.0 inet6 addr:fe80::20c:29ff:feda:5a22/64 scope:link up          Broadcast RUNNING multicast mtu:1500 metric:1 RX packets:14676 errors:0 dropped:0 overruns:0 frame:0 TX packets:10293 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:9260953  (8.8 MiB) TX bytes:1450866 (1.3 MiB) interrupt:19 Base address:0x2000 lo Link encap:local Loopback inet A          ddr:127.0.0.1 mask:255.0.0.0 Inet6 Addr::: 1/128 scope:host up LOOPBACK RUNNING mtu:65536 metric:1          RX packets:10 errors:0 dropped:0 overruns:0 frame:0           TX packets:10 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:568 (568.0 b) TX bytes:568 (568.0 b) pan0 Link encap:ethernet HWaddr 52:2c:94:69:6e:69 Inet6 addr:fe80::502c:94ff:fe69:6e69/64 scope:link up broadcast RUNNING multicast mtu:15          XX metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0           TX packets:592 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0  (0.0 b) TX bytes:200880 (196.1 KiB)
Display specified interface information
[[email protected] ~]# ifconfig eth0eth0      Link encap:Ethernet  HWaddr 00:0C:29:DA:5A:22            inet addr:10.201.106.129  Bcast:10.201.106.255  Mask:255.255.255.0          inet6 addr: fe80::20c:29ff:feda:5a22/64 Scope:Link          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1          RX packets:14707 errors:0 dropped:0 overruns:0 frame:0          TX packets:10322 errors:0 dropped:0 overruns:0 carrier:0          collisions:0 txqueuelen:1000           RX bytes:9263637 (8.8 MiB)  TX bytes:1454632 (1.3 MiB)          
Configure the eth0 address and mask and start
[[email protected] ~]# ifconfig eth0 10.201.106.129/24 up[[email protected] ~]# [[email protected] ~]# ifconfig eth0 10.201.106.129 netmask 255.255.255.0 up #第二种方法[[email protected] ~]# ifconfig eth0eth0      Link encap:Ethernet  HWaddr 00:0C:29:DA:5A:22            inet addr:10.201.106.129  Bcast:10.201.106.255  Mask:255.255.255.0          inet6 addr: fe80::20c:29ff:feda:5a22/64 Scope:Link          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1          RX packets:15000 errors:0 dropped:0 overruns:0 frame:0          TX packets:10544 errors:0 dropped:0 overruns:0 carrier:0          collisions:0 txqueuelen:1000           RX bytes:9290103 (8.8 MiB)  TX bytes:1479528 (1.4 MiB)          
No inverse display of routing table information
[[email protected] ~]# route -nKernel IP routing tableDestination     Gateway         Genmask         Flags Metric Ref    Use Iface10.201.106.0    0.0.0.0         255.255.255.0   U     0      0        0 eth00.0.0.0         10.201.106.2    0.0.0.0         UG    0      0        0 eth0
Adds a host route and specifies that the send from eth0
[[email protected] ~]# route add -host 192.168.1.3 gw 10.201.106.2 dev eth0[[email protected] ~]# route -nKernel IP routing table                  # Flags:条目标志位 U:启用状态,G:表示网关 H:主机路由Destination     Gateway         Genmask         Flags Metric Ref    Use Iface192.168.1.3     10.201.106.2    255.255.255.255 UGH   0      0        0 eth010.201.106.0    0.0.0.0         255.255.255.0   U     0      0        0 eth00.0.0.0         10.201.106.2    0.0.0.0         UG    0      0        0 eth0第二种方法[[email protected] ~]# route add default ge 10.201.106.2
Add Network Segment Routing
[[email protected] ~]# route add -net 192.168.0.0 netmask 255.255.255.0 gw 10.201.106.2 dev eth0[[email protected] ~]# route -nKernel IP routing tableDestination     Gateway         Genmask         Flags Metric Ref    Use Iface192.168.1.3     10.201.106.2    255.255.255.255 UGH   0      0        0 eth010.201.106.0    0.0.0.0         255.255.255.0   U     0      0        0 eth0192.168.0.0     10.201.106.2    255.255.255.0   UG    0      0        0 eth00.0.0.0         10.201.106.2    0.0.0.0         UG    0      0        0 eth0
Add a default route
[[email protected] ~]# route add -net 0.0.0.0 netmask 0.0.0.0 gw 10.201.106.2 dev eth0SIOCADDRT: 文件已存在[[email protected] ~]# route -nKernel IP routing tableDestination     Gateway         Genmask         Flags Metric Ref    Use Iface192.168.1.3     10.201.106.2    255.255.255.255 UGH   0      0        0 eth010.201.106.0    0.0.0.0         255.255.255.0   U     0      0        0 eth0192.168.0.0     10.201.106.2    255.255.255.0   UG    0      0        0 eth00.0.0.0         10.201.106.2    0.0.0.0         UG    0      0        0 eth0
Removing host routes
[[email protected] ~]# route del -host 192.168.1.3/32  gw 10.201.106.2[[email protected] ~]# route -nKernel IP routing tableDestination     Gateway         Genmask         Flags Metric Ref    Use Iface10.201.106.0    0.0.0.0         255.255.255.0   U     0      0        0 eth0192.168.0.0     10.201.106.2    255.255.255.0   UG    0      0        0 eth00.0.0.0         10.201.106.2    0.0.0.0         UG    0      0        0 eth0
Delete a network segment route
[[email protected] ~]# route del -net 192.168.0.0 netmask 255.255.255.0[[email protected] ~]# route -nKernel IP routing tableDestination     Gateway         Genmask         Flags Metric Ref    Use Iface10.201.106.0    0.0.0.0         255.255.255.0   U     0      0        0 eth00.0.0.0         10.201.106.2    0.0.0.0         UG    0      0        0 eth0
11.2.2 DNS Modify system DNS address
[[email protected] ~]# vim /etc/resolv.conf ; generated by /sbin/dhclient-scriptsearch localdomainnameserver 10.201.106.2
Domain Name resolution
[[email protected] ~]# dig -t A www.qq.com; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.30.rc1.el6 <<>> -t A www.qq.com;; global options: +cmd;; Got answer:;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 12877;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0;; QUESTION SECTION:;www.qq.com.            IN  A;; ANSWER SECTION:www.qq.com.     5   IN  A   120.198.201.156;; Query time: 25 msec;; SERVER: 10.201.106.2#53(10.201.106.2);; WHEN: Wed Jul 20 18:19:45 2016;; MSG SIZE  rcvd: 44
Reverse parsing
[[email protected] ~]# dig -x 120.198.201.156
The host command forward and reverse parse
[[email protected] ~]# host -t A www.qq.comwww.qq.com has address 120.198.201.156[[email protected] ~]# [[email protected] ~]# host -t PTR 120.192.201.156Host 156.201.192.120.in-addr.arpa. not found: 3(NXDOMAIN)
11.2.3 netstat only shows TCP or UDP
[[email protected] ~]# netstat -tActive Internet connections (w/o servers)Proto Recv-Q Send-Q Local Address               Foreign Address             State      tcp        0      0 10.201.106.129:ssh          10.201.106.1:55907          ESTABLISHED tcp        0     52 10.201.106.129:ssh          10.201.106.1:56655          ESTABLISHED [[email protected] ~]# [[email protected] ~]# netstat -uActive Internet connections (w/o servers)Proto Recv-Q Send-Q Local Address               Foreign Address             State     
Do not do port reverse solution
[[email protected] ~]# netstat -tnActive Internet connections (w/o servers)Proto Recv-Q Send-Q Local Address               Foreign Address             State      tcp        0      0 10.201.106.129:22           10.201.106.1:55907          ESTABLISHED tcp        0     52 10.201.106.129:22           10.201.106.1:56655          
Displays all connections, including the monitored
[[email protected] ~]# netstat-tanactive Internet connections (servers and established) Proto recv-q send-q Local Add                   Ress Foreign Address State TCP 0 0 0.0.0.0:21 0.0.0.0:*        LISTEN TCP 0 0 0.0.0.0:22 0.0.0.0:* LISTEN TCP                0 0 127.0.0.1:631 0.0.0.0:* LISTEN TCP 0 0 127.0.0.1:25 0.0.0.0:* LISTEN TCP 0 0 10.201.106.129:22 10.201.106.1:55907 ES tablished TCP 0 10.201.106.129:22 10.201.106.1:56655 established TCP 0 0::: 2                        2:::* LISTEN TCP 0 0:: 1:631:::*        LISTEN TCP 0 0:: 1:25:::* LISTEN TCP   0 0::: 80                    :::* LISTEN   
Show only the Listening connections
[[email protected] ~]# netstat -tnlActive Internet connections (only servers)Proto Recv-Q Send-Q Local Address               Foreign Address tcp        0      0 0.0.0.0:21                  0.0.0.0:*       tcp        0      0 0.0.0.0:22                  0.0.0.0:*       tcp        0      0 127.0.0.1:631               0.0.0.0:*       tcp        0      0 127.0.0.1:25                0.0.0.0:*       tcp        0      0 :::22                       :::*            tcp        0      0 ::1:631                     :::*            tcp        0      0 ::1:25                      :::*            tcp        0      0 :::80                       :::*     
Show Extended Properties
[[email protected] ~]# netstat -tnleActive Internet connections (only servers)Proto Recv-Q Send-Q Local Address               Foreign Address tcp        0      0 0.0.0.0:21                  0.0.0.0:*       tcp        0      0 0.0.0.0:22                  0.0.0.0:*       tcp        0      0 127.0.0.1:631               0.0.0.0:*       tcp        0      0 127.0.0.1:25                0.0.0.0:*       tcp        0      0 :::22                       :::*            tcp        0      0 ::1:631                     :::*            tcp        0      0 ::1:25                      :::*            tcp        0      
Displays the process and PID to which the connection belongs through the-p parameter
[[email protected] ~]# netstat-tnlpactive Internet connections (only servers) 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 1438/vsftpd TCP 0 0 0.0.0.0:22 0.0.0.0:*       LISTEN 1425/sshd TCP 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1253/CUPSD TCP 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1550/mas ter TCP 0 0::: +:::* LISTEN 1425/sshd TC      P 0 0:: 1:631:::* LISTEN 1253/cupsd TCP 0                       0:: 1:25:::* LISTEN 1550/master TCP 0 0::: 80  :::*                      LISTEN 20471/httpd   
View the routing table
[[email protected] ~]# netstat -rnKernel IP routing tableDestination     Gateway         Genmask         Flags   MSS Window  irtt Iface10.201.106.0    0.0.0.0         255.255.255.0   U         0 0          0 eth00.0.0.0         10.201.106.2    0.0.0.0         UG        0 0          0 eth0
Display interface Statistics
[[email protected] ~]# netstat -Ieth0    #通过I选项指定接口统计信息Kernel Interface tableIface       MTU Met    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flgeth0       1500   0    18050      0      0      0    13229      0      0      0 BMRU[[email protected] ~]# netstat -i          #显示所有接口统计信息Kernel Interface tableIface       MTU Met    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flgeth0       1500   0    18064      0      0      0    13239      0      0      0 BMRUlo        65536   0       10      0      0      0       10      0      0      0 LRUpan0       1500   0        0      0      0      0      871      0      0      0 BMRU

Linux Network Configuration Miscellaneous

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.