1、用ifconfig、route、hostname
设置IP地址:
ifconfig eth0 192.168.0.95 netmask 255.255.255.0 up
设置默认网关:
route add default gw 192.168.0.1
说明:
eth0是第一个网卡,其他依次为eth1,eth*
192.168.0.95是给网卡配置的第一个网卡配置的ip地址
netmask 255.255.255.0 配置的是子网掩码
up是表示立即激活
临时修改主机名:
[root@localhost ~]# hostname gbicc
注意:通过这种方式的修改,可以立即生效,但网卡或机器重启后,又回到原来的设置了。
2、用netconfig图形化设置
netconfig调出图形化界面程序,按提示一步步操作。
但是,必须重启网卡后才能生效,永久改变。
网卡重启命令:
[root@localhost ~]#service network restart
3、通过修改网络相关参数文件
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.128.95
NETMASK=255.255.255.0
GATEWAY=192.168.128.254
[root@localhost ~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=localhost.localdomain
[root@localhost ~]# cat /etc/resolv.conf
nameserver 192.168.128.1
search localdomain
然后重启网卡或机器,永久生效。