Ubuntu12.04配置静态IP

初级驱动第一天

Ubuntu12.04配置静态ip

  1. 使用ifconfig查看网卡名称
eth0      Link encap:Ethernet  HWaddr 00:0c:29:28:be:0f  
          inet addr:192.168.30.54  Bcast:192.168.30.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe28:be0f/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:12729336 errors:6827 dropped:7354 overruns:0 frame:0
          TX packets:7217209 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1464520312 (1.4 GB)  TX bytes:2296991300 (2.2 GB)
          Interrupt:19 Base address:0x2000 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:4126 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4126 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:400935 (400.9 KB)  TX bytes:400935 (400.9 KB)
          

eth0为网卡名;

  1. 第二步
sudo vim /etc/network/interfaces

修改为如下:

auto lo
iface lo inet loopback

auto eth0					//网卡
iface eth0 inet static		//静态
address 192.168.30.54		//ip
netmask 255.255.255.0       //子网掩码
gateway 192.168.30.1		//网关

  1. 第三步
    配置dns:
    搜索当地dns然后写入配置文件
sudo vim /etc/resolvconf/resolv.conf.d/base 

写入dns如下

nameserver 202.96.128.86
nameserver 8.8.8.8
  1. 第四步
    初始化dns和网络:
sudo /etc/init.d/networking restart

 * Running /etc/init.d/networking restart is deprecated because it may not enable again some interfaces
 * Reconfiguring network interfaces...                                          ssh stop/waiting
ssh start/running, process 13029
                                                                         [ OK ]
zzw@ubuntu-stu:/mnt/hgfs/ubuntu&matebook$ 

 sudo /etc/init.d/resolvconf restart

Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service resolvconf restart

Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the stop(8) and then start(8) utilities,
e.g. stop resolvconf ; start resolvconf. The restart(8) utility is also available.
resolvconf stop/waiting
resolvconf start/running
zzw@ubuntu-stu:/mnt/hgfs/ubuntu&matebook$ 

5.================================== 配置完成==========================================

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值