Chinaunix首页 | 论坛 | 博客
  • 博客访问: 20831
  • 博文数量: 21
  • 博客积分: 850
  • 博客等级: 准尉
  • 技术积分: 200
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-23 22:53
文章分类

全部博文(21)

文章存档

2010年(21)

我的朋友
最近访客

分类: LINUX

2010-03-26 20:40:09

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

阅读(338) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~