Ubuntu13.04 sets static ip (whether notebook, desktop, virtual machine)

  
        

# Operating System: Ubuntu13.04

#

# Author: Sunny

#文章地址:http://blog.csdn.net/sunnypotter/article /details/22598201

# Set Static IP:

#

# Preparation:

# 1. View the network card, IP and subnet in use Mask netmask, mine is eth0

ifconfig

eth0 Link encap:Ethernet HWaddr ec:9a:74:36:c8:8c

inet addr:192.168.1.100 Bcast: 192.168.1.255 Mask: 255.255.255.0

# IP:192.168.1.100, netmask:255.255.255.0

# 2. View gateway gateway

route -n< Br>

Destination Gateway Genmask Flags Metric Ref Use Iface

0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth0

# gateway: 192.168.1.1

# dns: 192.168.1.1 # Normally and gateway, of course, you can also set other dns

# 3. Start setting static ip

sudo vim /etc/network/interfaces

*********

# interfaces(5) file used by ifup(8) and ifdown(8)

auto lo

iface Lo inet loopback

# Set Static IP

auto eth0 # My NIC

iface eth0 inet static # Static, as opposed to dynamic (dhcp, ie face eth0 inet dhcp)

address 192.168. 1.100 # You can set the available ip on the same network segment, such as 192.168.1.102

gateway 192.168.1.1 # gateway

netmask 255.255.255.0 #subnet mask

dns -nameservers 192.168.1.1 # Multiple dns can be set, or not set here, edit /etc/resolv.conf dns-nameservers 114.114.114.114

# 4, restart the network card

sudo service Networking restart

# or sudo /etc/init.d/networking restart

# Still not, please restart reboot

# Note:

# When dns-nameservers is not set, you need to manually add

in /etc/resolv.conf sudo vim /etc/resolv.cof

nameserver 192.168.1.1

# :

In a relatively early version, you need to set the resolv.conf file in /etc and add nameserver so that you can connect to the Internet, otherwise you can only access it via ip and cannot resolve the URL. (nslookup Can view the URL ip, of course, you must You must have dns first.

After Ubuntu 12.04, this method is no longer recommended, because whatever value you want to set in the configuration file will be restored to the initial state after restarting. (Of course does not include the boot startup script automatically set)

The recommended practice is to add dns-nameservers <gateway ip> directly to the interfaces configuration file.

Copyright © Windows knowledge All Rights Reserved