banner
李大仁博客

李大仁博客

天地虽大,但有一念向善,心存良知,虽凡夫俗子,皆可为圣贤。

[Linux]Ubuntu配置修改网络连接配置

Ubuntu 的网络配置与 CentOS 相比区别不大,具体方法如下:

1. 使用编辑器打开网卡的配置文件,这里默认使用 eth0

vi /etc/network/interfaces

键入以下内容

# The loopback network interface
auto lo
iface lo inet loopback

The primary network interface#

auto eth0 #自动配置 eth0
iface eth0 inet static #设置为静态配置,需要动态获取 ip 时可选 dhcp
address 192.168.0.100 #IP 地址
broadcast 192.168.0.255 #对应的子网广播地址
netmask 255.255.255.0 #子网掩码
network 192.168.0.0 #网络地址
gateway 192.168.0.1 #网关地址,可选设定

2. 修改 DNS 解析,编辑 resolv.conf 文件

vi /etc/resolv.conf

键入

nameserver 8.8.8.8
nameserver 8.8.4.4

修改完 resolv.conf 后 dns 解析会立即生效

3. 重启网络配置

/etc/init.d/networking restart

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.