*修改ipconfig
#vi /etc/netplan/50-cloud-init.yaml
(1)DHCP
network:
ethernets:
enp0s3:
addresses: []
dhcp4: true
version: 2
(2)固定IP
network:
ethernets:
enp0s3:
addresses: [192.168.0.10/24]
gateway4: 192.168.0.1
nameservers:
addresses: [8.8.8.8,8.8.4.4]
dhcp4: no
version: 2
(確定前測試)
#netplan try
(確定修改)
#netplan apply
*加上rc.local
1.建立rc-local.service文件
#vi /etc/systemd/system/rc-local.service
[Unit]
Description=/etc/rc.local Compatibility
ConditionPathExists=/etc/rc.local
[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99
[Install]
WantedBy=multi-user.target
#將要執行的命令寫入 /etc/rc.localDescription=/etc/rc.local Compatibility
ConditionPathExists=/etc/rc.local
[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99
[Install]
WantedBy=multi-user.target
# chmod +x /etc/rc.local
# systemctl start rc-local.service
沒有留言:
張貼留言