Ubuntu下NAT模式配置静态IP

时间:2023-03-09 07:01:55
Ubuntu下NAT模式配置静态IP

编辑文件/etc/network/interfaces:

并用下面的行来替换有关eno16777736的行:

# The primary network interface
auto eno16777736
#iface eno16777736 inet dhcp
iface eno16777736 inet static
address 192.168.172.146
gateway 192.168.172.2
netmask 255.255.255.0

Ubuntu下NAT模式配置静态IP

然后配置dns服务器地址:

vim /etc/resolv.conf

nameserver 192.168.172.2
search localdomain

Ubuntu下NAT模式配置静态IP

将上面的ip地址等信息换成你自己就可以了.用下面的命令使网络设置生效:

sudo /etc/init.d/networking restart

如果需要配置代理: