静态ip配置
终端输入: vim /etc/network/interfaces
编辑内容(这是整个文件的内容):
#The loopback network interface
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
#主机地址
address 10.1.5.190
#掩码
netmask 255.255.255.0
#网络号
network 10.1.5.1
#广播地址
broadcast 10.1.5.255
#网关地址
gateway 10.1.5.1
# dns-* options are implemented by the resolvconf package, if installed
#dns 地址
dns-nameservers 10.1.5.1
配置好后重启主机生效。
注意: etho 为网卡名称,各地址不懂的问网络管理员。
配置动态ip
终端输入: vim /etc/network/interfaces
编辑内容(这是整个文件的内容):
auto eth0
iface eth0 inet dhcp
#The loopback network interface
auto lo
iface lo inet loopback
dns-nameservers fun
最后一行配置是dns 的服务器地址,需要替换成自己的dns 主机名或ip地址。
零时配置
使用命令:
ifconfig 网卡名称(如 eth0) ip地址 #设置地址
ifconfig 网卡名称(如 eth0) network x.x.x.x #对子网掩码设置
广播地址和dns 使用默认的
配置后会立即生效,但是是临时的,重启会失效。
重启网卡
ifconfig eth0 up
#或
ifup eth0
卸载网卡
ifconfig eth0 down
#或
ifdown eth0