Skip to content

Instantly share code, notes, and snippets.

@darklinden
Last active March 4, 2023 09:42
Show Gist options
  • Save darklinden/f4f451421386c67c34c7b8694c67cd1e to your computer and use it in GitHub Desktop.
Save darklinden/f4f451421386c67c34c7b8694c67cd1e to your computer and use it in GitHub Desktop.
Configure CentOS 7 Network Settings And Dnsmasq

Configure CentOS 7 Network Settings

from https://www.serverlab.ca/tutorials/linux/administration-linux/how-to-configure-centos-7-network-settings

  • Static IP

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

    TYPE=Ethernet
    NAME=eth0
    DEVICE=eth0
    ONBOOT=yes
    IPADDR=192.168.1.X
    NETMASK=255.255.255.0
    GATEWAY=192.168.1.1
    BOOTPROTO=static
    DEFROUTE=no
    
  • DNS

    nmcli connection show

    NAME  UUID TYPE  DEVICE
    eth0             eth0
    
    nmcli con mod eth0 ipv4.dns "8.8.8.8"
    nmcli connection up "eth0"
    systemctl restart network
    nmcli connection reload
    
  • Dnsmasq

    yum install dnsmasq -y
    vi /etc/dnsmasq.conf
    
    resolv-file=/etc/resolv.dnsmasq.conf
    addn-hosts=/etc/dnsmasq.hosts
    listen-address=192.168.1.x
    

    vi /etc/resolv.dnsmasq.conf

    nameserver 8.8.8.8
    

    vi /etc/dnsmasq.hosts

    127.0.0.1 whatever.host.to.resolv
    
    systemctl start dnsmasq
    systemctl enable dnsmasq
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment