ubuntu18命令行修改ip网关
修改 sudo vim /etc/netplan/50-cloud-init.yaml文件network:ethernets:enp0s3:addresses: [192.168.33.34/24]gateway4: 192.168.33.1dhcp4: no optional: no nameservers: addresses: [114.114.
·
1 netplan
也适用于ubuntu server
修改 sudo vim /etc/netplan/50-cloud-init.yaml文件
network:
ethernets:
enp2s0:
addresses: [10.0.230.87/24,192.168.1.87/24]
dhcp4: no
gateway4: 10.0.230.1
optional: no
nameservers:
addresses: [10.0.230.1]
这样设置后可能和界面设置的ip冲突,保存后
sudo netplan apply
2 修改界面设置的ip
cd /etc/NetworkManager/system-connections
ls
sudo vim Profile\ 1
[connection]
id=Profile 1
uuid=0769f567-6a3d-4478-ae6b-b3df3fb741cc
type=ethernet
permissions=
timestamp=1599828840
[ethernet]
mac-address-blacklist=
[ipv4]
address1=10.0.230.89/24,10.0.230.1
dns=192.168.1.1;
dns-search=
ignore-auto-dns=true
method=manual
[ipv6]
addr-gen-mode=stable-privacy
dns-search=
method=auto
3. 临时生效
ifconfig -a 查看所有网卡
sudo ifconfig eth1 up 启用eth1
sudo ifconfig eth1 10.0.230.86 netmask 255.255.255.0
sudo route add default gw 10.0.230.1
修改网关
sudo vim /etc/resolv.conf 修改nameserver为 10.0.230.1
更多推荐
已为社区贡献1条内容
所有评论(0)