#yyds干货盘点#网络配置

笛里谁知壮士心,沙头空照征人骨。这篇文章主要讲述#yyds干货盘点#网络配置相关的知识,希望能为你提供帮助。
1.基本网络配置【#yyds干货盘点#网络配置】将Linux主机接入到网络,需要配置网络相关设置
一般包括如下内容:
  主机名
IP/netmask
  路由:默认网关    DNS服务器      主DNS服务器    次DNS服务器    第三个DNS服务器?
  CentOS 6 之前版本网卡名称
接口命名方式:CentOS 6
以太网:eth[0,1,2,...]
ppp:ppp[0,1,2,...]
网络接口识别并命名相关的udev配置文件:
/etc/udev/rules.d/70-persistent-net.rules
查看网卡:
dmesg |grep –i eth
ethtool -i eth0
卸载网卡驱动:
modprobe -r e1000
rmmod e1000
装载网卡驱动:
modprobe e1000
临时修改网卡名称

[root@centos6 ~]#ip link set eth0 down
[root@centos6 ~]#ip link set eth0 name abc
[root@centos6 ~]#ip link set abc up

2.网络配置命令  静态指定:
ifconfig, route, netstat
ip: object {link, addr, route}, ss, tc
system-config-network-tui,setup
配置文件
动态分配:DHCP: Dynamic Host Configuration Protocol
[root@c7-137-mariadb-bak ~]# cat /etc/resolv.conf
# Generated by NetworkManager

# No nameservers found; try putting DNS servers into your
# ifcfg files in /etc/sysconfig/network-scripts like so:
#
search wangxiaochun.com#自动补全后缀
# DNS2=xxx.xxx.xxx.xxx
# DOMAIN=lab.foo.com bar.foo.com
nameserver 10.0.0.2

#自动补全后缀
[root@c7-137-mariadb-bak ~]# ping www
PING www.wangxiaochun.com (123.56.174.200) 56(84) bytes of data.
64 bytes from 123.56.174.200: icmp_seq=1 ttl=128 time=45.2 ms
64 bytes from 123.56.174.200: icmp_seq=2 ttl=128 time=45.1 ms
64 bytes from 123.56.174.200: icmp_seq=3 ttl=128 time=45.2 ms
^C

判断是否是自动获取的IP
[root@c7-147 ~]# ss -ntlu
NetidStateRecv-Q Send-QLocal Address:PortPeer Address:Port
udpUNCONN00*:670*:*
udpUNCONN00127.0.0.1:914*:*
udpUNCONN00*:111*:*
udpUNCONN00*:34187*:*
udpUNCONN00:::670:::*
udpUNCONN00:::58121:::*
udpUNCONN00:::111:::*
tcpLISTEN0128*:111*:*
tcpLISTEN0128*:22*:*
tcpLISTEN0100127.0.0.1:25*:*
tcpLISTEN0128*:54429*:*
tcpLISTEN0128:::111:::*
tcpLISTEN0128:::22:::*
tcpLISTEN0100::1:25:::*
tcpLISTEN0128:::42277:::*
[root@c7-147 ~]# ss -ntlu |grep 68 #是否有68号开启

3.ifconfig命令来自于net-tools包,建议使用  ip 代替
[root@c7-147 ~]# rpm -qi net-tools
Name: net-tools
Version: 2.0
Release: 0.25.20131004git.el7
Architecture: x86_64
Install Date: Wed 08 Sep 2021 08:43:13 PM CST
Group: System Environment/Base
Size: 938978
License: GPLv2+
Signature: RSA/SHA256, Fri 23 Aug 2019 05:36:04 AM CST, Key ID 24c6a8a7f4a80eb5
Source RPM: net-tools-2.0-0.25.20131004git.el7.src.rpm
Build Date: Fri 09 Aug 2019 09:10:26 AM CST
Build Host: x86-02.bsys.centos.org
Relocations : (not relocatable)
Packager: CentOS BuildSystem < http://bugs.centos.org>
Vendor: CentOS
URL: http://sourceforge.net/projects/net-tools/
Summary: Basic networking tools
Description :
The net-tools package contains basic networking tools,
including ifconfig, netstat, route, and others.
Most

    推荐阅读