LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 12-15-2016, 03:44 PM   #1
sloppytypist
LQ Newbie
 
Registered: Dec 2016
Posts: 13

Rep: Reputation: Disabled
Set-mss in iptables not modifying mss in TCP packet


Hi,

I cant get iptables to adjust mss in Openwrt.

I need to set all packets exiting to set mss to 1360. I had to turn off pmtu discovery so the auto clamping is not an option. The exit interface is from the gretap tunnel is eth0.3. The packets come into GRETAP interface that is a striongswan radius assigned VIP. So gretap > br0 > eth0.3. So when they exit eth0.3 the GRETAP encapsulation should be gone. I added rules to both mangle FORWARD and POSTROUTING and nothing.

root@Need-Config:/etc# iptables -S -v -t mangle
-P PREROUTING ACCEPT -c 18366 7184558
-P INPUT ACCEPT -c 16635 7056183
-P FORWARD ACCEPT -c 0 0
-P OUTPUT ACCEPT -c 4750 611121
-P POSTROUTING ACCEPT -c 4750 611121
-A FORWARD -o eth0.3 -p tcp -m tcp --tcp-flags SYN,RST SYN -c 0 0 -j TCPMSS --set-mss 1360
-A FORWARD -o eth0 -p tcp -m tcp --tcp-flags SYN,RST SYN -c 0 0 -j TCPMSS --set-mss 1360
-A FORWARD -o eth0.2 -p tcp -m tcp --tcp-flags SYN,RST SYN -m comment --comment "!fw3: wan (mtu_fix)" -c 0 0 -j TCPMSS --clamp-mss-to-pmtu
-A FORWARD -o usb0 -p tcp -m tcp --tcp-flags SYN,RST SYN -m comment --comment "!fw3: wan (mtu_fix)" -c 0 0 -j TCPMSS --clamp-mss-to-pmtu
-A POSTROUTING -o br-br0 -p tcp -m tcp --tcp-flags SYN,RST,ACK SYN -c 0 0 -j TCPMSS --set-mss 1360
-A POSTROUTING -o eth0.3 -p tcp -m tcp --tcp-flags SYN,RST,ACK SYN -c 0 0 -j TCPMSS --set-mss 1360
-A POSTROUTING -o eth0 -p tcp -m tcp --tcp-flags SYN,RST,ACK SYN -c 0 0 -j TCPMSS --set-mss 1360
-A POSTROUTING -o eth0 -p tcp -m tcp --tcp-flags SYN,RST SYN -c 0 0 -j TCPMSS --set-mss 1360
-A POSTROUTING -o eth0.3 -p tcp -m tcp --tcp-flags SYN,RST SYN -c 0 0 -j TCPMSS --set-mss 1360
root@Need-Config:/etc#

I cant get the packets to hit my rules:

root@Need-Config:/etc# iptables -L -v -t mangle
Chain PREROUTING (policy ACCEPT 12207 packets, 4281K bytes)
pkts bytes target prot opt in out source destination

Chain INPUT (policy ACCEPT 10895 packets, 4199K bytes)
pkts bytes target prot opt in out source destination

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 TCPMSS tcp -- any eth0.3 anywhere anywhere tcp flags:SYN,RST/SYN TCPMSS set 1360
0 0 TCPMSS tcp -- any eth0 anywhere anywhere tcp flags:SYN,RST/SYN TCPMSS set 1360
0 0 TCPMSS tcp -- any eth0.2 anywhere anywhere tcp flags:SYN,RST/SYN /* !fw3: wan (mtu_fix) */ TCPMSS clamp to PMTU
0 0 TCPMSS tcp -- any usb0 anywhere anywhere tcp flags:SYN,RST/SYN /* !fw3: wan (mtu_fix) */ TCPMSS clamp to PMTU

Chain OUTPUT (policy ACCEPT 3880 packets, 535K bytes)
pkts bytes target prot opt in out source destination

