分享

ifconfig/route

 lifei_szdz 2012-12-14

ifconfig/route

 =================================DHCP自动分配IP================================

一般情况下,我们都是用dhcp自动获取IP,

/etc/init.d/networking restart  ----> 重启网络配置获取IP

invoke-rc.d networking restart  ----> 重启网络配置获取IP

或者安装dhcpcd,获取IP

root@Linux:/# dhcpcd

Usage: dhcpcd [options] <interface>

root@Linux:/# dhcpcd eth0

root@Linux:/# dhcpcd.sh: interface eth0 has been configured with new IP=192.168.1.112

 

 =================================手动指定IP================================

root@Linux:/# ifconfig eth0 192.168.1.108

 

Linux下设定了IP,还需绑定网关,

root@Linux:/# route add default gw 192.168.1.1    ---->> 切忌不是route add -host default gw 192.168.1.1

root@Linux:/# route

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

192.168.1.0     *               255.255.255.0   U     0      0        0 eth0

default         192.168.1.1     0.0.0.0         UG    0      0        0 eth0

使用这种方法添加的网关,在IP重设,网卡禁用/启用时,需重新设定.

ifconfig eth0 down

ifconfig eth0 up

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

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多