Ubuntu Server 下的网络配置

 时间:2024-10-12 09:33:48

检查网络配置

$ifconfig

配置DHCP客户端$sudovi/etc/network/interfaces加入ifaceeth0inetdhcp

Ubuntu Server 下的网络配置

让新配置生效保存退出后,使用重启networking命令让新配置生效:$sudo/etc/init.d/networkingrestart也可以重启网卡让新配置生效,优点是不影响其他网络接口:$sudoifdowneth0$sudoifupeth0

临时改变IP地址

$sudoifconfigeth0192.168.1.111netmask255.255.255.0当系统重启动后,后会恢复interfaces中的配置。

设置默认网关的方法也有两种:1.在interfaces文件中设置。$sudovi/etc/network/interfaces在eth0的相关配置下加入gateway,如:autoeth0ifaceeth0inetstaticaddress192.168.1.123netmask255.255.255.0gateway192.168.1.1

Ubuntu Server 下的网络配置

2.直接用命令设置:

$sudoroutedeldefaultgw手工配置缺省网关$sudorouteadddefaultgw192.168.1.1查看路由信息$route使用本方法,修改当即生效,重新启动后,则interfaces文件中的设置有效。

查看主机名$hosts

临时修改主机名$sudohostnametestserver执行完命令后,即时生效。

永久修改主机名

$sudovi/etc/hostname把新的主机名写入即可。当系统重启后,会读出此文件中主机名。

配置DNS服务器的地址,最多可以使用3个DNS服务器$sudovi/etc/resolv.confnameserver202.xx.xx.xxnameserver192.168.1.1对”resolv.conf”的修改是即时生效的。可以使用nslookup命令进行DNS服务器查询,以验证”resolv.conf”配置文件。

  • 【CentOS 7】GNOME桌面如何链接账户
  • ubuntu 最简化安装gnome桌面
  • ftp连不上linux服务器怎么办(红帽rhel等)
  • 教你怎么用Python获得当前主机的MAC物理地址
  • ubuntu16.04怎么解压rar压缩文件
  • 热门搜索
    型男是什么意思 打飞机什么意思 香港肉丸子事件是什么意思 冷雨扑向我点点纷飞是什么歌 蓝色配什么颜色好看 时间像什么 become是什么意思 雪燕是什么 什么是甲亢 什么是有机食品