Linux ifconfig eth0

 
ifconfig修改IP
2009年07月17日 07:12 来源:ChinaUnix博客 作者:白领乞丐 编辑:周荣茂

    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

    =============

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值