Home Ubuntu命令行下设置IP
Post
Cancel

Ubuntu命令行下设置IP

本文介绍通过命令行设置IP、网关的方法。 首先通过ifconfig命令查看系统的网卡。 比如本文使用的网卡是eth1。 然后通过下面的命令设置IP和网关。

1
2
sudo ifconfig eth0 172.16.1.226 netmask 255.255.255.0
sudo route add default gw 172.16.1.1 eth0

重启网络服务:

1
sudo /etc/init.d/networking restart

查看路由情况:

1
route -n
This post is licensed under CC BY 4.0 by the author.