Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Routing phone AP connected laptop WIFI in home wired network
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
CaptainBlood
Advocate
Advocate


Joined: 24 Jan 2010
Posts: 3993

PostPosted: Wed Jan 08, 2025 12:00 am    Post subject: Routing phone AP connected laptop WIFI in home wired network Reply with quote

Home network has a desktop and a laptop wired through ISP router/swich box@192.168.1.1.
ISP box is currently disconnected from the internet.
Desktop
Code:
enp1s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.55  netmask 255.255.255.0  broadcast 192.168.1.255
        ether f4:4d:30:04:42:4e  txqueuelen 1000  (Ethernet)
        RX packets 294702  bytes 113775672 (108.5 MiB)
        RX errors 0  dropped 1  overruns 0  frame 0
        TX packets 237098  bytes 60680746 (57.8 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 125  base 0x9000
Laptop
Code:
ifconfig
enp2s1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.127  netmask 255.255.255.0  broadcast 192.168.1.255
        ether 00:1e:ec:16:22:81  txqueuelen 1000  (Ethernet)
        RX packets 244927  bytes 61088204 (58.2 MiB)
        RX errors 0  dropped 9288  overruns 0  frame 0
        TX packets 288000  bytes 113275122 (108.0 MiB)
        TX errors 0  dropped 0 overruns 3  carrier 0  collisions 0

wlp1s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.240.146  netmask 255.255.255.0  broadcast 192.168.240.255
        ether 00:1f:3a:6e:60:6b  txqueuelen 1000  (Ethernet)
        RX packets 153564  bytes 175527197 (167.3 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 107723  bytes 13857021 (13.2 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
Networkmanager has enp2s1 in shared method+manual IP4, wlp1s0 in client mode, DHCP only method IP4.

Laptop gets internet fine.
Desktop and laptop are talking fine.

However Desktop has no internet access, i.e. laptop internet access isn't shared.

How to achieve this?

Thks 4 ur attention, interest & suoort.
_________________
USE="-* ..." in /etc/portage/make.conf here, i.e. a countermeasure to portage implicit braces, belt & diaper paradigm
LT: "I've been doing a passable imitation of the Fontana di Trevi, except my medium is mucus. Sooo much mucus. "
Back to top
View user's profile Send private message
Ralphred
l33t
l33t


Joined: 31 Dec 2013
Posts: 701

PostPosted: Wed Jan 08, 2025 12:39 am    Post subject: Reply with quote

Laptop is going to be routing, so you 'll need a basic firewall set-up with masquerade, and /proc/sys/net/ipv4/ip_forward needs to be set to 1. Desktop needs it's default gateway set to the laptops ethernet ip address.
Shout if you want the firewall written, only needs like 5-6 lines.
Back to top
View user's profile Send private message
CaptainBlood
Advocate
Advocate


Joined: 24 Jan 2010
Posts: 3993

PostPosted: Wed Jan 08, 2025 7:47 pm    Post subject: Reply with quote

Ralphred wrote:
Laptop is going to be routing, so /proc/sys/net/ipv4/ip_forward needs to be set to 1
Default here.
Ralphred wrote:
Desktop needs it's default gateway set to the laptops ethernet ip address.
Code:
cat /etc/dhcpcd.conf
#------------------------------------------------------------
##static routers=192.168.1.1
static routers=192.168.1.127
Ralphred wrote:
Laptop is going to be routing, so you 'll need a basic firewall set-up with masquerade...
Shout if you want the firewall written, only needs like 5-6 lines.
Seems like networkmanager set as described in OP installed as
Code:
Installed versions:  1.48.10-r1^t(00:13:15 08/01/2025)(connection-sharing elogind gnutls iptables nftables policykit ppp resolvconf tools wifi -audit -bluetooth -concheck -debug -dhclient -dhcpcd -gtk-doc -introspection -iwd -libedit -modemmanager -nss -ofono -ovs -psl -selinux -syslog -systemd -teamd -test -vala -wext ABI_MIPS="-n32 -n64 -o32" ABI_S390="-32 -64" ABI_X86="64 -32 -x32")
handles all these things internally :)
Lucky networking noob here :lol:

Thks 4 ur attention, interest & support
_________________
USE="-* ..." in /etc/portage/make.conf here, i.e. a countermeasure to portage implicit braces, belt & diaper paradigm
LT: "I've been doing a passable imitation of the Fontana di Trevi, except my medium is mucus. Sooo much mucus. "
Back to top
View user's profile Send private message
Ralphred
l33t
l33t


Joined: 31 Dec 2013
Posts: 701

PostPosted: Wed Jan 08, 2025 10:38 pm    Post subject: Reply with quote

CaptainBlood wrote:
Code:
Installed versions:  1.48.10-r1^t(00:13:15 08/01/2025)(connection-sharing ~~snip~~~
handles all these things internally :)

Didn't know that, nice :)
Back to top
View user's profile Send private message
CaptainBlood
Advocate
Advocate


Joined: 24 Jan 2010
Posts: 3993

PostPosted: Thu Jan 09, 2025 2:00 pm    Post subject: Reply with quote

Ralphred wrote:
Didn't know that, nice :)
What it apparently did:
Code:
nft list ruleset
table ip nm-shared-enp2s1 {
   chain nat_postrouting {
      type nat hook postrouting priority srcnat; policy accept;
      ip saddr 192.168.1.0/24 ip daddr != 192.168.1.0/24 masquerade
   }

   chain filter_forward {
      type filter hook forward priority filter; policy accept;
      ip daddr 192.168.1.0/24 oifname "enp2s1" ct state { established, related } accept
      ip saddr 192.168.1.0/24 iifname "enp2s1" accept
      iifname "enp2s1" oifname "enp2s1" accept
      iifname "enp2s1" reject
      oifname "enp2s1" reject
   }
}
Thks 4 ur attention, interest & support.
_________________
USE="-* ..." in /etc/portage/make.conf here, i.e. a countermeasure to portage implicit braces, belt & diaper paradigm
LT: "I've been doing a passable imitation of the Fontana di Trevi, except my medium is mucus. Sooo much mucus. "
Back to top
View user's profile Send private message
CaptainBlood
Advocate
Advocate


Joined: 24 Jan 2010
Posts: 3993

PostPosted: Thu Jan 09, 2025 3:16 pm    Post subject: Reply with quote

Plz note nftables seems favored over iptables when both are available.
Thks 4 ur attention, interest & support.
_________________
USE="-* ..." in /etc/portage/make.conf here, i.e. a countermeasure to portage implicit braces, belt & diaper paradigm
LT: "I've been doing a passable imitation of the Fontana di Trevi, except my medium is mucus. Sooo much mucus. "
Back to top
View user's profile Send private message
Zucca
Moderator
Moderator


Joined: 14 Jun 2007
Posts: 3874
Location: Rasi, Finland

PostPosted: Sat Jan 11, 2025 1:53 pm    Post subject: Reply with quote

Moved from Other Things Open Source to Networking & Security, since this topic fits better in there and also gets more visibility.
_________________
..: Zucca :..

My gentoo installs:
init=/sbin/openrc-init
-systemd -logind -elogind seatd

Quote:
I am NaN! I am a man!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum