Ubuntu的网络配置若干问

1、配置静态ip和网关

sudo vim /etc/network/interfaces

虚拟机的话,可以看到:

auto lo

iface lo inet loopback

现在我们要配置名为eth0的接口,加入以下代码

auto eth0
iface eth0 inet static  #这里把eth0接口设置为静态ip
address xxx.xxx.xxx.xxx  #这里设置eth0的静态ip
gateway yyy.yyy.yyy.yyy  #这里设置网关
netmask zzz.zzz.zzz.zzz  #这里设置子网掩码
dns-nameservers aaa.aaa.aaa.aaa #这里设置DNS服务器


关于auto eth0的解释:
 the word "auto" are used to identify the physical interfaces to be brought up when ifup is run with the -a option. (This option is used by the system boot scripts.) Physical interface names should follow the word "auto" on the same line.

意思就是auto关键字把我们指定名字的物理接口卡在 ifup -a 执行时”挂上去”。


配置完了之后,重启networking服务:sudo service networking restart

2、未完待续~


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值