Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
static arp on network up
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
trikmik
n00b
n00b


Joined: 06 Nov 2017
Posts: 62

PostPosted: Sun Jan 07, 2018 11:47 am    Post subject: static arp on network up Reply with quote

On debian i would make a permanent static arp by creating file in:
/etc/network/if-up.d/add-my-static-arp
With contents:
Code:
#!/bin/sh
arp -i eth0 -s 192.168.0.4 00:50:cc:44:55:55

Then add the permission:
Code:
chmod +x /etc/network/if-up.d/add-my-static-arp

And these arp entries will be manually added or re-added every time the network interface is brought up.

On Gentoo OpenRC Xorg XFCE4 i can not find the directory /etc/network
If i need to provide any more information about the system please feel free to ask.

How would i make a static arp entry that will be manually added or re-added when the network interface goes up on Gentoo?
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 6962

PostPosted: Sun Jan 07, 2018 12:07 pm    Post subject: Reply with quote

Code:
bzcat /usr/share/doc/netifrc-0.6.0/net.example.bz2 | grep "#postup" -A5
#postup() {
#   # This function could be used, for example, to register with a
#   # dynamic DNS service.  Another possibility would be to
#   # send/receive mail once the interface is brought up.
#}

Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6228
Location: Room 101

PostPosted: Sun Jan 07, 2018 12:14 pm    Post subject: Reply with quote

trikmik ...

/etc/conf.d/net:
postup() {
    arp -i eth0 -s 192.168.0.4 00:50:cc:44:55:55
}

HTH & best ... khay
Back to top
View user's profile Send private message
trikmik
n00b
n00b


Joined: 06 Nov 2017
Posts: 62

PostPosted: Sun Jan 07, 2018 1:17 pm    Post subject: Reply with quote

/etc/conf.d/net
Code:
postup() {
               arp -i wlp2s0 -s 192.0.0.0 2b:ab:a8:48:21:28
}

Does not seem to work; i am using <gnome-extra/nm-applet> and <net-wireless/wpa_supplicant> to set static arp entry when the system connects to the wireless network, does that matter to make the static arp work?
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 6962

PostPosted: Sun Jan 07, 2018 4:54 pm    Post subject: Reply with quote

Quote:
does that matter to make the static arp work?

no that's something the kernel do for you, and it's better to not mess with arp table.
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6228
Location: Room 101

PostPosted: Sun Jan 07, 2018 5:52 pm    Post subject: Reply with quote

trikmik wrote:
Does not seem to work; i am using <gnome-extra/nm-applet> [...]

trikmik ... if you're using nm-applet, then you're using net-misc/networkmanager and not net-misc/netifrc ... and the /etc/conf.d/net is exclusively used by the later.

best ... khay
Back to top
View user's profile Send private message
trikmik
n00b
n00b


Joined: 06 Nov 2017
Posts: 62

PostPosted: Sun Jan 07, 2018 7:52 pm    Post subject: Reply with quote

khayyam wrote:
trikmik wrote:
Does not seem to work; i am using <gnome-extra/nm-applet> [...]

trikmik ... if you're using nm-applet, then you're using net-misc/networkmanager and not net-misc/netifrc ... and the /etc/conf.d/net is exclusively used by the later.

best ... khay


khayyam,

I had to find out the hard way net-misc/networkmanager did not work with postup in /etc/conf.d/net, so i removed net-misc/networkmanager and nm-applet, and switched to wpa_gui (wpa_supplicant) + dhcpcd.
postup in /etc/conf.d/net still does not work (you are right it needs net-misc/netifrc)

now i am stuck on how to carry on, will dhcpcd + wpa_supplicant work with postup in /etc/conf.d/net or will my attempts be futile? if so how can i connect to wifi with dhcp and just using net-misc/netifrc?

if i need to provide more information about the system feel free to ask, thanks for the help.
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6228
Location: Room 101

PostPosted: Sun Jan 07, 2018 8:40 pm    Post subject: Reply with quote

trikmik wrote:
[...] will dhcpcd + wpa_supplicant work with postup in /etc/conf.d/net or will my attempts be futile? if so how can i connect to wifi with dhcp and just using net-misc/netifrc?

trikmik ... yes, something like:

/etc/conf.d/net:
modules_wlp2s0="!plug !iwconfig wpa_supplicant dhcpcd"
wpa_supplicant_wlp2s0="-Dnl80211 -qq"
config_wlp2s0="dhcp"

postup(){
    if [ "$IFACE" = "wlp2s0" ] ; then
        arp -i wlp2s0 -s 192.0.0.0 2b:ab:a8:48:21:28
    fi
}

This assumes that 'dhcpcd' isn't in the runlevel and 'net.wlp2s0' is ... you might also want the following:

/etc/rc.conf:
rc_dhcpcd_provide="!net"

Also, krinn is probably right, you shouldn't be messing with the arp table ... is there a reason for this?

HTH & best ... khay
Back to top
View user's profile Send private message
trikmik
n00b
n00b


Joined: 06 Nov 2017
Posts: 62

PostPosted: Sun Jan 07, 2018 10:24 pm    Post subject: Reply with quote

khayyam,

The provided solution in the post above, made static arp possible on reboot.

If i may ask, could you please explain why it is not a smart thing to set a static arp entry?
I thought setting static arp entry will prevent arp spoofing/poisoning?
Back to top
View user's profile Send private message
szatox
Veteran
Veteran


Joined: 27 Aug 2013
Posts: 1717

PostPosted: Sun Jan 07, 2018 10:53 pm    Post subject: Reply with quote

@trikmik, kernel does network discovery by itself and populates arp table as needed. This configuration is not necessarily static, and doing it manually is not worth the effort.
If you're afraid of arp spoofing, you can install a daemon that will maintain ARP table for you. Much more managable, since you still benefit from automagic discovery, but it also makes kernel ignore updates, so the existing entries can't be easily replaced by a rogue client.
Hopefully, it ignores those updates selectively, so your kernel will update its ARP table after the old entry times out ;)
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