Configuring Network Interfaces Print

  • 0

Properly configuring your server's network interfaces is crucial for establishing and maintaining connectivity. This guide covers how to set up IP addresses, subnet masks, gateways, and DNS servers on Linux and Windows.

  1. Introduction
    • A network interface (also known as a NIC - Network Interface Card) is your server's connection point to the network. Configuring it involves assigning an IP address and other network parameters so your server can communicate.
    • For remote servers (VPS or Dedicated), always ensure you have out-of-band access (e.g., KVM, IPMI, or your provider's control panel console) before making network changes, in case you accidentally lock yourself out.
  2. Linux Servers (CentOS, Ubuntu, Debian)
    • Identifying Network Interfaces:
      • Use ip a or ip address show to list your interfaces (e.g., eth0, ens18, enp0s3).
      • (Legacy) ifconfig may also be available.
    • Ubuntu/Debian (using Netplan - Modern method for Ubuntu 18.04+):
      • Netplan uses YAML files located in /etc/netplan/ (e.g., 01-netcfg.yaml or similar).
      • Example Static IPv4 Configuration:network:version: 2renderer: networkd # or 'NetworkManager' if using desktopethernets:ens18: # Replace with your actual interface namedhcp4: no # Disable DHCP for IPv4addresses: [192.168.1.10/24] # Your server's IP address and subnet mask in CIDRroutes:- to: defaultvia: 192.168.1.1 # Your default gateway IPnameservers:addresses: [8.8.8.8, 8.8.4.4] # DNS server IPs# dhcp6: no # Optional: Disable DHCP for IPv6# addresses: ["2001:db8::10/64"] # Example IPv6 address
      • Save the file and apply changes:sudo netplan apply
      • Verify: ip a
    • CentOS/RHEL 7/8 (using NetworkManager & ifcfg files):
      • Network configurations are typically in /etc/sysconfig/network-scripts/ (e.g., ifcfg-ens18).
      • Example Static IPv4 Configuration (ifcfg-ens18):TYPE=EthernetBOOTPROTO=none # Set to 'none' for static IPNAME=ens18DEVICE=ens18ONBOOT=yes # Start interface on bootIPADDR=192.168.1.10 # Your server's IP addressPREFIX=24 # Subnet prefix length (e.g., 24 for 255.255.255.0)GATEWAY=192.168.1.1 # Your default gateway IPDNS1=8.8.8.8 # Primary DNS serverDNS2=8.8.4.4 # Secondary DNS server
        IPV6INIT=yes # Enable IPv6 initialization

        IPV6_AUTOCONF=no # Disable IPv6 autoconfiguration if using static IPv6

        IPV6ADDR="2001:db8::10/64" # Example static IPv6 address
      • Save the file and restart NetworkManager:sudo systemctl restart NetworkManager
      • Verify: ip a or nmcli device show ens18
    • (Legacy) Debian/Ubuntu (/etc/network/interfaces):
      • Still used on some older systems.
      • Example Static IPv4 Configuration:auto eth0 # Replace with your actual interface nameiface eth0 inet staticaddress 192.168.1.10netmask 255.255.255.0gateway 192.168.1.1dns-nameservers 8.8.8.8 8.8.4.4
      • Apply changes:sudo systemctl restart networking # or 'sudo ifdown eth0 && sudo ifup eth0'
      • Verify: ip a
  3. Windows Server
    • Graphical Interface:
      1. Open Server Manager.
      2. Click on "Local Server" in the left pane.
      3. Find "Ethernet" (or your network adapter name) under the "Properties" section and click on it.
      4. In the "Network Connections" window, right-click your network adapter (e.g., "Ethernet") and select "Properties".
      5. Select "Internet Protocol Version 4 (TCP/IPv4)" (or Version 6 if configuring IPv6) and click "Properties".
      6. Choose "Use the following IP address" and enter:
        • IP address: Your server's IP.
        • Subnet mask: Your network's subnet mask.
        • Default gateway: Your default gateway IP.
      7. Enter Preferred DNS server and Alternate DNS server addresses.
      8. Click "OK" on all windows to save changes.
    • PowerShell (for automation or command-line preference):
      • View Network Adapters:Get-NetAdapter
      • Set Static IPv4: (Replace "Ethernet" with your adapter's name)New-NetIPAddress -InterfaceAlias "Ethernet" -IPAddress "192.168.1.10" -PrefixLength 24 -DefaultGateway "192.168.1.1"Set-DnsClientServerAddress -InterfaceAlias "Ethernet" -ServerAddresses ("8.8.8.8","8.8.4.4")
      • Set Static IPv6:New-NetIPAddress -InterfaceAlias "Ethernet" -IPAddress "2001:db8::10" -PrefixLength 64Set-DnsClientServerAddress -InterfaceAlias "Ethernet" -ServerAddresses ("2001:4860:4860::8888","2001:4860:4860::8844")
  4. Important Considerations:
    • Verify with Provider: Always confirm the correct IP address, subnet mask, and gateway details provided by ServerHood.com.
    • Out-of-Band Access: Before applying changes, ensure you have a console or KVM access to revert changes if something goes wrong.
    • DNS Servers: Correct DNS server configuration is essential for your server to resolve domain names and access external services.
    • Firewall: Remember that changing network settings might affect your server's firewall. Ensure your firewall allows necessary inbound and outbound connections after configuration.
  5. Conclusion
    • Proper network interface configuration is the backbone of your server's connectivity. By following these steps, you can ensure your server is correctly connected to the internet and your internal networks.

Was this answer helpful?

« Back

Powered by WHMCompleteSolution