linux之IP配置

1.进入配置文件

vi /etc/network/interfaces
root@cubietruck-plus:~# vi /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo eth0
#allow-hotplug eth0
iface lo inet loopback  #将lo接口设置为一个本地回环(loopback)地址
#iface eth0 inet dhcp    #指出eth0接口自动获取IP
iface eth0 inet static    #指出eth0接口具有一个静态的(static)IP配置
	address 192.168.0.231
	mask 255.255.255.0
	gateway 192.168.0.1


#"your-ssid-here" and "your-passwd-here" should been replase with yours and remove the annotation

#auto wlan0
#iface wlan0 inet dhcp
#pre-up ip link set wlan0 up
#pre-up iwconfig wlan0 essid your-ssid-here
#wpa-ssid your-ssid-here
#wpa-psk your-passwd-here

2. auto 和auto-hotplug

auto

语法:
auto <interface_name>
含义:
在系统启动的时候启动网络接口,无论网络接口有无连接(插入网线),如果该接口配置了DHCP,则无论有无网线,系统都会去执行DHCP,如果没有插入网线,则等该接口超时后才会继续。

allow-hotplug

语法:
allow-hotplug <interface_name>

含义:
只有当内核从该接口检测到热插拔事件后才启动该接口。如果系统开机时该接口没有插入网线,则系统不会启动该接口,系统启动后,如果插入网线,系统会自动启动该接口。也就是将网络接口设置为热插拔模式。

3. 手动重新启动网络

一般修改了网络配置文件后,会用以下命令重新启动网络
/etc/init.d/networking restart

4.其他

`ifconfig eth0 down
#将网卡禁用命令

ifconfig eth0 up
#将网卡启用命令`

链接

链接:https://blog.csdn.net/mountzf/article/details/52035499

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值