ubuntu 与 centOS 网卡配置修改

本文介绍了如何在Ubuntu和CentOS中配置静态IP地址,包括修改`/etc/network/interfaces`文件、设置DNS、重启网卡以使配置生效,以及处理配置过程中遇到的问题。对于Ubuntu,还涉及了配置多个IP和主机名称的设置。
摘要由CSDN通过智能技术生成

ubuntu网卡配置修改

转载  https://blog.csdn.net/mi2006/article/details/86620740

关键点一:为网卡配置静态IP地址
编辑文件/etc/network/interfaces,如果你不是以root用户登录请使用如下命令打开配置文件
sudo vi /etc/network/interfaces
配置文件内容如下:
auto eth0
iface eth0 inet static  // 若系统现在使用的动态ip,请将dhcp改为static;
address  210.168.3.90  // 配置本机的静态IP;
gateway 192.168.3.1    // 配置默认网关的网关;
netmask 255.255.255.0 // 配置子网掩码;
dns-nameservers 192.168.1.254 8.8.8.8 // 配置DNS
 #network 192.168.3.0   // 配置网络号,可以忽略;
#broadcast 192.168.3.255 // 配置网络地址,可以忽略;

           iface eth0 inet static
               address 192.168.1.3
               netmask 255.255.255.0
               gateway 192.168.1.1
               dns-nameservers 192.168.1.254 8.8.8.8
               dns-search foo.org bar.com

       N.B.:  On a machine where resolvconf has just been or is about to be installed and which
       previously relied on a static /etc/resolv.conf file, the nameserver information in  that
       static file should be migrated to the appropriate iface stanza(s) in interfaces(5)

用dns-nameservers设置DNS即可,然后用sudo resolvconf -u来更新,cat /etc/resolv.conf就能看到更改了。

关键点二:重启网卡是的刚刚设置的地址信息生效
sudo /etc/init.d/networking restart
在ubuntu 14.04中重启服务已经不能可用了,可行的方法是sudo ifdown em1 ; sudo ifup em1 执行两条命令来重启网卡。

关键点三:配置多

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值