Linux下配置网卡信息

Linux下面配置网卡信息,可以直接使用ifconfig来进行配置,也可以在网卡配置文件中直接配置.
用ifconfig配置的信息退出后在下次登录时就不存在了,所以想要保存配置信息,需要将网卡信息配置到配置文件中。

1.ifconfig

查看网卡配置信息
ifconfig [eth0]

eth0 Link encap:Ethernet HWaddr 00:25:64:e5:bd:84
inet addr:192.168.0.4 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::225:64ff:fee5:bd84/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:110927 errors:0 dropped:0 overruns:0 frame:0
TX packets:105066 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:66939907 (66.9 MB) TX bytes:26789801 (26.7 MB)
Interrupt:27 Base address:0xa000

Link encap:连接类型(Ethernet) HWaddr:网卡地址
inet addr:ip地址 Bcast:广播地址 Mask:掩码
inet6 addr: ipv6地址
UP(网卡激活状态) BROADCAST(支持广播) RUNNING(网卡已连接) MULTICAST(支持组播) MTU:1500(最大传输单元1500字节)

配置网卡
ifconfig eth0 192.168.0.85 netmask 255.255.255.0 broadcast 192.168.0.255
为一个网卡配置多个ip地址,比如(eth0:0 eth0:1 eth0:2 eth0:3 eth0:4 eth0:5 ...).

激活与禁用网卡
ifconfig eth0 up 激活网卡 ifup eth0
ifconfig eth0 down 禁用网卡 ifdown eth0

2.配置文件(以Ubuntu为例)

vi /etc/network/interfaces

# The primary network interface
auto eth0
iface eth0 inet static # static为手工配置,dhcp为静态获取

address 192.168.0.2
netmask 255.255.255.0
gateway 192.168.0.1
#network 192.168.0.0
#broadcast 192.168.0.255

3.启动|停止服务
/etc/init.d/networking start|stop|restart

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值