Hostname and IP setup
From Smith family
| Server setup | |
| ← Previous | Next → |
| OS installation | Firewall |
The default setup for allocating IP numbers is dynamically, via DCHP from the router. That's fine for most machines, but server machines need fixed IP numbers. As both Linux machines act as servers, they both need fixed IP numbers.
The first thing to do is to adjust the settings on the router so that some of the IP numbers on the LAN are not in the DHCP pool. While you're there, adjust the settings on the router to open various ports and pass the packets to the server.
Contents |
Hostname
To give the Linux boxes their hostname, adjust the following files:
- Change
/etc/hostnameto
server
- Change
/etc/resolv.confto include
domain domain.tld search domain.tld
- (you may need to include these lines in
/etc/resolvconf/resolv.conf.d/tailifresolvconfkeeps overwriting/etc/resolv.conf)
- Change
/etc/hoststo include
127.0.0.1 localhost 127.0.1.1 server.domain.tld server
Find the hostname with hostname, the domain name with dnsdomainname and the FQDN with hostname -f.
Multiple network cards
One of my machines has two network cards. udev assigns interface names to the cards. The trouble is, it seems to do it randomly. To fix how the interface names are assigned to the NICs, modify the file /etc/udev/rules.d/70-persistent-net.rules to include the naming you want:
# PCI device 0x11ab:0x4320 (skge)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="xx:xx:xx:xx:xx:xx", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x10b7:0x9200 (3c59x)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="xx:xx:xx:xx:xx:xx", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
- Remember to remove any existing naming rules. Note that you should replace the xx:xx:xx:xx:xx:xx with your cards' MAC addresses.
Static IP numbers
- To give a network card a static IP number, add a stanza to /etc/network/interfaces
auto eth0
iface eth0 inet static
address 192.168.1.252
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
- Change /etc/resolv.conf to
nameserver 192.168.1.1
(make sure the server and desktop get different IP numbers).
Reboot the machines and they should both have their fixed IP numbers.
Changing hostnames
If you change the hostname after setting up the machine, you'll need to change a couple of things that encode the hostname.
First is the OpenSSH server. The server keys will still be labelled with the old hostname. To regenerate the keys, delete them then reconfigure the openssh-server package:
root@server:~# rm /etc/ssh/ssh_host_* root@server:~# rm dpkg-reconfigure -plow openssh-server
You will then need to remove the key fingerprints from all machines that connect to this server, otherwise the SSH client will complain that the host it's connecting to has changed identity. For each user, remove the line for the given host in ~/.ssh/known-hosts. When you next connect to the host, you'll be asked to confirm the key fingerprint again. (Taken from Vivek Gite's instrutions.)
The other thing is the user table in MySQL. MySQL creates users for the particular hostname. They're easily changed using the MySQL tool:
root@desktop:~# mysql -u 'root' -p mysql> update mysql.user set host='newhost.domain.tld' where host='oldhost.domain.tld'; mysql> quit;
External DNS records
I use DomainDiscount24 as a registrar for my domains. Their nameservers provide the canonical source for external DNS lookups for the njae.me.uk domain, among others. The domain settings there are fairly straightforward. I use their standard nameservers (ns1.domaindiscount24.net, ns2.domaindiscount24.net, and ns3.domaindiscount24.net).
The DNS settings are:
| IN A | 212.69.55.62 |
| MX | 10 mail.njae.me.uk |
| 20 mail.microwavesushi.com |
Ensure the 'Make wildcard entry' box at the bottom of the page is checked, so that domains such as www.njae.me.uk and mail.njae.me.uk can be resolved.