Chain POSTROUTING (policy ACCEPT 3880 packets, 535K bytes)
pkts bytes target prot opt in out source destination
0 0 TCPMSS tcp -- any br-br0 anywhere anywhere tcp flags:SYN,RST,ACK/SYN TCPMSS set 1360
0 0 TCPMSS tcp -- any eth0.3 anywhere anywhere tcp flags:SYN,RST,ACK/SYN TCPMSS set 1360
0 0 TCPMSS tcp -- any eth0 anywhere anywhere tcp flags:SYN,RST,ACK/SYN TCPMSS set 1360
0 0 TCPMSS tcp -- any eth0 anywhere anywhere tcp flags:SYN,RST/SYN TCPMSS set 1360
0 0 TCPMSS tcp -- any eth0.3 anywhere anywhere tcp flags:SYN,RST/SYN TCPMSS set 1360
root@Need-Config:/etc#

I confirmed with Wireshark that the mss is not being modified as I was expecting.

Any help would be appreciated. I really dont want to remove the DF bit. Thanks.

CB
 
Old 12-16-2016, 12:52 PM   #2
lazydog
Senior Member
 
Registered: Dec 2003
Location: The Key Stone State
Distribution: CentOS Sabayon and now Gentoo
Posts: 1,249
Blog Entries: 3

Rep: Reputation: 194Reputation: 194
Ok, I'm thinking your rules are not matching the packets thus nothing nothing is being altered. Have you tried to remove the Flag settings from your rules since you state "I need to set all packets exiting to set mss to 1360". If you need all packets then the Flag setting should not matter.
 
Old 12-16-2016, 01:58 PM   #3
sloppytypist
LQ Newbie
 
Registered: Dec 2016
Posts: 13

Original Poster
Rep: Reputation: Disabled
Hi Robert,

Here's what I figured out since last night. If I remove the -o flag, set a policy rule, I get further. While my rule gets hits, sadly it does not mangle the mss:

root@Need-Config:/etc# iptables -t mangle -S -v
-P PREROUTING ACCEPT -c 2347 1589909
-P INPUT ACCEPT -c 2306 1586734
-P FORWARD ACCEPT -c 0 0
-P OUTPUT ACCEPT -c 2003 559362
-P POSTROUTING ACCEPT -c 0 0
-A FORWARD -o eth0 -p tcp -m tcp --tcp-flags SYN,RST SYN -c 0 0 -j TCPMSS --set-mss 1340
-A FORWARD -o eth0.2 -p tcp -m tcp --tcp-flags SYN,RST SYN -m comment --comment "!fw3: wan (mtu_fix)" -c 0 0 -j TCPMSS --clamp-mss-to-pmtu
-A FORWARD -o usb0 -p tcp -m tcp --tcp-flags SYN,RST SYN -m comment --comment "!fw3: wan (mtu_fix)" -c 0 0 -j TCPMSS --clamp-mss-to-pmtu
-A POSTROUTING -p tcp -m tcp --tcp-flags SYN,RST,ACK SYN -c 24 1440 -j TCPMSS --set-mss 1340 <--Rule is hit, but does not mangle the tcp mss value on exit
-A POSTROUTING -o eth0 -p tcp -m tcp --tcp-flags SYN,RST SYN -c 0 0 -j TCPMSS --set-mss 1340
-A POSTROUTING -o eth0.2 -c 22435 5712270 -j ACCEPT
-A POSTROUTING -o gre-gretap_NAT1 -c 0 0 -j ACCEPT
-A POSTROUTING -o br-lan -c 3715 559360 -j ACCEPT
-A POSTROUTING -o tap0 -c 0 0 -j ACCEPT
-A POSTROUTING -o eth0.1 -c 0 0 -j ACCEPT
-A POSTROUTING -o lo -c 486 80333 -j ACCEPT
-A POSTROUTING -o eth0.3 -c 0 0 -j ACCEPT
-A POSTROUTING -o br-br0 -c 0 0 -j ACCEPT
-A POSTROUTING -o eth0 -c 2427 116496 -j ACCEPT
root@Need-Config:/etc#

Below is a connection to craigslist from the local client of 10.105.0.200. As you can see, the mss is not 1340, though this rule, "-A POSTROUTING -p tcp -m tcp --tcp-flags SYN,RST,ACK SYN -c 24 1440 -j TCPMSS --set-mss 1340" is being hit.

