This article objective is to provide that initial IP configuration, etc..
Shell script.
hostname server-1 ifconfig eth0 172.16.1.11 netmask 255.255.255.0 broadcast 172.16.1.255 route add default gw 172.16.1.1 eth0
Shell script?
# this is a shell script which will be sourced at boot # if you change the hostname then you need to add a # /etc/hosts entry as well # hostname inserthostname_here # like this: # echo "127.0.0.1 inserthostname_here" >>/etc/hosts echo "trex-0" >/etc/hostname cat <<EOF >/etc/network/interfaces auto lo iface lo inet loopback auto eth0 iface eth0 inet static hostname trex-0 address 10.1.1.254 netmask 255.255.255.0 gateway 10.1.1.1 #dns-nameservers 8.8.8.8 EOF service networking restart
This image uses cloud-init
system for initial configuration.
User-data cannot change an instance’s network configuration.
Unfortunately, User-data based direct network configuration will not work. So, you must configure alternative configuration write Netplan file and call Netplan command directly.
#cloud-config password: cisco chpasswd: { expire: False } hostname: ubuntu-0 ssh_pwauth: True ssh_authorized_keys: - ecdsa-sha2-nistp384 AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzODQAAABhBIbn2VyO9Mby6BwkijQmGfH8O2+Uqewn0/oIOXOxMNgCZiztR3v2o5n1l9ET1GuN7iVMe9whoUiNuZMUVEv0INb+A6Yd0M/37tlWlC+qbIjjqL6UzJAqRISdGP1oVmnV2g== wnoguchi@lasthope.pg1x.net write_files: - path: /etc/netplan/51-cloud-init_static.yaml permissions: '0644' content: | network: version: 2 ethernets: enp0s2: match: name: enp0s2 addresses: - 10.1.1.253/24 gateway4: 10.1.1.1 #nameservers: # addresses: # - 8.8.8.8 runcmd: - [ sudo, netplan, generate ] - [ sudo, netplan, apply ]
Image | ID | Password | Elevate privileged user | Remarks |
---|---|---|---|---|
Tiny Core Linux | tc | sudo -Es | ||
Tiny Core Linux | cisco | cisco | sudo -Es | |
Ubuntu 18.04 | ubuntu | cisco | sudo -i |