1.获取网卡名称
在命令行输入ifconfig -a

2.修改网卡配置文件
sudo vim /etc/network/interfaces
加上下面的配置,IP地址可以成适合你的
auto eth0 # eth0 替换成之前获取的网卡名称
iface eth0 inet static
address 192.168.8.160 # 静态IP
netmask 255.255.255.0
gateway 192.168.8.2

3.修改DNS配置
$ sudo vim /etc/resolvconf/resolv.conf.d/head

4.重启网络服务
$ sudo /etc/init.d/networking restart
到此为止就设置好静态IP了.
附:如果你的CRT连接报错The remote system refused the connection.
可能是没有安装ssh 服务,输入下面命令即可
$ sudo apt-get install openssh-server
本文详细介绍了在Linux系统中如何通过编辑配置文件设置静态IP地址的过程,包括获取网卡名称、修改网卡配置、设置DNS及重启网络服务等步骤。
9819

被折叠的 条评论
为什么被折叠?



