--ifconfig --配置网关和DNS

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  
=============

posted @ 2009-06-07 12:05  mop  阅读(15279)  评论(0编辑  收藏  举报