Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Amazon Linux - Configure Network Settings

When running Amazon Linux on AWS, you can find the networking configuration file at:

/etc/sysconfig/network-scripts/ifcfg-eth0

If you edit it, you will likely find content similar to the following:

DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes
TYPE=Ethernet
USERCTL=yes
PEERDNS=yes
IPV6INIT=no
PERSISTENT_DHCLIENT=yes
RES_OPTIONS="timeout:2 attempts:5"
DHCP_ARP_CHECK=no
MTU="9001"

Set Google DNS

One can manually set the DNS provider, by adding the following lines:

DNS1=8.8.8.8
DNS2=8.8.4.4

In this example, we have set the DNS to Google's DNS servers, but you can set any IP addresses you like, such as OpenDNS.

Run the following command for the changes to take immediate effect.

sudo ifdown eth0 && sudo ifup eth0

References

Last updated: 25th January 2023
First published: 8th January 2023

This blog is created by Stuart Page

I'm a freelance web developer and technology consultant based in Surrey, UK, with over 10 years experience in web development, DevOps, Linux Administration, and IT solutions.

Need support with your infrastructure or web services?

Get in touch