首页 技术 正文
技术 2022年11月8日
0 收藏 997 点赞 2,013 浏览 1226 个字

在Linux系统中,通过编辑网络配置文件,设置系统IP地址,当然要在root权限下执行,具体步骤如下:

1、切换路径到/etc/sysconfig/network-scripts

[root@Compile network-scripts]# pwd
/etc/sysconfig/network-scripts

2、查看ifcfg-eth0文件属性,确保具有编辑权限

[root@Compile network-scripts]# ls -l ifcfg-eth0
-rw-r–r–. 1 root root 258 9月  24 18:05 ifcfg-eth0

3、编辑文件ifcfg-eth0,添加如下信息

ONBOOT=yes

BOOTPROTO=static

IPADDR=192.168.30.175

NETMASK=255.255.255.0

GATEWAY=192.168.30.1

命令如下:[root@Compile network-scripts]# vi ifcfg-eth0

DEVICE=eth0
TYPE=Ethernet
UUID=9d3f1462-d7ac-49fe-8b1b-d729866d3bc7
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
HWADDR=00:23:AE:A8:D7:1E
IPADDR=192.168.30.175
NETMASK=255.255.255.0
GATEWAY=192.168.30.1
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME=”System eth0″

4、重启网络服务

[root@Compile network-scripts]# /etc/init.d/network  restart
正在关闭接口 eth0: 设备状态:3 (断开连接)
                                                           [确定]
关闭环回接口:                                             [确定]
弹出环回接口:                                             [确定]
弹出界面 eth0: 活跃连接状态:激活的
活跃连接路径:/org/freedesktop/NetworkManager/ActiveConnection/2
                                                           [确定]

5、通过命令方式设置网络IP,可以立即生效

[root@Compile network-scripts]# ifconfig eth0 192.168.30.175 netmask 255.255.255.0

[root@Compile network-scripts]# route add default gateway 192.168.30.1

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,023
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,513
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,360
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,143
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,774
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,852