Chinaunix
标题:
ifconfig修改IP
[打印本页]
作者:
白领乞丐
时间:
2009-07-17 15:12
标题:
ifconfig修改IP
LINUX下只用打route就可以看到网关了(必须是root用户):
[root@oracle11g ~]# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.232.0 * 255.255.255.0 U 0 0 0 eth0
169.254.0.0 * 255.255.0.0 U 0 0 0 eth0
default
192.168.232.1
0.0.0.0 UG 0 0 0 eth0
[root@oracle11g ~]#
===========================================
netstat -nr也可以看:
[root@oracle11g ~]# netstat -nr
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
192.168.232.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
0.0.0.0
192.168.232.1
0.0.0.0 UG 0 0 0 eth0
[root@oracle11g ~]#
============================================
打开New Terminal,进入命令行进行设置:
ifconfig eth0 192.168.10.50 netmask 255.255.255.0
============================================
[root@oracle11g ~]# ifconfig eth0 192.168.232.135 netmask 255.255.255.0
[root@oracle11g ~]#
============================================
route add default gw 192.168.1.1
============================================
[root@oracle11g ~]# route add default gw 192.168.232.1
SIOCADDRT: File exists
[root@oracle11g ~]#
============================================
这时我的电脑能通过网关访问外部internet但是据说以上的设置只是存放在内存中,所以每次重启的时候又要再来一遍。
=============
1、可以把它放在/etc/rc.d/init.d/rc.local文件中
ifconfig eth0 192.168.10.50 netmask 255.255.0.0
route add default gw 192.168.1.1
2、配置网卡的配置文件
创建或修改此文件/etc/sysconfig/network-scripts/ifcfg-eth0#ifcfg-eth0
DEVICE=eth0
BOOTPROTO=static
BROADCAST=192.168.10.255
IPADDR=192.168.10.50
NETMASK=255.255.255.0
NETWORK=192.168.10.0
ONBOOT=yes
TYPE=Ethernet
USERCTL=no
PEERDNS=no
GATEWAY=
##Add to tail of /etc/sysconfig/static-routes
eth0 192.168.1.1
=============
本文来自ChinaUnix博客,如果查看原文请点:
http://blog.chinaunix.net/u1/39492/showart_1999220.html
作者:
su_kiki
时间:
2011-04-06 16:20
提示:
作者被禁止或删除 内容自动屏蔽
作者:
beyondfly
时间:
2011-04-26 16:28
[root@oracle11g ~]# ifconfig eth0 192.168.232.135 netmask 255.255.255.0
[root@oracle11g ~]#
============================================
route add default gw 192.168.1.1
============================================
[root@oracle11g ~]# route add default gw 192.168.232.1
SIOCADDRT: File exists
[root@oracle11g ~]#
切记,这种方法修改的IP地址,重启完,就丢失了
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2