Linux是一套免费使用和自由传播的类Unix操作系统,是一个基于POSIX和UNIX的多用户、多任务、支持多线程和多CPU的操作系统。它能运行主要的UNIX工具软件、应用程序和网络协议。
显示当前启动的网络接口命令,命令如下:
[root@iZ256w2hluuZ ~]# ifconfig
查看当前所有网络接口命令,命令如下:
[root@iZ256w2hluuZ ~]# ifconfig -a
查看指定网络接口命令,命令如下:
[root@iZ256w2hluuZ ~]# ifconfig eth0
在Linux系统下修改IP分为两种情况,具体如下:
1、调试时修改IP地址,仅在当前时刻生效,重启Linux之后恢复原有IP,命令如下:
ifconfig eth0 127.0.0.1 netmask 255.255.255.0 route add default gw 192.168.1.1 up
2、永久生效
方法一:配置网卡,修改配置文件,命令如下:
[root@iZ256w2hluuZ ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
将IP改为所需IP地址,之后重启服务,命令如下:
[root@iZ256w2hluuZ ~]# service network restart 或 [root@iZ256w2hluuZ ~]# /etc/init.d/network restart
方法二:
将ifconfig eth0 127.0.0.1 netmask 255.255.255.0 route add default gw 192.168.1.1 保存至/etc/init.d/rc.local文件中,重启Linux系统即可。