Internet sharing worked, but something like a DNS problem

Issues related to configuring your network
Post Reply
hack3rcon
Posts: 757
Joined: 2014/11/24 11:04:37

Internet sharing worked, but something like a DNS problem

Post by hack3rcon » 2023/07/16 06:27:47

Hello,
I want to share internet from my Linux box to other clients. My Linux box has two NICs as below:

Code: Select all

enp0s3 (Internet)
enp0s8 (Local NIC)
I used the following iptables rules for sharing the internet:

Code: Select all

# iptables -A FORWARD -i enp0s3 -o enp0s8 -m state --state ESTABLISHED,RELATED -j ACCEPT
# iptables -A FORWARD -i enp0s8 -o enp0s3 -j ACCEPT
# iptables -A FORWARD -j LOG
# iptables -t nat -A POSTROUTING -o enp0s3 -j MASQUERADE
Clients have internet, but they can't ping targets by their names. Something like the DNS problem.

Code: Select all

C:\Windows\system32>ping 4.2.2.1

Pinging 4.2.2.1 with 32 bytes of data:
Reply from 4.2.2.1: bytes=32 time=109ms TTL=125
Reply from 4.2.2.1: bytes=32 time=112ms TTL=125
Reply from 4.2.2.1: bytes=32 time=121ms TTL=125
Reply from 4.2.2.1: bytes=32 time=106ms TTL=125

Ping statistics for 4.2.2.1:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 106ms, Maximum = 121ms, Average = 112ms

C:\Windows\system32>ping google.com
Ping request could not find host google.com. Please check the name and try again.

C:\Windows\system32>
How to solve it?

Thank you.

User avatar
jlehtone
Posts: 4532
Joined: 2007/12/11 08:17:33
Location: Finland

Re: Internet sharing worked, but something like a DNS problem

Post by jlehtone » 2023/07/16 09:33:00

When you run "ping google.com" on a client, the client must first resolve the name to address.
Therefore, it will send a query to name server. What is the configured (DNS) server in the clients?


Note: CentOS Stream 8 does:
* Use FirewallD by default
* Has nftables in the kernel
Due to the latter, the tool 'iptables' is a mere wrapper that translates rule in iptables syntax into nftables syntax for the kernel.

The FirewallD manages whole ruleset (that you can see with nft list ruleset). You have to configure firewall via FirewallD,
with command firewall-cmd, or disable firewalld.service and enable nftables.service and write ruleset.

BShT
Posts: 585
Joined: 2019/10/09 12:31:40

Re: Internet sharing worked, but something like a DNS problem

Post by BShT » 2023/07/26 20:28:59

dnf install dnsmasq

you can provide dns and dhcp

hack3rcon
Posts: 757
Joined: 2014/11/24 11:04:37

Re: Internet sharing worked, but something like a DNS problem

Post by hack3rcon » 2023/07/27 11:47:54

BShT wrote:
2023/07/26 20:28:59
dnf install dnsmasq

you can provide dns and dhcp
Hello,
Thank you so much for your reply.
In the Dnsmasq configuration file, which NIC should be the interface value?

User avatar
jlehtone
Posts: 4532
Joined: 2007/12/11 08:17:33
Location: Finland

Re: Internet sharing worked, but something like a DNS problem

Post by jlehtone » 2023/07/27 12:37:21

You did not answer yet:
jlehtone wrote:
2023/07/16 09:33:00
What is the configured (DNS) server in the clients?

Post Reply