You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The wiki says that Ethernet connection doesn't work if plugged directly to the PC, which is true if you consider only an out-of-the-box approach.
I propose the following "guide" that make your PC behave like a DHCP server and also allow the printer to connect to the Internet with NAT.
Prerequisites
root level permissions (i.e. sudo)
dnsmasq installed
iptables installed
Configuration
Assigning a static IP address to ethernet interface
FIrst of all decide an IP subnet, in my case I choose 10.0.0.0/24.
Now assign a static IP to your ethernet interface, I did it via nmtui since it's the easiest (doing it via ip command will assign but then it would get almost instantly removed, probably by NetworkManager itself).
To assign a static IP to your interface do the following (assuming that you have nmtui opened)
Edit a connection
Ethernet > Wired connection 1 (i.e. the ethernet interface which will be used to connect to the printer)
IPv4 CONFIGURATION -> Manual
IPv4 CONFIGURATION -> Addresses -> 10.0.0.1/24
Check "Never use this network for default route"
Check "Ignore automatically obtained routes"
Check "Ignore automatically obtained DNS parameters"
Uncheck "Require IPv4 addressing for this connection"
Check "Automatically connect"
Check "Available to all users"
Press OK, then you can exit from nmtui.
Configuring dnsmasq
Now we have to configure dnsmasq so open the configuration file at /etc/dnsmasq.conf and write the following
Remember to modify interface, dhcp-range and listen-address according to your IPs.
Configure IP forwarding & NAT
Now we have configuare IP forwarding and NAT
To enable IP forwarding, switch to root with sudo su - and then execute the following command
echo 1 > /proc/sys/net/ipv4/ip_forward
You can check if it has been enabled successfully with
sysctl net.ipv4.ip_forward
Then modify the iptables with the following command (you don't need to be root for this, sudo works fine here)
iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
Where wlan0 is the interface that you use to access the internet from your PC
Connecting to the printer
Now connect the printer to the PC with the ethernet cable and check with ip -c a when your ethernet interface gets the static IP, when it gets it you can start dnsmasq with sudo dnsmasq (or, if you prefer, you may also start it as a systemd service`).
At this point just wait a little bit and your printer will get an IP address, to know which address just check dnsmasq logs using either systemctl status dnsmasq or journalctl -xe | grep dnsmasq; you should see something like this.
The wiki says that Ethernet connection doesn't work if plugged directly to the PC, which is true if you consider only an out-of-the-box approach.
I propose the following "guide" that make your PC behave like a DHCP server and also allow the printer to connect to the Internet with NAT.
Prerequisites
root
level permissions (i.e.sudo
)dnsmasq
installediptables
installedConfiguration
Assigning a static IP address to ethernet interface
FIrst of all decide an IP subnet, in my case I choose
10.0.0.0/24
.Now assign a static IP to your ethernet interface, I did it via
nmtui
since it's the easiest (doing it viaip
command will assign but then it would get almost instantly removed, probably byNetworkManager
itself).To assign a static IP to your interface do the following (assuming that you have
nmtui
opened)nmtui
.Configuring
dnsmasq
Now we have to configure
dnsmasq
so open the configuration file at/etc/dnsmasq.conf
and write the followingRemember to modify
interface
,dhcp-range
andlisten-address
according to your IPs.Configure IP forwarding & NAT
Now we have configuare IP forwarding and NAT
To enable IP forwarding, switch to
root
withsudo su -
and then execute the following commandYou can check if it has been enabled successfully with
Then modify the
iptables
with the following command (you don't need to beroot
for this,sudo
works fine here)Where
wlan0
is the interface that you use to access the internet from your PCConnecting to the printer
Now connect the printer to the PC with the ethernet cable and check with
ip -c a
when your ethernet interface gets the static IP, when it gets it you can startdnsmasq
withsudo dnsmasq
(or, if you prefer, you may also start it as asystemd
service`).At this point just wait a little bit and your printer will get an IP address, to know which address just check
dnsmasq
logs using eithersystemctl status dnsmasq
orjournalctl -xe | grep dnsmasq
; you should see something like this.You can now connect to the printer with SSH using
ssh [email protected]
and check if it has connection to the internet with a simple pingThe text was updated successfully, but these errors were encountered: