ubuntu设置ip和dns
Ubuntu配置和修改IP地址

Ubuntu配置和修改IP地址1、修改配置⽂件/etc/network/interfaces:~# sudo gedit /etc/network/interfaces添加以下内容:auto eth0 #设置⾃动启动eth0接⼝iface eth0 inet static #配置静态IPaddress 192.168.11.88 #IP地址netmask 255.255.255.0 #⼦⽹掩码gateway 192.168.11.1 #默认⽹关2、修改DNSsudo gedit /etc/resolve.confnameserver 127.0.0.1 #记得加上nameserver 8.8.8.8 #当地dns服务器(⽤ipconfig /all 查看本地dns,第⼀个dns是默认的,共有2个dns)注:#后⾯的注释信息不要加进去。
3、重启⽹络,使配置⽣效sudo /etc/init.d/networking restart4、查看ip是否配置成功 :~# ifconfigeth0 Link encap:Ethernet HWaddr 00:0c:29:2d:89:40inet addr:192.168.11.88 Bcast:192.168.11.255 Mask:255.255.255.0inet6 addr: fe80::20c:29ff:fe2d:8940/64 Scope:LinkUP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1RX packets:223 errors:0 dropped:0 overruns:0 frame:0TX packets:253 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:1000RX bytes:24219 (24.2 KB) TX bytes:22960 (22.9 KB)Interrupt:19 Base address:0×2024lo Link encap:Local Loopbackinet addr:127.0.0.1 Mask:255.0.0.0inet6 addr: ::1/128 Scope:HostUP LOOPBACK RUNNING MTU:16436 Metric:1RX packets:48 errors:0 dropped:0 overruns:0 frame:0TX packets:48 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:0RX bytes:3964 (3.9 KB) TX bytes:3964 (3.9 KB):~#注:红字加粗“192.168.11.88”跟上⾯配置的ip⼀样,表⽰ip配置成功。
Ubuntu系统Bind搭建配置私有、主备DNS服务器

Ubuntu系统Bind搭建配置私有、主备DNS服务器上一篇文章中介绍了Ubuntu系统缓存转发DNS服务器的配置,不过有时可能还需要我们自己搭建一个私有DNS服务器。
例如一个或多个项目的多台服务器之间,通信地址可能需要配置成统一的域名地址,解析记录可能需要私有IP地址等。
使用域名而不是IP的方式,可以很好的管理服务器和项目中的配置,减少维护成本和风险。
Ubuntu系统试了下,12.04,14.04和16.04应该都没什么问题,配置一样。
准备准备两台server,一台主DNS服务器,一台备份DNS服务器。
ns1:192.168.140.129ns2:192.168.140.135步骤安装和配置步骤参考前面缓存和转发DNS服务器的配置。
主DNS服务器1、安装登录server服务器,运行apt-get命令安装。
apt-get updateapt-get install bind9 bind9utils bind9-doc进程named,配置文件目录为/etc/bind ,监听在TCP和UDP 的53端口。
2、关闭IPv6一般现在bind工作在ipv4环境居多,所以先把ipv6监听的地址关了。
vi /etc/default/bind9OPTIONS中增加-4选项,例如:OPTIONS="-u bind -4"。
3、配置缓存转发打开/etc/bind/named.conf.options目录,修改后如下。
acl goodclients {192.168.140.0/24;localhost;localnets;};options {directory "/var/cache/bind";listen-on { 192.168.140.129;};listen-on-v6 { none; };dnssec-validation auto;auth-nxdomain no; # conform to RFC1035recursion yes ;allow-query { goodclients;};allow-transfer { none; }; # disable zone transfers by defaultforwarders {223.5.5.5;223.6.6.6;};forward only ;};4、配置local文件named.conf.local 文件默认是空的。
ubantu详细配置

$ sudo hwclock -w # 根据修正好的系统时钟(软件时钟)时间修正硬件时钟的时间
Tips:不同软件源服务器下载速度受你所在网络服务提供商(ISP)影响。例如有的服务器中国电信用户使用速度极快,但北方的中国联通(原网通)使用极慢。选择你觉得最快的服务器。如果你不知道该怎么做,点击“Select best Server”按钮由系统逐一测试,不过这可能会花费很长的时间,不推荐应用。如果觉得官方源速度都很慢,那么请将 Ubuntu Software 标签下所有的钩打掉以禁用官方源服务器,选择我们推荐的第三方源。
开启了『语言支援』(Language Selector) 后,按『安装或删除语言...』(Install/Remove Languages...) 进入『已安装语言』(Installed Languages) 对话框:
点选「中文 (繁体)」或「中文 (简体)」,按『套用变更』(Apply) 下载了中文语言套件并回到『语言』(Language) 对话框后,在 我的选单和窗口使用 (For my menus and windows, use) 设定您想使用的语言:「汉语 (香港)」Chinese (Hong Kong Special Administrative Region of China))、「中文 (台湾)」(Chinese (Taiwan))、「汉语 (中国)」(Chinese (China)) 或「Chinese (Singapore)」,并记谨开启『使用输入法引擎 (IME) 以输入复杂字符』(Use input method engines (IME) to enter complex characters)。
ubuntu中ip address的用法

ubuntu中ip address的用法在Ubuntu中,ip address用于管理网络接口的IP地址配置。
它提供了用于配置和管理网络接口的工具和命令。
以下是在Ubuntu中使用ip address的用法和常见操作:1. 查看当前网络接口的IP配置:```arduinoip addr```该命令将显示系统中所有网络接口的IP配置信息,包括接口名称、IP地址、子网掩码、网关等。
2. 添加新的网络接口:```phpsudo ip link add name <interface_name> type <interface_type>```使用此命令可以添加新的网络接口。
`<interface_name>`是接口的名称,`<interface_type>`可以是`ethernet`(以太网)、`wifi`(无线)等。
例如,要添加一个名为`eth0`的以太网接口,可以运行以下命令:```bashsudo ip link add name eth0 type ethernet```3. 设置网络接口的IP地址和子网掩码:```phpsudo ip addr add <ip_address>/<subnet_mask> dev <interface_name> ```使用此命令可以为指定的网络接口设置IP地址和子网掩码。
`<ip_address>`是所需的IP地址,`<subnet_mask>`是子网掩码的长度(例如,24表示255.255.255.0),`<interface_name>`是已存在的网络接口名称。
例如,要将`eth0`接口设置为IP地址为192.168.1.10/24,可以运行以下命令:```bashsudo ip addr add 192.168.1.10/24 dev eth0```4. 设置默认网关:```phpsudo ip route add default via <gateway_ip> dev <interface_name> ```使用此命令可以为指定的网络接口设置默认网关。
ubuntu18.04配置静态ip和动态ip

ubuntu18.04配置静态ip和动态ip进入netplan文件夹cd /etc/netplan查看文件夹下的yaml文件ls文件后缀为.yaml,我的是01-network-manager-all.yaml的文件。
如果没有可以使用sudo touch 01-network-manager-all.yaml自己创建编辑网络配置文件之前,先使用:ifconfig查看自己的网卡名称,我的是eno11.# Let NetworkManager manage all devices on this systemwork:3.version: 24.renderer: NetworkManager5.ethernets:6.eno1: #配置的网卡名称,使用ifconfig -a查看得到7.dhcp4: no #dhcp4关闭8.addresses: [192.168.202.36/24] #设置本机IP及掩码9.gateway4: 192.168.202.1 #设置网关servers:11.addresses: [114.114.114.114] #设置DNS使用命令,使静态ip生效。
sudo netplan apply编辑网络配置文件之前,使用ifconfig命令查看配置情况,如果配置成功上图中ip会变成自己设置的ip。
2.配置动态IP1.# Let NetworkManager manage all devices on this systemwork:3.version: 24.renderer: NetworkManager5.ethernets:6.enp3s0: #配置的网卡名称,使用ifconfig -a查看得到7.dhcp4: true #dhcp4开启8.addresses: [] #设置本机IP及掩码,空9.optional: true使用命令,使动态IP生效sudo netplan apply再次使用ifconfig查看是否更改IP成功。
ubuntu IP设置

Ubuntu 11.04 下如何手动设置IP现在的计算机发展已经非常智能化了,我们很多时侯已经不用给计算机设置IP 地址而计算机在链接到网络的时侯会自动配置这些。
那么如果我们想在Ubuntu 11.04 下自己指定一个IP 地址该在哪里操作呢?下面我就来一步一步告诉大家在Ubuntu 11.04 下IP 地址在哪里设置:首先,在打开系统设置“Power –> System Settings” :然后选择“互联网和网络”中的网络链接“Internet and Network –> Network Connections” :打开对话框后,选择选择当前网络连接“Auto eth(X)” 然后点击编辑按钮“Edit”然后选择IPv4 设置选项卡"IPv4 Settings",并选择"Manual" 连接方法。
然后点击添加按钮“Add” :然后输入我们自己需要的IP 地址、子网掩码和网关。
在DNS 服务器框中,输入DNS 服务器地址,可以用逗号分隔多个DNS 地址:输入完成后,我们点击保存按钮“Save”。
这样我们自己指定的IP 地址就设定好了。
Ubuntu11.04网络配置与问题排除这几天用Ubuntu11.04,被网络配置问题搞得很心烦。
这个Ubuntu是装在笔记本上的,在宿舍有静态IP,在实验室用无线网,IP自动获取。
刚开始系统装好了,没有进行配置,开启无线网,就可以上网了。
于是以为Ubuntu的网络配置做的挺好的哈。
回到宿舍,配置好静态IP,和DNS,打开网页,也可以上网了。
挺不错的哈。
可第二天,悲剧就来了。
实验室无线网络没有什么问题,问题是回到宿舍后,不能上网了。
ping一下,unreachable。
看一下IP设置,是对的。
于是networking重启一起,ping一下,也可以了,但还是不能上网。
再看一下DNS。
嗯?空的?昨天设好的dns被清空呢?怎么会这样呢?文件中还有一行注释,generated by network manager。
ubuntu20.04设置静态ip地址(包括不同版本)

ubuntu20.04设置静态ip地址(包括不同版本)因为Ubuntu20.04通过netplan来管理⽹络,和之前得版本略有区别,Ubuntu18.04好像需要编辑/network/interfaces来设置静态⽹络因为安装的是虚拟机,⾸先我将其改为桥接模式接下来编辑⽂件:sudo vim /etc/netplan/01-network-manager-all.yaml将⽂件内容修改为:我⼀直有疑惑,是不是要针对不同的ip地址进⾏修改呢?不过因为我还没到那个层次,所以也不是很清楚,应该是可以修改的,但是直接将下⾯的代码敲到⽂件中也是没有问题的输⼊:wq 保存退出后,再输⼊sudo netplan --debug apply即可现在静态ip就设置好了,可以通过ifconfig来查看当前ip地址。
12.x版本$ cat /etc/network/interfacesauto loiface lo inet loopbackauto eth0iface eth0 inet staticaddress 20.20.20.102netmask 255.255.255.0gateway 20.20.20.102dns-nameservers 20.20.20.214.x版本$ cat /etc/network/interfacesauto loiface lo inet loopbackauto eth0iface eth0 inet staticaddress 20.20.20.102netmask 255.255.255.0gateway 20.20.20.102dns-nameservers 20.20.20.2$ cat /etc/NetworkManager/NetworkManager.conf[main]plugins=ifupdown,keyfile,ofonodns=dnsmasqno-auto-default=00:0C:29:D7:43:29,[ifupdown]managed=true16.x版本$ cat /etc/network/interfacesauto loiface lo inet loopbackauto ens32iface ens32 inet staticaddress 20.20.20.102netmask 255.255.255.0gateway 20.20.20.102$ cat /etc/NetworkManager/NetworkManager.conf[main]plugins=ifupdown,keyfile,ofonodns=dnsmasqno-auto-default=00:0C:29:D7:43:29,[ifupdown]managed=true$ cat /etc/resolv.confnameserver 127.0.1.1nameserver 20.20.20.218.x版本:1、⾸先查看⽹卡名$ ip a / ifconfig2、 cp⼀份yaml⽂件,改个名字$ sudo cp /etc/netplan/*.yaml /etc/netplan/⽹卡名.yaml 3、修改yaml⽂件内容,如下:# Let NetworkManager manage all devices on this system network:version: 2renderer: NetworkManagerethernets:⽹卡名:dhcp4: noaddresses: [ip/prefix]gateway4: gatewaynameservers:addresses: [dns]4、启动$ sudo netplan apply5、验证$ ip a / ifconfig到此这篇关于ubuntu20.04设置静态ip地址(包括不同版本)的⽂章就介绍到这了,更多相关ubuntu20.04设置静态ip内容请搜索以前的⽂章或继续浏览下⾯的相关⽂章希望⼤家以后多多⽀持!。
ubuntu配置DNS

ubuntu配置DNS设置Ubuntu DNS缓存1. 安装dnsmasq:# 安装dnsmasq的软件包[linuxidc@linuxidc-Ubuntu ~] $ sudo apt-get install "dnsmasq"2.设定dnsmasq接管本机的DNS解析请求:# 修改dnsmasq的配置文件[xport@ubuntu ~] $ sudo gedit /etc/dnsmasq.conf# 找到下面的内容,并进行修改listen-address=127.0.0.1 # 把这一行前面的注释去掉# 修改dnsmasq的配置文件[linuxidc@linuxidc-Ubuntu ~] $ sudo gedit /etc/dhcp3/dhclient.conf# 找到下面的内容,并进行修改prepend domain-name-servers 127.0.0.1; # 把这一行前面的注释去掉3.修改resolv.conf的配置:[linuxidc@linuxidc-Ubuntu ~] $ sudo gedit /etc/resolv.conf# 注意:我的resolv.conf文件的内容不会因为ADSL拨号而被改写# 因为dnsmasq会接管本机的DNS解析请求,所以把127.0.0.1的地址放在最前面nameserver 127.0.0.1nameserver xxx.xxx.xxx.xxxnameserver xxx.xxx.xxx.xxxsearch lan4. 重新开启dnsmasq的服务:[linuxidc@linuxidc-Ubuntu ~] $ sudo /etc/init.d/dnsmasq restart5.修改dsl-providersudo gedit /etc/ppp/peers/dsl-provider在usepeerdns 前面增加#,也就是把这条语句覆盖掉。
在Ubuntu操作系统中开启SSH服务和设置IP的步骤

在Ubuntu操作系统中开启SSH服务和设置IP的步骤SSH的英文全称是SecureSHell。
通过使用SSH,你可以把所有传输的数据进行加密,这样\"中间人\"这种攻击方式就不可能实现了,而且也能够防止DNS和IP欺骗。
还有一个额外的好处就是传输的数据是经过压缩的,所以可以加快传输的速度。
下文介绍的是在Ubuntu操作系统中开启SSH服务和设置IP的步骤。
Ubuntu系统中开启SSH设置:1、默认ubuntu已经安装好了客户端2、如使用命令:ps-e|grepssh3、会打印出来:ssh-agent4、下面安装服务端:sudoapt-getinstallopenssh-server(sudoapt-getinstallssh)5、安装好后会自动启动服务,再使用命令ps-e|grepssh6、会打印出:ssh-agent和sshd7、现在可以在其它系统使用ssh工具连到这台电脑了。
8、在上面如果没有启动ssh命令则:sudo/etc/init.d/sshstart9、etc/ssh/sshd_config里面可修改ssh端口,默认为2210、重启ssh服务sudo/etc/init.d/sshrestart11,安装vsftpd#sudoapt-getinstallvsftp设置/etc/vsftpd.conf,由于不需要对外开放FTP,只是内网访问,相关设置如下. #拒绝匿名用户,将其注释掉#anonymous_enable=YES#接受本地用户local_enable=YES#可以上传write_enable=YES#允许上传Ascii文件ascii_upload_enable=YESascii_download_enable=YES启动vsftpd/etc/init.dvsftpdstarUbuntu系统中IP设置:一、使用命令设置Ubuntu IP地址1.修改配置文件blacklist.conf禁用IPV6:sudovi/etc/modprobe.d/blacklist.conf2.在文档最后添加blacklistipv6,然后查看修改结果:cat/etc/modprobe.d/blacklist.conf3.设置UbuntuIP(设置网卡eth0的IP地址和子网掩码)sudoifconfigeth0192.168.2.1netmask255.255.255.04.UbuntuIP设置网关sudorouteadddefaultgw192.168.2.2545.UbuntuIP设置DNS修改/etc/resolv.conf,在其中加入nameserverDNS的地址1和nameserverDNS的地址2完成。
ubuntu下配置静态IP地址设置DNS和主机名

ubuntu下配置静态IP地址,设置DNS和主机名新装了ubuntu,虽然使用图形界面明明已经设置好了ip,网关等等,但是不能上网。
一个朋友提醒说,也许是设置的问题,试试命令行的设置。
于是搜索了一下怎么设置,结果还真的成功了。
具体如下:1. 检验是否可以连通,就使用ping命令ping 网关开始的时候总是现实unreachable2. 设置IPsudo ifconfig eth0 133.133.133.190 netmask 255.255.255.0这样就算设置好了网卡eth0的IP地址和子网掩码3. 设置网关sudo route add default gw 133.133.133.404. ping 网关就可以ping通了5. 设置DNS 修改/etc/resolv.conf,在其中加入nameserver DNS的地址1nameserver DNS的地址2完成。
这样设置之后,下次开机时候似乎IP又会发生变化。
一、使用命令设置ubuntu的ip地址1. 设置IPsudo ifconfig eth0 203.171.239.155 netmask 255.255.255.224这样就算设置好了网卡eth0的IP地址和子网掩码2. 设置网关sudo route add default gw 203.171.239.1293. 设置DNS 修改/etc/resolv.conf,在其中加入nameserver DNS的地址1 nameserver DNS的地址2 完成。
不过,这样设置之后,下次开机时候似乎IP又不存在了。
二、直接修改系统配置文件ubuntu的网络配置文件是:/etc/network/interfacesubuntu命令行修改网络配置方法/etc/network/interfaces打开后里面可设置DHCP或手动设置静态ip。
前面auto eth0,让网卡开机自动挂载.1. 以DHCP方式配置网卡编辑文件/etc/network/interfaces:sudo vi /etc/network/interfaces并用下面的行来替换有关eth0的行:# The primary network interface - use DHCP to find our addressauto eth0iface eth0 inet dhcp用下面的命令使网络设置生效:sudo /etc/init.d/networking restart也可以在命令行下直接输入下面的命令来获取地址sudo dhclient eth02. 为网卡配置静态IP地址编辑文件/etc/network/interfaces:sudo vi /etc/network/interfaces并用下面的行来替换有关eth0的行:# The primary network interfaceauto eth0iface eth0 inet staticaddress 192.168.3.90gateway 192.168.3.1netmask 255.255.255.0#network 192.168.3.0#broadcast 192.168.3.255将上面的ip地址等信息换成你自己就可以了.用下面的命令使网络设置生效: sudo /etc/init.d/networking restart3. 设定第二个IP地址(虚拟IP地址)编辑文件/etc/network/interfaces:sudo vi /etc/network/interfaces在该文件中添加如下的行:auto eth0:1iface eth0:1 inet staticaddress 192.168.1.60netmask 255.255.255.0network x.x.x.xbroadcast x.x.x.xgateway x.x.x.x根据你的情况填上所有诸如address,netmask,network,broadcast和gateways 等信息.用下面的命令使网络设置生效:sudo /etc/init.d/networking restart4. 设置主机名称(hostname)使用下面的命令来查看当前主机的主机名称:sudo /bin/hostname使用下面的命令来设置当前主机的主机名称:sudo /bin/hostname newname系统启动时,它会从/etc/hostname来读取主机的名称.关于设置主机名称的更多信息,请访问这里5. 配置DNS首先,你可以在/etc/hosts中加入一些主机名称和这些主机名称对应的IP地址,这是简单使用本机的静态查询.要访问DNS 服务器来进行查询,需要设置/etc/resolv.conf文件.假设DNS服务器的IP地址是192.168.3.2, 那么/etc/resolv.conf文件的内容应为:search nameserver 192.168.3.2/etc/network/interfaces打开后里面可设置DHCP或手动设置静态ip。
Ubuntu网卡基本配置

Ubuntu网卡基本配置:一、设置IP和网关(1) 配置eth0的IP地址,同时激活该设备#sudo ifconfig eth0 192.168.1.10 netmask 255.255.255.0 up (2) 添加默认网关#sudo route add default gw 192.168.1.1(3) 查看网卡配置#ifconfig如果只查看eth0的配置信息#ifconfig eth0二、直接编辑网卡配置文件(推荐用这个方法设置)(1)编辑文件$ sudo vi /etc/network/interfaces# The loopback network interface (配置环回口)auto lo # 开机自动激lo接口iface lo inet loopback # 配置lo接口为环回口# The primary network interface #配置主网络接口auto eth0 #开机自动激活eth0接口iface eth0 inet dhcp #配置eth0接口为DHCP自动获取或者配置eth0为静态地址# The primary network interface (配置主网络接口) auto eth0 #开机自动激活eth0接口iface eth0 inet static #配置eth0接口为静态地址address 192.168.1.10gateway 192.168.1.254Netmask 255.255.255.0network 192.168.1.0broadcast 192.168.1.255(2)重启网络服务#sudo /etc/init.d/networking restart三、配置DNS配置DNS服务器的地址,最多可以使用3个DNS服务器$ sudo vi /etc/resolv.confnameserver 202.96.134.133nameserver 202.96.128.68nameserver 202.96.128.166对"resolv.conf"的修改是即时生效的。
Linux系列:Ubuntu虚拟机设置固定IP上网(配置IP、网关、DNS、防止resol。。。

Linux系列:Ubuntu虚拟机设置固定IP上⽹(配置IP、⽹关、DNS、防⽌resol。
虚拟机⾥设置上⽹⽅式为NAT最⽅便,因为⽆需⼿动设置即可上⽹,但是NAT的上⽹⽅式默认是DHCP动态分配IP的,这意味着你每次重启虚拟机都有不⼀样的IP地址,这对⼀般⽤户没任何问题。
但是如果你的机⼦有特殊⽤处,⽐如作为服务器,需要IP地址信息,亦或者像我⼀样,作为⼀个云计算的节点,其IP都是在配置⽂件⾥配置好的,如果每次重启系统都要跑过去修改下配置⽂件⾥的IP,那简直是不可取的做法,因此为虚拟机设置固定IP上⽹⾮常的有必要!设置固定IP的⽅法很多,⼤家都知道虚拟机上⽹有三种模式:bridged、host-only和NAT,其中NAT模式对应VMnet8虚拟⽹络,host-only模式对应VMnet1虚拟⽹络,bridged模式对应 VMnet0虚拟⽹络,都是由VMware虚拟机⾃动配置⽽⽣成的,不需要⽤户⾃⾏设置。
VMnet8和VMnet1提供DHCP服务,VMnet0虚拟⽹络则不提供。
三种⽅式具体的区别和介绍可看参考⽂献(1)。
由于NAT的⽅式最简单,因此下⾯是NAT设置的具体⽅法。
测试环境:虚拟机版本:VMware Workstation 10Ubuntu版本:Ubuntu 12.10/13.041. 设置虚拟机上⽹⽅式为NAT2. 配置VMnet8虚拟⽹络(Virtual Network Editor)因为NAT对应的是VMnet8虚拟⽹络,打开Vmware⾃带的虚拟⽹络编辑⼯具Virtual Network Editor,配置如下:其中⼦⽹IP根据⾃⼰情况设置,⽐如我想设置固定IP地址为192.168.1.151,那么这⾥的⼦⽹IP就填192.168.1.0,另外记得取消DHCP选项服务。
3. 进⼊到Ubuntu系统中配置⽹络主要配置下⾯三个⽅⾯的内容:(1)修改⽂件/etc/network/interfaces,这⾥是IP、⽹关、掩码等的⼀些配置;(2)修改⽂件/etc/resolv.conf,这个⽂件保存DNS的有关信息;(3)解决resolv.conf被重写问题;(4)重启虚拟机⽹络下⾯是具体配置⽅法:(1)修改⽂件/etc/network/interfaces命令:sudo vi /etc/network/interfaces sudo gedit /etc/network/interfaces我的配置如下:# interfaces(5) file used by ifup(8) and ifdown(8)auto loiface lo inet loopbackauto eth0iface eth0 inet staticaddress 192.168.1.151netmask 255.255.255.0gateway 192.168.1.2其中⽹关gateway要与Virtual Network Editor中“NAT Settings...”中的⼀致,⼀般好像都为192.168.xx.2。
ubuntu如何设置dns?

ubuntu如何设置 dns?
1. 临时生效(随时会被刷掉)
关闭systemd-resolved进程 # systemctl stop systemd-resolved # echo "nameserver 8.8.8.8" /etc/resolv.conf
2.2 重新启动systemd-resolved服务
$ sudo systemctl restart systemd-resolved
2.2.3 查看当前dns状态
$ sudo systemd-resolve --status Global
DNS Servers: 8.8.8.8 ...
2.3 更新配置
# resolvconf -u
2.4 检查配置是否生效
# cat /etc/resolv.conf nameserver 8.8.8.8
方案二 2.1 打开 /etc/systemd/resolved.conf,修改为
[Resolve] DNS=8.8.8.8 # 设置的是域名解析服务器的IP地址 #FallbackDNS= #Domains= LLMNR=no # 设置的是禁止运行LLMNR(Link-Local Multicast Name Resolution),否则systemd-resolve会监听5535端口 #MulticastDNS=no #DNSSEC=no #Cache=yes #DNSStubListener=yes
2. 永久生效(使用ystemd-resolved, ubuntu18.04以及之后的版本默认使用此工具管理dns) (方案一) 2.1 安装resolvconf工具
Ubuntu路由器上网配置

Ubuntu路由器上网设置
装完ubuntu 第一件事情就是连上网,换个源,进行更新操作,但前提条件是要配好ip和dns。
下面把自己配置的过程记录下来,权且当作一份备份,以便不时之需。
一、配置ip
ubuntu的网络配置信息放在/etc/network/interfaces 中,如果配置动态获取ip,则在上述文件中加入以下内容:
auto eth0
iface eth0 inet dhcp
如果配置静态ip,则添加如下内容:
auto eth0
iface eth0 inet static
address 192.168.33.201
netmask 255.255.255.0
gateway 192.168.33.1
要是配置生效,需要重启网卡:
sudo ifconfig eth0 down
sudo ifconfig eth0 up
接着用ifconfig命令查看ip是否配置成功,配置成功的结果如图一所示:
图一配置成功后的ip信息
若还有没有配置成功,则需重启下网络服务
/etc/init.d/networking restart
二、配置dns服务器
ubuntu 的dns服务器信息,放在/etc/resolv.conf中,
添加dns服务器地址,如202.112.125.53,则在上述文件中加入
nameserver 202.112.125.53
小结:只要按上面的步骤配置完,就能上网了,如果还不行就重启下机器试试。
ubuntu网络设置方法大全

方式1:网卡通过DHCP自动获取IP地址$ sudo gedit /etc/network/interfaces# 修改文件/etc/network/interfaces如下文#-------------------------------------------------------------------------------# This file describes the network interfaces available on your system# and how to activate them. For more information, see interfaces(5).## The loopback network interface(配置环回口)auto lo # 开机自动激lo接口iface lo inet loopback # 配置lo接口为环回口# The primary network interface (配置主网络接口)auto eth0 #开机自动激活eth0接口iface eth0 inet dhcp #配置eth0接口为DHCP自动获取#-------------------------------------------------------------------------------$ sudo /etc/init.d/networking restart # 重启网络 方式2:网卡静态分配IP地址$ sudo gedit /etc/network/interfaces# 修改文件/etc/network/interfaces如下文#-------------------------------------------------------------------------------# This file describes the network interfaces available on your system# and how to activate them. For more information, see interfaces(5).## The loopback network interface(配置环回口)auto lo # 开机自动激lo接口iface lo inet loopback # 配置lo接口为环回口# The primary network interface (配置主网络接口)auto eth0 #开机自动激活eth0接口iface eth0 inet static #配置eth0接口为静态设置IP地址address 10.16.3.99netmask 255.255.255.0network 10.16.3.0broadcast 10.16.3.255gateway 10.16.3.1###################################################### dns-* options are implemented by the resolvconf package, if installed(DNS 设置)#dns-nameservers 61.153.177.196 61.153.177.197#dns-search #####################################################sudo gedit /etc/resolv.conf##设置DNS server(可以设置多个)#nameserver 192.168.1.1#####################################################-------------------------------------------------------------------------------$ sudo /etc/init.d/networking restart # 重启网络方式3:PPPoE宽带拨号配置首次拨号:应用程序–系统工具–终端 打开一终端,输入命令:sudo pppoeconf系统开始搜索所有网络接口上的adsl modem,一步步的yes过来。
基于Ubuntu18.04配置固定IP的方法教程

基于Ubuntu18.04配置固定IP的⽅法教程前⾔Ubuntu 18.04不再使⽤ifupdown配置⽹络,⽽改⽤netplan。
在/etc/network/interfaces配置固定IP是⽆效的,重启⽹络的命令services network restrart或/etc/init.d/networking restart也是⽆效的。
本⽂主要给⼤家介绍了关于Ubuntu 18.04配置固定IP的相关内容,分享出来供⼤家参考学习,下⾯话不多说了,来⼀起看看详细的介绍吧1. 使⽤ifupdown配置⽹络如果要使⽤之前的⽅式配置⽹络,需要重新安装ifupdown:sudo apt install ifupdown修改配置⽂件/etc/network/interfaces:sudo vim /etc/network/interfaces配置⽂件修改如下:iface ens160 inet staticaddress 210.72.92.25gateway 210.72.92.254netmask 255.255.255.0dns-nameservers 8.8.8.8重启⽹络服务使配置⽣效sudo services network restrart2. 使⽤netplan配置⽹络Ubuntu 18.04使⽤netplan配置⽹络,其配置⽂件是yaml格式的。
安装好Ubuntu 18.04之后,在/etc/netplan/⽬录下默认的配置⽂件名是50-cloud-init.yaml,我们通过VIM修改它:sudo vim /etc/netplan/50-cloud-init.yaml配置⽂件修改如下:network:ethernets:ens160:addresses:- 210.72.92.28/24 # IP及掩码gateway4: 210.72.92.254 # ⽹关nameservers:addresses:- 8.8.8.8 # DNSversion: 2⽆论是ifupdown还是netplan,配置的思路都是⼀致的,在配置⽂件⾥⾯按照规则填⼊IP、掩码、⽹关、DNS等信息。
Ubuntu配置DNS服务器--bind

Ubuntu配置DNS服务器--bind3. BIND9 的安装与配置3.1 bind简介BIND (Berkeley Internet Name Domain)是Domain Name System (DNS) 协议的一个实现,提供了DNS主要功能的开放实现,包括* 域名服务器(named)* DNS解析库函数* DNS服务器运行调试所用的工具是一款开放源码的DNS服务器软件,由美国加州大学Berkeley分校开发和维护的,按照ISC的调查报告,BIND是世界上使用最多最广泛的域名服务系统。
不论你的邮件服务器,WEB服务器或者其他的services如何的安全可靠,DNS的故障会给你带来用户根本无法访问这些服务。
BIND,也是我们常说的named,由于多数网络应用程序使用其功能,所以在很多BIND的弱点及时被发现。
主要分为三个版本:v41998年多数UNIX捆绑的是BIND4,已经被多数厂商抛弃了,除了OpenBSD还在使用。
OpenBSD核心人为BIND8过于复杂和不安全,所以继续使用BIND4。
这样一来BIND8/9的很多优点都不包括在v4中。
v8就是如今使用最多最广的版本,其详细内容可以参阅BIND 8+ 域名服务器安全增强v9最新版本的BIND,全部重新写过,免费(但是由商业公司资助),也添加了许多新的功能(但是安全上也可能有更多的问题)。
BIND9在2000年十月份推出,现在稳定版本是9.3.2。
3.2 软件的相关资源官方网站:/最新版本: 9.3.2 /sw/bind/bind9.3.php#download帮助文档:/sw/bind/配置文件样例:/bind.htmlFAQ: /getOpenSourceResource.php?id=6 3.3 配置环境环境:GNU/Linux Debian/testing Linux 2.6.8-2-386版本:bind9 9.3.2-2测试域名:测试ip: 192.168.102.47 主域名服务器192.168.102.48 纯缓存域名服务器192.168.102.49 辅助域名服务器192.168.102.49 测试客户机3.4 配置文件说明安装bind9的命令:~# aptitude update~# aptitude install bind9 bind9-host dnsutils配置文件族:# ls /etc/bind/ -ltotal 44-rw-r--r-- 1 root root 237 Jan 16 2006 db.0-rw-r--r-- 1 root root 271 Jan 16 2006 db.127-rw-r--r-- 1 root root 237 Jan 16 2006 db.255-rw-r--r-- 1 root root 353 Jan 16 2006 db.empty-rw-r--r-- 1 root root 256 Jan 16 2006 db.local-rw-r--r-- 1 root root 1507 Jan 16 2006 db.root-rw-r--r-- 1 root bind 1611 Jan 16 2006 named.conf-rw-r--r-- 1 root bind 165 Jan 16 2006 named.conf.local-rw-r--r-- 1 root bind 672 Jan 16 2006 named.conf.options-rw-r----- 1 bind bind 77 Aug 4 08:41 rndc.key-rw-r--r-- 1 root root 1317 Jan 16 2006 zones.rfc1918配置文件说明:named.conf设置一般的named参数,指向该服务器使用的域数据库的信息源named.conf.optionsdb.root根服务器指向文件,由Internet NIC创建和维护,无需修改,但是需要定期更新db.locallocalhost正向区文件,用于将名字localhost转换为本地回送IP地址(127.0.0.1) db.127localhost反向区文件,用于将本地回送IP地址(127.0.0.1)转换为名字localhost其中,主配置文件/etc/named.conf的配置语句命令用法acl 定义IP地址的访问控制清单control 定义ndc使用的控制通道include 把其他文件包含到配置文件中key 定义授权的安全密钥logging 定义日志写什么,写到哪opitons 定义全局配置选项和缺省值server 定义远程服务器的特征trunsted-keys 为服务器定义DNSSEC加密密钥zone 定义一个区默认情况下,内容如下:include "/etc/bind/named.conf.options";zone "." {type hint;file "/etc/bind/db.root";};zone "localhost" {type master;file "/etc/bind/db.local";};zone "127.in-addr.arpa" {type master;file "/etc/bind/db.127";};zone "0.in-addr.arpa" {file "/etc/bind/db.0";};zone "255.in-addr.arpa" {type master;file "/etc/bind/db.255";};include "/etc/bind/named.conf.local";其中type项的值:master:表示定义的是主域名服务器slave :表示定义的是辅助域名服务器hint:表示是互联网中根域名服务器在Debian环境中,options语句的配置内容,被移至named.conf.options文件中:options {directory "/var/cache/bind";// If there is a firewall between you and nameservers you want// to talk to, you might need to uncomment the query-source// directive below. Previous versions of BIND always asked// questions using port 53, but BIND 8.1 and later use an unprivileged// port by default.// query-source address * port 53;// If your ISP provided one or more IP addresses for stable// nameservers, you probably want to use them as forwarders.// Uncomment the following block, and insert the addresses replacing// the all-0's placeholder.//可以将下面的注释去掉添加原来的dns (可加多个)// forwarders {// 0.0.0.0;// };auth-nxdomain no; # conform to RFC1035};3.5 创建主域名服务器a. 首先, 在在192.168.102.47机器上安全bind9b. 使用编辑器,比如vi,编辑配置文件/etc/bind/named.conf注:在ubuntu中还有一个/etc/bind/named.conf.local (效果相同)加入如下内容zone "" {type master; //定义此区为主服务器file "/etc/bind/db.mydebian"; //指定区资源文件的位置};zone "102.168.192.in-addr.arpa" {type master; //定义此区为主服务器file "/etc/bind/db.192"; //指定区资源文件的位置};c. 创建区资源文件:创建区资源文件/etc/bind/db.mydebian内容如下;; BIND data file for local loopback interface;$TTL 604800$ORIGIN .@ IN SOA . . (2006080401 ; Serial604800 ; Refresh86400 ; Retry2419200 ; Expire604800 ) ; Negative Cache TTL;@ IN NS ns@ IN MX 0 .@ IN A 192.168.102.47ns IN A 192.168.102.47www IN A 192.168.102.47webserver IN CNAME wwwmail IN A 192.168.102.47ftp IN A 192.168.102.48ns2 IN A 192.168.102.48ns3 IN A 192.168.102.49第一行是TTL设定,生存时间记录字段。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
ubuntu设置ip和dns
装完ubuntu 第一件事情就是连上网,换个源,进行更新操作,但前提条件是要配好ip和dns。
下面把自己配置的过程记录下来,权且当作一份备份,以便不时之需。
一、配置ip
ubuntu的网络配置信息放在 /etc/network/interfaces 中,
如果配置动态获取ip,则在上述文件中加入以下内容:
auto eth0
iface eth0 inet dhcp
如果配置静态ip,则添加如下内容:
auto eth0
iface eth0 inet static
address 192.168.33.201
netmask 255.255.255.0
gateway 192.168.33.1
要是配置生效,需要重启网卡:
ifconfig eth0 down
ifconfig eth0 up
不是root,命令前面加sudo
接着用ifconfig命令查看ip是否配置成功,配置成功的结果如图一所示:
图一配置成功后的ip信息
若还有没有配置成功,则需重启下网络服务
/etc/init.d/networking restart
二、配置dns服务器
ubuntu 的dns服务器信息,放在 /etc/resolv.conf中,
添加dns服务器地址,如202.112.125.53,则在上述文件中加入
nameserver 202.112.125.53
小结:
只要按上面的步骤配置完,就能上网了,如果还不行就重启下机器试试。