208.82.237.146.443 > 10.105.0.200.52548: Flags [S.], cksum 0xc92a (correct), seq 1367988955, ack 1299286265, win 8192, options [mss 1460,sackOK,eol], length 0
19:49:12.907690 IP (tos 0x0, ttl 128, id 5805, offset 0, flags [DF], proto TCP (6), length 40)

Not sure why it's not hitting the traffic on eth0.3, but I can come back to that later likely. Thanks.

Chris

Last edited by sloppytypist; 12-16-2016 at 02:00 PM.
 
Old 12-16-2016, 02:27 PM   #4
lazydog
Senior Member
 
Registered: Dec 2003
Location: The Key Stone State
Distribution: CentOS Sabayon and now Gentoo
Posts: 1,249
Blog Entries: 3

Rep: Reputation: 194Reputation: 194
Try changing your rule to something like this;
Code:
iptables -t mangle -A POSTROUTING -p tcp --tcp-flags SYN,RST SYN -o eth0.3 -j TCPMSS --set-mss 1340
 
Old 12-16-2016, 03:29 PM   #5
sloppytypist
LQ Newbie
 
Registered: Dec 2016
Posts: 13

Original Poster
Rep: Reputation: Disabled
No go I'm afraid.

I put in two rules:

iptables -t mangle -A POSTROUTING -p tcp --tcp-flags SYN,RST SYN -o eth0.3 -j TCPMSS --set-mss 1340
iptables -t mangle -A POSTROUTING -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --set-mss 1340


root@Need-Config:/etc# iptables -S -v -t mangle
-P PREROUTING ACCEPT -c 8700 4127458
-P INPUT ACCEPT -c 7599 3954100
-P FORWARD ACCEPT -c 0 0
-P OUTPUT ACCEPT -c 6730 1153074
-P POSTROUTING ACCEPT -c 6730 1153074
-A FORWARD -o eth0.2 -p tcp -m tcp --tcp-flags SYN,RST SYN -m comment --comment "!fw3: wan (mtu_fix)" -c 0 0 -j TCPMSS --clamp-mss-to-pmtu
-A FORWARD -o usb0 -p tcp -m tcp --tcp-flags SYN,RST SYN -m comment --comment "!fw3: wan (mtu_fix)" -c 0 0 -j TCPMSS --clamp-mss-to-pmtu
-A POSTROUTING -o eth0.3 -p tcp -m tcp --tcp-flags SYN,RST SYN -c 0 0 -j TCPMSS --set-mss 1340
-A POSTROUTING -p tcp -m tcp --tcp-flags SYN,RST SYN -c 90 5400 -j TCPMSS --set-mss 1340

The eth0.3 rule gets zero hits and the chain policy rule gets hits but does not modify the mss.

Chris
 
Old 12-16-2016, 08:43 PM   #6
sloppytypist
LQ Newbie
 
Registered: Dec 2016
Posts: 13

Original Poster
Rep: Reputation: Disabled
I did some testing on a couple of Mikrotiks which use iptables/nf. I setup one operating in layer 3 and one operating in L2, bridging ports as my setup is on the current devices. The set-mss did not work in bridge mode. iptables just ignored the packets. I wonder if a packet needs to be L3 routed instead of L2 forwarded for IP tables to adjust the mss? Perhaps?

Chris
 
Old 12-19-2016, 08:54 AM   #7
lazydog
Senior Member
 
Registered: Dec 2003
Location: The Key Stone State
Distribution: CentOS Sabayon and now Gentoo
Posts: 1,249
Blog Entries: 3

Rep: Reputation: 194Reputation: 194
In bridge mode they should be hitting the FORWARD rule set.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
nftables router MSS serafean Linux - Networking 0 12-24-2014 03:48 PM
Tcp mss cjreyn Linux - Networking 2 01-29-2014 01:23 PM
MTU/MSS issue in TCP connection kapsikum Linux - Networking 1 06-10-2008 08:34 AM
set MSS ? Server does NOT send with negotiated MSS lomex Linux - Networking 0 01-30-2008 01:56 PM
Why is netstat -r MSS 40? wsanders Linux - Networking 1 12-12-2003 12:58 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 11:08 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration