跳转至主要内容
  • 快速、轻松地下订单
  • 查看订单并跟踪您的发货状态
  • 创建并访问您的产品列表
  • 使用“Company Administration”(公司管理),管理Dell EMC站点、产品和产品级联系人。

文章编号: 000146536


Ubuntu Server Networking

摘要: In Ubuntu Server, configuring network interfaces is surprisingly straight-forward. As opposed to other Linux distributions, where there is a configuration

文章内容


症状

In Ubuntu Server, configuring network interfaces is surprisingly straight-forward. As opposed to other Linux distributions, where there is a configuration file per each interface (which can be hard to manage), there is only one network interface configuration file in Ubuntu:

/etc/network/interfaces

Here is a basic example:

# The loopback network interface
auto lo
iface lo inet loopback

# Built-in NIC, port 1
auto em1
iface em1 inet dhcp

As you can see, the loopback interface and only one NIC port is defined, which is using DHCP. This file will be automatically populated when the OS is installed.

Say that you want to change from DHCP to a static IP address. How do you do it? Easy, though there is an extra step that may not be obvious:

1. Edit config file to look like this:

# The loopback network interface
auto lo
iface lo inet loopback

# Built-in NIC, port 1
auto em1
iface em1 inet static
address 192.168.1.7
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 192.168.1.254 # Your DNS server, if any
dns-search dlr.com # Your DNS search domain, if any

2. Restart networking service:

$ sudo /etc/init.d/networking restart

If using 12.04 or earlier, ignore the 'deprecated' warning message. If using 12.10 or later, you can instead use:

$ sudo restart networking

3. Shutdown the dhclient daemon, otherwise you will get an IP address from DHCP when the lease is renewed, regardless of what's specified in the configuration file:

$ sudo killall dhclient
$ sudo apt-get -y purge isc-dhcp-client

文章属性


上次发布日期

21 2月 2021

版本

3

文章类型

Solution