#yyds干货盘点#网络配置

Posted 王华_linux

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了#yyds干货盘点#网络配置相关的知识,希望对你有一定的参考价值。

1.基本网络配置

将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
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port
udp UNCONN 0 0 *:670 *:*
udp UNCONN 0 0 127.0.0.1:914 *:*
udp UNCONN 0 0 *:111 *:*
udp UNCONN 0 0 *:34187 *:*
udp UNCONN 0 0 :::670 :::*
udp UNCONN 0 0 :::58121 :::*
udp UNCONN 0 0 :::111 :::*
tcp LISTEN 0 128 *:111 *:*
tcp LISTEN 0 128 *:22 *:*
tcp LISTEN 0 100 127.0.0.1:25 *:*
tcp LISTEN 0 128 *:54429 *:*
tcp LISTEN 0 128 :::111 :::*
tcp LISTEN 0 128 :::22 :::*
tcp LISTEN 0 100 ::1:25 :::*
tcp LISTEN 0 128 :::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 #yyds干货盘点# 网络高级配置和多网卡绑定实现

#yyds干货盘点#Ubuntu网络配置和故障排错工具详解

#yyds干货盘点#Linux网络管理命令

#yyds干货盘点# 在 VM 虚拟机中 Linux 动态网络配置

samba 配置参数#yyds干货盘点#

#yyds干货盘点#Linux常见面试题之网络通讯命令