1. Trang chủ
  2. » Công Nghệ Thông Tin

Topic 8 Networking Fundamentals

10 6 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Nội dung

Triển khai một máy tính làm việc Linux với các tính năng về đồ họa, vi tính văn phòng,… Hệ thống vận hành: cài đặt, cấu hình, quản trị, xử lý sự cố,… Vận hành hệ điều hành Linux: cài đặt, cấu hình mạng, máy trong, sử dụng thành thạo các công cụ quản lý mạng, cấu hình nhân, DFS, lập kế hoạch cho việc lưu trữ và phục hồi dữ liệu, TCP IP , config device,… Liên kết cơ bản kỹ năng đến Internet: kết nối, email, bảo mật, DNS, Apache, SSH, NTP,…

Topic 8: Networking Fundamentals Fundamentals of internet protocols Basic networking configuration Basic network troubleshooting Configure Configure static routre 122 Phiên Bản Thử Nghiệm – Lưu Hành Nội Bộ Networking Fundamentals Các file cấu hình thơng dụng Xem, thay đổi tên máy hệ thống: [root@localhost ~]# hostnamectl set-hostname may1.nhhatnghe1.com Reboot máy đổi tên máy, kiểm tra lại [root@localhost ~]# reboot [root@may1 ~]# hostname may1.nhhatnghe1.com File /etc/hosts: phân giải tên sang IP, thường dùng cho phân giải nội 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.1.20 may1.nhatnghe1.com may1 192.168.1.120 may2.nhatnghe1.com may2 Kiểm tra phân giải tên cách ping [root@may1 ~]# ping may1.nhatnghe1.com PING may1.nhatnghe1.com (192.168.1.20) 56(84) bytes of data 64 bytes from may1.nhatnghe1.com (192.168.1.20): icmp_seq=1 ttl=64 time=4.41 ms 64 bytes from may1.nhatnghe1.com (192.168.1.20): icmp_seq=2 ttl=64 time=0.108 ms File /etc/resolv.conf : khai báo DNS server dùng cho phân giải tên [root@may1 ~]# vi /etc/resolv.conf # Generated by NetworkManager search nhatnghe1.com nameserver 8.8.8.8 search: danh sách domains cho việc lookup host-name, mặc dịnh khai báo local domain (tối đa khai báo domains tổng số ký tự 256 ký tự) nameserver: định DNS servers Cấu hình IP card mạng: 2.1- Xem thơng tin cấu hình IP card mạng: [root@may1 ~]# ifconfig ens33: flags=4163 mtu 1500 inet 192.168.9.101 netmask 255.255.255.0 broadcast 192.168.9.255 inet6 fe80::7db9:c784:687d:f764 prefixlen 64 scopeid 0x20 ether 00:0c:29:11:d8:b1 txqueuelen 1000 (Ethernet) RX packets 1677 bytes 248877 (243.0 KiB) RX errors dropped overruns frame TX packets 236 bytes 31927 (31.1 KiB) TX errors dropped overruns carrier collisions ens34: flags=4163 mtu 1500 inet 10.0.0.1 netmask 255.255.255.0 broadcast 10.0.0.255 inet6 fe80::c5e6:b531:68ec:5601 prefixlen 64 scopeid 0x20 ether 00:0c:29:11:d8:bb txqueuelen 1000 (Ethernet) RX packets 29 bytes 3311 (3.2 KiB) RX errors dropped overruns frame TX packets 126 bytes 26440 (25.8 KiB) TX errors dropped overruns carrier collisions lo: flags=73 mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10 loop txqueuelen (Local Loopback) RX packets 64 bytes 5664 (5.5 KiB) RX errors dropped overruns frame TX packets 64 bytes 5664 (5.5 KiB) TX errors dropped overruns carrier collisions virbr0: flags=4099 mtu 1500 inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255 ether 52:54:00:4d:e4:4d txqueuelen 1000 (Ethernet) RX packets bytes (0.0 B) RX errors dropped overruns frame TX packets bytes (0.0 B) TX errors dropped overruns carrier collisions Hay dùng lệnh ifconfig –a Nếu muốn xem thơng tin cấu hình card mạng thì: [root@may1 ~]# ifconfig ens33 ens33 Link encap:Ethernet HWaddr 00:0C:29:A0:1A:71 inet addr:192.168.1.20 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fea0:1a71/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:504 errors:0 dropped:0 overruns:0 frame:0 TX packets:316 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:56197 (54.8 KiB) TX bytes:36566 (35.7 KiB) Interrupt:19 Base address:0x2000 2.2- Thay đổi địa IP [root@may1 ~]# ifconfig ens34 172.16.0.1 netmask 255.255.255.0 Việc thay đổi lệnh tạm thời không lưu lại khởi động lại hệ thống Kiểm tra IP: [root@may1 ~]# ifconfig ens34 ens34: flags=4163 mtu 1500 124 Phiên Bản Thử Nghiệm – Lưu Hành Nội Bộ inet 172.16.0.1 netmask 255.255.255.0 broadcast 172.16.0.255 inet6 fe80::c5e6:b531:68ec:5601 prefixlen 64 scopeid 0x20 ether 00:0c:29:11:d8:bb txqueuelen 1000 (Ethernet) RX packets 44 bytes 4938 (4.8 KiB) RX errors dropped overruns frame TX packets 157 bytes 34637 (33.8 KiB) TX errors dropped overruns carrier collisions Restart lại service network sau: [root@may1 ~]# systemctl restart network Shutting down interface eth0: Device state: (disconnected) [ OK ] Shutting down interface eth1: Device state: (disconnected) [ OK ] Shutting down loopback interface: [ OK ] Bringing up loopback interface: [ OK ] Bringing up interface eth0: Active connection state: activated Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/2 [ OK ] Bringing up interface eth1: Active connection state: activated Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/3 [ OK ] Kiểm tra lại IP: [root@may1 ~]# ifconfig ens34 ens34: flags=4163 mtu 1500 inet 10.0.0.1 netmask 255.255.255.0 broadcast 10.0.0.255 inet6 fe80::c5e6:b531:68ec:5601 prefixlen 64 scopeid 0x20 ether 00:0c:29:11:d8:bb txqueuelen 1000 (Ethernet) RX packets 58 bytes 6472 (6.3 KiB) RX errors dropped overruns frame TX packets 201 bytes 43034 (42.0 KiB) TX errors dropped overruns carrier collisions Để lưu lại việc thay đổi địa IP sau restart lại hệ thống, ta sửa trực tiếp file sau: [root@may1 ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens34 DEVICE= ens34 NM_CONTROLLED=yes ONBOOT=yes IPADDR=172.16.0.1 BOOTPROTO=none NETMASK=255.255.255.0 TYPE=Ethernet IPV6INIT=no USERCTL=no HWADDR=00:0c:29:11:d8:bb Restart lại service network sau: # systemctl restart network Kiểm tra lại IP: [root@may1 ~]# ifconfig ens34 ens34: flags=4163 mtu 1500 inet 172.16.0.1 netmask 255.255.255.0 broadcast 172.16.0.255 inet6 fe80::c5e6:b531:68ec:5601 prefixlen 64 scopeid 0x20 ether 00:0c:29:11:d8:bb txqueuelen 1000 (Ethernet) RX packets 44 bytes 4938 (4.8 KiB) RX errors dropped overruns frame TX packets 157 bytes 34637 (33.8 KiB) TX errors dropped overruns carrier collisions 2.3- Tạo IP Alias cho card mạng + Gán thêm ip cho ens34 [root@may1 ~]# cd /etc/sysconfig/network-scripts/ [root@may1 network-scripts]# vi ifcfg- ens34 TYPE=Ethernet PROXY_METHOD=none BROWSER_ONLY=no BOOTPROTO=none DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_FAILURE_FATAL=no IPV6_ADDR_GEN_MODE=stable-privacy NAME=ens34 UUID=7a1cdbb3-7651-4225-80e1-17c34167fd11 DEVICE=ens34 ONBOOT=yes IPADDR=10.0.0.1 IPADDR2=10.0.0.2 IPADDR3=10.0.0.3 PREFIX=24 IPV6_PRIVACY=no # systemctl restart network Kiểm tra: [root@may1 ~]# ip addr 1: lo: mtu 65536 qdisc noqueue state UNKNOWN qlen link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever 126 Phiên Bản Thử Nghiệm – Lưu Hành Nội Bộ inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens33: mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 00:0c:29:11:d8:b1 brd ff:ff:ff:ff:ff:ff inet 192.168.9.101/24 brd 192.168.9.255 scope global ens33 valid_lft forever preferred_lft forever inet6 fe80::7db9:c784:687d:f764/64 scope link valid_lft forever preferred_lft forever 3: ens34: mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 00:0c:29:11:d8:bb brd ff:ff:ff:ff:ff:ff inet 10.0.0.1/24 brd 10.0.0.255 scope global ens34 valid_lft forever preferred_lft forever inet 10.0.0.2/8 brd 10.255.255.255 scope global ens34 valid_lft forever preferred_lft forever inet 10.0.0.3/8 brd 10.255.255.255 scope global secondary ens34 valid_lft forever preferred_lft forever inet6 fe80::c5e6:b531:68ec:5601/64 scope link valid_lft forever preferred_lft forever 4: virbr0: mtu 1500 qdisc noqueue state DOWN qlen 1000 link/ether 52:54:00:4d:e4:4d brd ff:ff:ff:ff:ff:ff inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0 valid_lft forever preferred_lft forever 5: virbr0-nic: mtu 1500 qdisc pfifo_fast master virbr0 state DOWN qlen 1000 link/ether 52:54:00:4d:e4:4d brd ff:ff:ff:ff:ff:ff + Tạo Alias cho ens34 [root@may1 ~]# cd /etc/sysconfig/network-scripts/ [root@may1 network-scripts]# cp ifcfg- ens34 ifcfg- ens34:0 #vi ifcfg- ens34:0 DEVICE= ens34:0 NM_CONTROLLED=yes ONBOOT=yes TYPE=Ethernet BOOTPROTO=none IPADDR=192.168.1.30 PREFIX=24 GATEWAY=192.168.1.1 DNS1=8.8.8.8 DEFROUTE=yes IPV4_FAILURE_FATAL=yes IPV6INIT=no UUID=5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03 USERCTL=no NETMASK=255.255.255.0 HWADDR=00:0C:29:A0:1A:71 # systemctl restart network #ifconfig | more Lệnh route - Xem routing table: [root@may1 ~]# route -n Kernel IP routing table Destination Gateway 172.16.0.0 0.0.0.0 192.168.1.0 0.0.0.0 0.0.0.0 192.168.1.1 Genmask Flags Metric Ref 255.255.255.0 U 255.255.255.0 U 0.0.0.0 UG 0 Use Iface eth1 eth0 eth0 - Thêm default gateway: [root@may1 ~]# route add default gw 172.16.0.200 - Kiểm tra lại routing table: [root@may1 ~]# route -n Kernel IP routing table Destination Gateway 172.16.0.0 0.0.0.0 192.168.1.0 0.0.0.0 0.0.0.0 172.16.0.200 0.0.0.0 192.168.1.1 Genmask Flags Metric Ref 255.255.255.0 U 255.255.255.0 U 0.0.0.0 UG 0 0.0.0.0 UG 0 Use Iface eth1 eth0 eth1 eth0 - Xoá default route: [root@may1 ~]# route del default gw 172.16.0.200 - Kiểm tra lại routing table: [root@may1 ~]# route -n Kernel IP rou ing table Destination Gateway 172.16.0.0 0.0.0.0 192.168.1.0 0.0.0.0 0.0.0.0 192.168.1.1 Genmask Flags Metric Ref 255.255.255.0 U 255.255.255.0 U 0.0.0.0 UG 0 Use Iface eth1 eth0 eth0 Genmask Flags Metric Ref 255.255.255.0 U 255.255.255.0 U 0.0.0.0 UG 0 Use Iface eth1 eth0 eth0 Lệnh netstat -Xem routing table: [root@may1 ~]# route -n Kernel IP routing table Destination Gateway 172.16.0.0 0.0.0.0 192.168.1.0 0.0.0.0 0.0.0.0 192.168.1.1 - Kiểm tra port tcp mở: 128 Phiên Bản Thử Nghiệm – Lưu Hành Nội Bộ # netstat -ntlp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address name tcp6 0 :::389 :::* tcp6 0 :::80 :::* tcp6 0 :::22 :::* tcp6 0 ::1:631 :::* tcp6 0 ::1:953 :::* tcp6 0 ::1:25 :::* Foreign Address LISTEN LISTEN LISTEN LISTEN LISTEN LISTEN State PID/Program 2368/slapd 3191/httpd 955/sshd 3954/cupsd 4923/named 2324/master Kiểm tra port udp mở: # netstat -nulp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address name udp 0 192.168.1.101:53 udp 6144 0.0.0.0:53 udp 0 127.0.0.1:53 udp 0 0.0.0.0:123 udp 0 0.0.0.0:5353 udp 0 0.0.0.0:47420 udp 0 127.0.0.1:323 udp6 0 :::53 udp6 0 :::123 udp6 0 ::1:323 Foreign Address 0.0.0.0:* 0.0.0.0:* 0.0.0.0:* 0.0.0.0:* 0.0.0.0:* 0.0.0.0:* 0.0.0.0:* :::* :::* :::* State PID/Program 4923/named 4923/named 4923/named 653/chronyd 650/avahi-daemon: r 650/avahi-daemon: r 653/chronyd 4923/named 653/chronyd 653/chronyd tcp Các lệnh khác Lệnh tracepath lần dấu đường mạng tới đích định báo cáo nút mạng (hop) dọc đường Nếu gặp phải vấn đề mạng, lệnh tracepath vị trí lỗi mạng [root@may1 ~]# tracepath nhatnghe.com 1: may1.nhatnghe1.com (192.168.1.20) 1: 192.168.1.1 (192.168.1.1) 1: 192.168.1.1 (192.168.1.1) 2: 192.168.1.1 (192.168.1.1) 2: localhost (222.254.175.1) 3: 172.17.32.2 (172.17.32.2) 4: no reply 5: no reply 6: no reply 7: vdc.vn (123.29.16.18) 8: 118.69.241.130 (118.69.241.130) 9: no reply 10: no reply 4: vdc.vn (123.29.14.205) 4: vdc.vn (123.29.14.205) 0.718ms pmtu 1500 1.403ms 1.904ms 1.909ms pmtu 1492 51.176ms asymm 49.416ms 49.610ms 50.714ms asymm 10 19060.501ms asymm 19107.464ms asymm Lệnh traceroute: giúp ta biết đường gói tin đến đích phải qua địa Nó sử dụng TTL, cách gởi gói tin liên tục đích, gói tin đầu có thời gian TTL 1, gói tin có TTL 2, đến đích, lần tăng lên đơn vị [root@may1 ~]# traceroute nhatnghe.com traceroute to nhatnghe.com (118.69.197.152), 30 hops max, 60 byte packets 192.168.1.1 (192.168.1.1) 1.126 ms 1.039 ms 1.017 ms localhost (222.254.175.1) 27.717 ms 29.574 ms 31.840 ms 172.17.32.2 (172.17.32.2) 32.701 ms 33.911 ms 35.978 ms 4*** *** *** vdc.vn (123.29.16.18) 29.890 ms 24.382 ms 25.868 ms 118.69.250.210 (118.69.250.210) 28.920 ms 118.69.241.130 (118.69.241.130) 30.965 ms 32.985 ms *** 10 * * * Lệnh tcpdump: Capture packets [root@may1 ~]# tcpdump -n icmp -i eth0 tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes 23:07:17.074311 IP 192.168.1.2 > 192.168.1.1: ICMP echo request, id 1024, seq 40454, length 28 23:07:17.074765 IP 192.168.1.1 > 192.168.1.2: ICMP echo reply, id 1024, seq 40454, length 28 23:07:22.074052 IP 192.168.1.2 > 192.168.1.1: ICMP echo request, id 1024, seq 40710, length 28 23:07:22.074843 IP 192.168.1.1 > 192.168.1.2: ICMP echo reply, id 1024, seq 40710, length 28 23:07:27.074001 IP 192.168.1.2 > 192.168.1.1: ICMP echo request, id 1024, seq 40966, length 28 23:07:27.074724 IP 192.168.1.1 > 192.168.1.2: ICMP echo reply, id 1024, seq 40966, length 28 23:07:32.074022 IP 192.168.1.2 > 192.168.1.1: ICMP echo request, id 1024, seq 41222, length 28 [root@may1 ~]# tcpdump "dst 192.168.1.20 and src 192.168.1.1" [root@may1 ~]# tcpdump "host 192.168.1.20 and host 192.168.1.1" Tập tin /etc/services Khi xinetd khởi tạo truy cập đến tập tin /etc/services để tìm cổng tương ứng với dịch vụ - Quan sát tập tin /etc/services sau: [root@may1 ~]# vi /etc/services ………………………… # service-name port/protocol [aliases ] [# comment] tcpmux tcpmux rje rje echo echo discard discard 130 1/tcp 1/udp 5/tcp 5/udp 7/tcp 7/udp 9/tcp 9/udp # TCP port service multiplexer # TCP port service multiplexer # Remote Job Entry # Remote Job Entry sink null sink null Phiên Bản Thử Nghiệm – Lưu Hành Nội Bộ systat systat daytime daytime qotd qotd msp msp chargen chargen 11/tcp 11/udp 13/tcp 13/udp 17/tcp 17/udp 18/tcp 18/udp 19/tcp 19/udp users users quote quote # message send protocol (historic) # message send protocol (historic) ttytst source ttytst source Cấu trúc tập tin /etc/services gồm có cột: Cột 1: tên dịch vụ Cột 2: port/giao thức Cột 3: aliases (danh sách tên gọi khác dịch vụ) Cột 4: thích ... ms 33.911 ms 35.9 78 ms 4*** *** *** vdc.vn (123.29.16. 18) 29 .89 0 ms 24. 382 ms 25 .86 8 ms 1 18. 69.250.210 (1 18. 69.250.210) 28. 920 ms 1 18. 69.241.130 (1 18. 69.241.130) 30.965 ms 32. 985 ms *** 10 * *... 192.1 68. 1.1: ICMP echo request, id 1024, seq 40710, length 28 23:07:22.07 484 3 IP 192.1 68. 1.1 > 192.1 68. 1.2: ICMP echo reply, id 1024, seq 40710, length 28 23:07:27.074001 IP 192.1 68. 1.2 > 192.1 68. 1.1:... 192.1 68. 1.2 > 192.1 68. 1.1: ICMP echo request, id 1024, seq 40454, length 28 23:07:17.074765 IP 192.1 68. 1.1 > 192.1 68. 1.2: ICMP echo reply, id 1024, seq 40454, length 28 23:07:22.074052 IP 192.1 68. 1.2

Ngày đăng: 27/09/2022, 02:31

HÌNH ẢNH LIÊN QUAN

Nếu muốn xem thông tin cấu hình từng card mạng thì: - Topic 8 Networking Fundamentals
u muốn xem thông tin cấu hình từng card mạng thì: (Trang 3)

TÀI LIỆU CÙNG NGƯỜI DÙNG

  • Đang cập nhật ...

TÀI LIỆU LIÊN QUAN

w