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