博客
关于我
Linux网络——网络设置(DHCP原理及配置)
阅读量:704 次
发布时间:2019-03-17

本文共 1083 字,大约阅读时间需要 3 分钟。

Linux网络设置(DHCP原理及配置)

查看及测试网络

查看网络配置

在Linux系统中,ifconfig 是用于查看和配置网络接口的重要工具。它可以显示当前活动的网络接口信息,包括IP地址、子网掩码、广播地址等参数。例如:

ifconfig

查看指定网络接口信息

可以使用接口名称作为参数:

ifconfig ens33

查看路由表条目

route 命令用于查看主机的路由表信息,也可以用于添加或删除路由表条目。例如:

route -n

查看网络连接状态

netstat 命令用于查看当前网络连接状态、路由表和接口统计信息。使用选项可以查看不同的网络统计数据:

netstat [选项]

域名解析测试

使用 nslookup 命令可以测试域名解析,查看主机地址与DNS服务器的映射关系:

nslookup www.example.com

设置网络地址参数

临时配置

可以通过命令直接修改运行中的网络参数,如设置IP地址和子网掩码:

ifconfig ens33 192.168.1.100 netmask 255.255.255.0

固定配置

通过编辑配置文件来设置固定的网络参数,例如 /etc/-network/interfaces 文件。重启网络服务后配置才会生效:

systemctl restart network

路由配置

使用 route 命令添加或删除路由表条目,如添加默认网关:

route add default 192.168.1.254

启用或禁用网络接口

通过 ifup/down 控令启用或禁用网络接口:

ifup ens33ifdown ens33

DHCP配置

安装DHCP服务器

在Red Hat系 distributions上安装DHCP服务器:

yum -y install dhcp

配置文件修改

编辑DHCP配置文件 /etc/dhcp/dhcpd.conf,添加子网段和设置:

vim /etc/dhcp/dhcpd.conf

启动DHCP服务

启动并设置运行:

systemctl start dhcpdsystemctl enable dhcpd

configuring子网

在配置文件中添加子网段和IP池:

subnet 192.168.80.0 netmask 255.255.255.0 {    range 192.168.80.10 192.168.80.20;    option routers 192.168.80.254;}

通过上述设置,可以完成Linux网络的基本配置和DHCP服务器的配置。

转载地址:http://miphz.baihongyu.com/

你可能感兴趣的文章
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
NO 157 去掉禅道访问地址中的zentao
查看>>
no available service ‘default‘ found, please make sure registry config corre seata
查看>>
no connection could be made because the target machine actively refused it.问题解决
查看>>
No Datastore Session bound to thread, and configuration does not allow creation of non-transactional
查看>>
No fallbackFactory instance of type class com.ruoyi---SpringCloud Alibaba_若依微服务框架改造---工作笔记005
查看>>
No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalanc
查看>>
No mapping found for HTTP request with URI [/...] in DispatcherServlet with name ...的解决方法
查看>>
No mapping found for HTTP request with URI [/logout.do] in DispatcherServlet with name 'springmvc'
查看>>
No module named 'crispy_forms'等使用pycharm开发
查看>>
No module named cv2
查看>>
No module named tensorboard.main在安装tensorboardX的时候遇到的问题
查看>>
No module named ‘MySQLdb‘错误解决No module named ‘MySQLdb‘错误解决
查看>>
No new migrations found. Your system is up-to-date.
查看>>
No qualifying bean of type XXX found for dependency XXX.
查看>>
No resource identifier found for attribute 'srcCompat' in package的解决办法
查看>>
no session found for current thread
查看>>
No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android
查看>>
NO.23 ZenTaoPHP目录结构
查看>>
no1
查看>>