ubuntu14.04体验入门 配置IP地址

2014/05/1502:54:47 发表评论

             今天安装了ubuntu14.04 desktop版,桌面还是很炫的,现在我要把它变成我的工作机器,那么配置网络是首要任务了。好了,废话少说,下面开始配置。

              由于以前一直在centos,redhat中操作,所以对ubuntu的网络配置文件还不是很熟悉,那么先手动临时配置下IP地址可以上网再说吧。这个时候问题就开始来了,我要怎么切换到root用户下去呢,当我使用su root命令时,提示我输入用户名密码,但我确实不知道密码,输入我的默认普通用户密码,发现不行。试着改一下密码吧:sudo passwd myname。两次输入密码后再切换到root用户,居然可以了。原来ubuntu中是这样第一次修改root密码的。继续配置IP地址。

1、手动配置IP

ipconfig eth0 192.168.44.60 netmask 255.255.255.0

此时ping 下44网段其它地址,发现可以ping通,说明临时的IP地址配置好了。但这个时候还不能上网。

2、修改DNS

echo "nameserver 8.8.8.8" >>/etc/resolv.conf
echo "nameserver 8.8.4.4" >>/etc/resolv.conf

ping www.baidu.com 发现,还是不能通,因为这个时候没有配置网关。因为你的数据包没有通过你的IPS提供商转发数据到百度,当然就不能上网了。

3、配置临时网关

route add default gw 192.168.44.1

192.168.44.1是我们公司交换机的网关。

此时应该就可以上网了。

root@chenqin-desktop:/home/guozi# ping www.baidu.com
PING www.a.shifen.com (115.239.210.27) 56(84) bytes of data.
64 bytes from 115.239.210.27: icmp_seq=1 ttl=53 time=27.0 ms
64 bytes from 115.239.210.27: icmp_seq=2 ttl=53 time=28.3 ms
64 bytes from 115.239.210.27: icmp_seq=3 ttl=53 time=26.7 ms
64 bytes from 115.239.210.27: icmp_seq=4 ttl=53 time=29.3 ms
64 bytes from 115.239.210.27: icmp_seq=5 ttl=53 time=30.8 ms

4、配置静态地址

为什么要配置静态地址呢?因为当你再次重启机器时,你的临时IP都会被清空。所以我们修改配置文件:/etc/network/interfaces

修改内容如下:(如果你有多个网卡,那对应加就行了。)

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.44.61
netmask 255.255.255.0
gateway 192.168.44.1

#无线配置部分:
auto wlan0
iface wlan0 inet static
netmask 255.255.255.0
gateway 192.168.0.1
address 192.168.0.113
pre-up ip link set wlan0 up
pre-up iwconfig wlan0 essid ssid
wpa-ssid TP-Link # 这里的ssid为路由里设置的无线名称
wpa-psk 12345678 # 无线密码

5、配置动态获取地址

当你的网络环境中是动态获取地址的话,那么你需要将配置修改为动态获取,也很简单,命令为:

dhclient eth0

配置文件修改如下:

auto eth0
iface eth0 inet dhcp

 

  • 微信扫码赞助
  • weinxin
  • 支付宝赞助
  • weinxin

发表评论

您必须才能发表评论!