admin管理员组

文章数量:1532165

2024年7月16日发(作者:)

/etc/network/interfaces

打开后里面可设置DHCP或手动设置静态ip。前面auto eth0,让网卡开机自动挂载.

1. 以DHCP方式配置网卡

编辑文件/etc/network/interfaces:

sudo vi /etc/network/interfaces

并用下面的行来替换有关eth0的行:

# The primary network interface - use DHCP to find our address

auto eth0

iface eth0 inet dhcp

用下面的命令使网络设置生效:

sudo /etc/init.d/networking restart

也可以在命令行下直接输入下面的命令来获取地址

sudo dhclient eth0

2. 为网卡配置静态IP地址

编辑文件/etc/network/interfaces:

sudo vi /etc/network/interfaces

并用下面的行来替换有关eth0的行:# The primary network interface

auto eth0

iface eth0 inet static

address 192.168.128.128

gateway 192.168.128.1

netmask 255.255.255.0

将上面的ip地址等信息换成你自己就可以了.用下面的命令使网络设置生效:

sudo /etc/init.d/networking restart

4. 设置主机名称(hostname)

使用下面的命令来查看当前主机的主机名称:

本文标签: 设置命令配置网卡网络