标签:find bee ima and alt red idt 分享图片 gate
原文: http://www.configserverfirewall.com/ubuntu-linux/ubuntu-set-static-ip-address/
-------------------------------------------------------------------------------------------------
It is really important to know how to configure static IP Address on Ubuntu Server, Because it is almost impossible to run a server without a static IP Address.
During the installation, Ubuntu Server by default configured to use dynamic IP Address. In this Tutorial we are going to learn how to set static IP Address in Ubuntu Server 16.04.
Following are the steps we are going to follow
First of all you need to get the list of available network interfaces on your Ubuntu Server 16.04. We can use ip link show command to find available network interfaces on Ubuntu Linux.
ip link show
You should get the similar output as below screenshot shows.
As above image shows, Our Ubuntu Server has Ethernet interfaces called enp0s3. Next we‘ll set static IP address to the enp0s3 interface.
For this example I am going configure enp0s3 Ethernet interfaces with following ip configuration
IP Address = 192.168.1.10
Network mask = 255.255.255.0
Default gateway = 192.168.1.1
DNS Server = 8.8.8.8 and 8.8.4.4
On Ubuntu server, in order to set static IP address we need to add IP configuration to the /etc/network/interfaces file. So open the /etc/network/interfaces file using a command line text editor (You can use vim or nano on Ubuntu Server).
vim /etc/network/interfaces
Then set static IP address as follows.
First line of configuration should be the word "auto" followed by the interface name (This brought up the network interface automatically when system boot or when networking restart).
auto enp0s3
The next line should specify whether to use static IP address or dhcp ip on the enp0s3 network interface. In our case it should be static.
auto enp0s3
iface enp0s3 inet static
Then add the static IP configuration as follows.
auto enp0s3
iface enp0s3 inet static
address 192.168.1.10
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 8.8.8.8 8.8.4.4
After setting up IP Configuration, we need to restart Ubuntu networking service.
sudo ip addr flush enp0s3 && sudo systemctl restart networking.service
After restarting network, use ip add command to make sure that static ip address has been assigned to the network interface.
ip add
Then send ICMP request to a remote host to check the connectivity.
ping -c 4 google.com
Same Way you can configure multiple network interface on ubuntu server using /etc/network/interfaces file.
Example
In the following example, I have set static IP Address on two network interfaces (enp0s3 and enp0s8).
auto enp0s3
iface enp0s3 inet static
address 192.168.1.10
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 8.8.8.8 8.8.4.4
auto enp0s8
iface enp0s8 inet static
address 192.168.0.100
netmask 255.255.255.0
*** Most important thing when configuring multiple interface is you cannot set multiple default gateways. Only one interface should configure with the default gateway. For other interfaces you should add default gateway using static routes.
In this tutorial we learned how to set static ip address in Ubuntu server 16.04.
给ubuntu设置静态ip —— How to set static IP Address in Ubuntu Server 16.04
标签:find bee ima and alt red idt 分享图片 gate
原文地址:https://www.cnblogs.com/oxspirt/p/9527153.html