一、快速修改,重启后设置就没了
ifconfig eth0 192.168.1.22 netmask 255.255.255.0 up
route add default gw 192.168.1.2
二、修改配置文件,重启设置还在
(一)ubuntu 版本命令行设置IP
cat /etc/network/interfaces
# This filedescribes the networ k interfaces available onyour system
# and how toactivate them. For more information, seeinterfaces(5).
# The loopbacknetwork interface
auto lo
iface lo inetloopback
# The primarynetwork interface
auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
在/etc/resolv.conf添加
nameserver192.168.1.1
nameserver220.170.64.68
重启网卡:/etc/init.d/networking restart
更新:Ubuntu从17.10开始,