Permanently set the IP address of the Ubuntu

1. Review the current Ubuntu IP address is how many?
@ Ubuntu GEC: ~ $ ifconfig
lo Link encap: Local the Loopback -> currently only lo loopback IP, no Ethernet card, you need to take the initiative to activate the card.
inet addr: 127.0.0.1 Mask: 255.0.0.0

2. Activate Ethernet
gec @ ubuntu: ~ $ sudo ifconfig eth0 up

3. Check again
GEC @ Ubuntu: ~ $ ifconfig
eth0 Link encap: Ethernet HWaddr 00: 0c: 29: 5D:. 9C: 76
inet6 addr: fe80 :: 20c: 29ff: fe5d: 9c76 / 64-Scope: Link -> has been activated Ethernet card, but have not set the IP address.

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0

4. Open the configuration file setting the IP address
gec @ ubuntu: ~ $ sudo vi / etc / network / interfaces

search all of it to auto so
iface search all of the inet loopback

audo eth0 -> Modify: Auto eth0
iface eth0 inet static
address 192.168.0.245 -> Modify: address 192.168.xx.xx (here I changed it is 192.168.90.15)
Gateway 192.168.0.1 -> Modify: gateway 192.168.xx.1 (Note gateway address with the same network segment)
Netmask 255.255.255.0

Save and exit!

5. 重启网络
gec@ubuntu:~$ 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... [OK]

6. restart the virtual machine, check the IP address again
GEC @ Ubuntu: ~ $ ifconfig
eth0 Link encap: Ethernet HWaddr 00: 0c: 29: 5D:. 9C: 76
inet addr: 192.168.90.15 Bcast: 192.168.90.255 Mask: 255.255.255.0

Guess you like

Origin www.cnblogs.com/xdd-sdyp/p/11793953.html